2992 === Subject: Re: Working with Indeterminate in large numerical lists > > simply try negation: > > Select[x, ! NumberQ[#] &] > > Daniel > > > > > Hi everyone, > > I'm wondering about the optimal way to work with Indeterminate in > > large matrices. I've been using this to replace \bad\ data points \ that > > I want to prevent from polluting calculations involving lists of data, > > but I'm not sure I'm working as smartly as I could be. > > > As an example, suppose I have a list of machine-precision reals and > > some Indeterminate elements: > > > x = RandomSample[Join[RandomReal[1, 1000], ConstantArray > > [Indeterminate, 10]]; > > > If I want to take only the valid entries, the best I have been able to > > find is something like: > > > Select[x, NumberQ] > > > This seems to work reasonably well. But if I want to specifically > > select the Indeterminate entries, there doesn't seem to be any > > function (equivalent to, say, \isnan\ from another system), so I have \ t= o > > resort to something less succinct like > > > > Does anyone have any suggestions on better ways to do this, or any > > general tips for working with Indeterminate in this context? > > > I'm particularly keen to do things in the most efficient way possible > > as I'm working with rather large lists. > > > Peter. Hi again, seems like the neatest solution (in terms of elegance + performance) for my purposes is to use DeleteCases[lst, Indeterminate] when working with a list. A related task is to remove rows of a matrix which contain one or more Indeterminate entry. In this case the following seem to be optimal: Select[mat, FreeQ[#, Indeterminate] &] (* to select valid numeric rows *) and either of Select[mat, MemberQ[#, Indeterminate] &] DeleteCases[mat, {___, Indeterminate, ___}] (* to select invalid rows containing one or more Indeterminate *) I'm slightly surprised that the latter pattern-matching approach is as efficient as the previous one, but it seems to be the case. Peter. === Subject: Re: Working with Indeterminate in large numerical lists >Hi everyone, I'm wondering about the optimal way to work with >Indeterminate in large matrices. I've been using this to replace >\bad\ data points that I want to prevent from polluting calculations >involving lists of data, but I'm not sure I'm working as smartly as >I could be. >As an example, suppose I have a list of machine-precision reals and >some Indeterminate elements: >x = RandomSample[Join[RandomReal[1, 1000], ConstantArray >[Indeterminate, 10]]; >If I want to take only the valid entries, the best I have been able >to find is something like: >Select[x, NumberQ] >This seems to work reasonably well. But if I want to specifically >select the Indeterminate entries, there doesn't seem to be any >function (equivalent to, say, \isnan\ from another system), so I >have to resort to something less succinct like If the goal is to select the non-numeric entries there are a number of ways to do so in addition to what you show above. When you do Select[x, NumberQ] what you are doing is using shorthand for Select[x, NumberQ@#&] You can use essentially this same syntax to get the non-numeric entries by simply negating the selection criteria, i.e. Select[x !NumberQ@#&] or instead of Select you can use Cases, i.e., Cases[x, Indeterminate] But it seems to me the only reason to select the non-numeric entries would be to remove them from other computations. This can be directly done using say DeleteCases. For example, DeleteCases[x, Indeterminate] will eliminate the Indeterminate entries One other thing to keep in mind. Using NumberQ will not select things like Pi which have numeric values. That is In[7]:= Select[{Pi, E}, NumberQ] Out[7]= {} In general for selecting numeric values you want to use NumericQ instead of NumberQ, i.e., In[8]:= Select[{Pi, E}, NumericQ] Out[8]= {Pi, E} === Subject: difference between HeavisidePi and UnitBox I am a very new user, and am not quite clear on the difference between general (HeavisidePi) and numerical (UnitBox, or piecewise) functions. When I try to create a 5-bar pattern using one of these and apply a FourierTransform, I have varying degrees of success... With HeavisidePi I can create an infinite series of them and FourierTransform has no problems, but it doesn't like modifying the argument as in HeavisidePi(x/w) With UnitBox I have the opposite issue. Is there a clear explanation on the difference between the two groups of functions, and when I should use which? === Subject: Re: difference between HeavisidePi and UnitBox what happens at x->1/2 and x->-1/2 with HeavisidePi[] and UnitBox[] ? For distributions like HeavisidePi[] that are used inside of an integral the single point does not matter. For functions like UnitBox[] it may be important. Jens > I am a very new user, and am not quite clear on the difference between > general (HeavisidePi) and numerical (UnitBox, or piecewise) functions. > > When I try to create a 5-bar pattern using one of these and apply a > FourierTransform, I have varying degrees of success... > > With HeavisidePi I can create an infinite series of them and > FourierTransform has no problems, but it doesn't like modifying the > argument as in HeavisidePi(x/w) > > With UnitBox I have the opposite issue. > > Is there a clear explanation on the difference between the two groups > of functions, and when I should use which? > === Subject: Re: new to group - Chemical Equation I'm currently reading a paper that might apply here: \Model Reduction via Projection onto Nonlinear Manifolds with Application to Analog Circuits and Biochemical Systems\ by Chenjie Gu and Jaijeet Roychowdhury HTH best tom === Subject: tensegrity and FindRoot for quadratic systems I have implemented the following code for simulating a 3x3 lattice of \ vertices, connected by 16 rigid bars to form 8 triangles, fixed at two \ points, and under the action of the gravity (the configuration can be seen in \ the animation that the code creates at the end). My problem is that for this \ particular geometry, FindRoot is not able to find a solution within the \ prescribed tolerance. Does this mean that I am in a local minimum? What can I \ do to avoid this situation? len[p1_, p2_] := (p2[[1]] - p1[[1]])*(p2[[1]] - p1[[1]]) + (p2[[2]] - p1[[2]])*(p2[[2]] - p1[[2]]) + (p2[[3]] - p1[[3]])*(p2[[3]] - p1[[3]]) strain[q_] := { len[q[[1]], q[[2]]] - 25, len[q[[2]], q[[4]]] - 25, len[q[[3]], q[[4]]] - 25, len[q[[1]], q[[3]]] - 25, len[q[[1]], q[[4]]] - 50, len[q[[2]], q[[5]]] - 25, len[q[[5]], q[[6]]] - 25, len[q[[4]], q[[6]]] - 25, len[q[[2]], q[[6]]] - 50, len[q[[6]], q[[7]]] - 25, len[q[[4]], q[[7]]] - 50, len[q[[7]], q[[8]]] - 25, len[q[[4]], q[[8]]] - 25, len[q[[3]], q[[8]]] - 50, len[q[[3]], q[[9]]] - 25, len[q[[8]], q[[9]]] - 25, q[[1, 1]] - 0, q[[1, 2]] - 0, q[[1, 3]] - 0, q[[9, 1]] - 0, q[[9, 2]] - 10, q[[9, 3]] - 0 } undeformed = {{0, 0, 0}, {5, 0, 0}, {0, 5, 0}, {5, 5, 0}, {10, 0, 0}, {10, 5, 0}, {10, 10, 0}, {5, 10, 0}, {0, 10, 0}}; force = { {0, 0, 98}, {0, 0, 98}, {0, 0, 98}, {0, 0, 98}, {0, 0, 98}, {0, 0, 98}, {0, 0, 98}, {0, 0, 98}, {0, 0, 98} }; EL[u_, p_, q_, \\[Lambda]_] := Flatten[{ {(q - p)/dt - (p - u)/dt} - \\[Lambda] .D[ strain[q], {q}] - {force}, {strain[q]} }] deformed = { {x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}, {x4, y4, z4}, {x5, y5, z5}, {x6, y6, z6}, {x7, y7, z7}, {x8, y8, z8}, {x9, y9, z9} }; dt = 1/1000; multipliers = { {l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20, l21, l22} }; hess[u_, p_, sym_, lag_] := D[ EL[u, p, sym, lag], {Flatten[{sym, lag}]} ] hess[undeformed, undeformed, deformed, multipliers]; step[u_, p_] := FindRoot[ EL[u, p , { {x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}, {x4, y4, z4}, {x5, y5, z5}, {x6, y6, z6}, {x7, y7, z7}, {x8, y8, z8}, {x9, y9, z9} }, { {l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20, l21, l22} }], {{x1, p[[1, 1]]}, {y1, p[[1, 2]]}, {z1, p[[1, 3]]}, {x2, p[[2, 1]]}, {y2, p[[2, 2]]}, {z2, p[[2, 3]]}, {x3, p[[3, 1]]}, {y3, p[[3, 2]]}, {z3, p[[3, 3]]}, {x4, p[[4, 1]]}, {y4, p[[4, 2]]}, {z4, p[[4, 3]]}, {x5, p[[5, 1]]}, {y5, p[[5, 2]]}, {z5, p[[5, 3]]}, {x6, p[[6, 1]]}, {y6, p[[6, 2]]}, {z6, p[[6, 3]]}, {x7, p[[7, 1]]}, {y7, p[[7, 2]]}, {z7, p[[7, 3]]}, {x8, p[[8, 1]]}, {y8, p[[8, 2]]}, {z8, p[[8, 3]]}, {x9, p[[9, 1]]}, {y9, p[[9, 2]]}, {z9, p[[9, 3]]}, {l1, 0}, {l2, 0}, {l3, 0}, {l4, 0}, {l5, 0}, {l6, 0}, {l7, 0}, {l8, 0}, {l9, 0}, {l10, 0}, {l11, 0}, {l12, 0}, {l13, 0}, {l14, 0}, {l15, 0}, {l16, 0}, {l17, 0}, {l18, 0}, {l19, 0}, {l20, 0}, {l21, 0}, {l22, 0}} , Jacobian -> hess[u, p, { {x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}, {x4, y4, z4}, {x5, y5, z5}, {x6, y6, z6}, {x7, y7, z7}, {x8, y8, z8}, {x9, y9, z9} }, { {l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20, l21, l22} }] ] tri = { {0, 0, 0}, {x2, y2, z2}, {x4, y4, z4}, {x3, y3, z3}, {0, 0, 0}, {x4, y4, z4}, {x6, y6, z6}, {x2, y2, z2}, {x5, y5, z5}, {x6, y6, z6}, {x7, y7, z7}, {x4, y4, z4}, {x8, y8, z8}, {x3, y3, z3}, {x9, y9, z9}, {x8, y8, z8}, {x7, y7, z7} }; edgeT = {tri} /. { x2 -> 5, y2 -> 0, z2 -> 0, x3 -> 0, y3 -> 5, z3 -> 0, x4 -> 5, y4 -> 5, z4 -> 0, x6 -> 10, y6 -> 5, z6 -> 0, x5 -> 10, y5 -> 0, z5 -> 0, x7 -> 10, y7 -> 10, z7 -> 0, x8 -> 5, y8 -> 10, z8 -> 0, x9 -> 0, y9 -> 10, z9 -> 0 }; vtx = { {x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}, {x4, y4, z4}, {x5, y5, z5}, {x6, y6, z6}, {x7, y7, z7}, {x8, y8, z8}, {x9, y9, z9} }; vold = undeformed vnew = undeformed; For[i = 0, i < 10, i++, sol = step[vold, vnew]; vold = vnew; vnew = vtx /. sol; edge = tri /. sol; Print[i]; AppendTo[edgeT, edge]; ] Animate[ Graphics3D[Line[edgeT[[i]]], PlotRange -> {{-2, 12}, {-2, 12}, {-1, 10}}], {i, 1, 10}, AnimationRunning -> False ] === Subject: \move cursor out of formula by one level\ I am hoping there is a Front End thingy via code that does the same thing. Is there and any examples of using it? My goal is to move around in a formula via buttons instead of keyboard. Andrew === Subject: Re: SingularValueDecomposition V6 > > In short: Is there a way to change the method in \ SingularValueDecomposition? > Explanation: > I have coded a relaxation scheme for solving a system of non-linear ODEs. \ The > relaxation scheme involves solving a linear system of algebraic equations \ in > the form S.b=-e. The matrix S is in my case 2000x2000. I use Krylov's \ method to > solve it. At certain conditions the system becomes unstable/singular. So I \ am > interested in finding the SVD for that Matrix. Unfortunately though the \ default > method is extermely slow. I couldn't find in the help which method for \ finding > the SVD is used, but by how slow it is I would assume it is the RQ method > (which goes like n^4). But I was told that method's like \divide and \ conquer\ > go like n^3*Ln(n) and will be significantly faster (and I have been told \ there > are even faster methods). Is there a way to change the method in > SingularValueDecomposition? > > In the end I could possibly use another method for resolving \ singularities > (S-mI).b=-e, but to evaluate m I still need to know what the maximum \ singular > value is. Will SingularValueList be sufficiently fast? Is there a way to \ change > the method there? > > Alexander Here http://reference.wolfram.com/mathematica/note/SomeNotesOnInternalImplementat\ ion.html#30506 you can find some explanations: \SingularValueDecomposition uses the QR algorithm with Givens rotations. PseudoInverse, NullSpace and MatrixRank are based on SingularValueDecomposition. For sparse arrays, Arnoldi methods are used.\ -- == Matemati=E8ko podzemlje == http://www.matematicko-podzemlje.com/ http://matka.forumotion.com/ http://www.travian.com.hr/?uc=hr3_5588 === Subject: formatting of string in input vs. output cells Does anyone know the cell style options which control how strings are displayed? As a simple example, when you enter the following in a notebook session: In[44]:= \x\ Out[44]= x The output cell suppresses the double quotes \\. This also occurs with things like NumberForm and so on. It becomes a pain when you, say, print a table of numbers formatted using NumberForm, and then copy this to a cell of a different type, where suddenly the quotes become visible. What I'd like to know is what cell formatting option is controlling the display/suppression of the quotes, so that I can add to whatever other cell types I need to use (e.g. \Table\ styles). Digging in the option inspector I have not been able to find anything, and there doesn't seem to be much documentation either. Peter. === Subject: Re: formatting of string in input vs. output cells Output cells generally ahve the option ShowStringCharacters->False You can see this by looking at the Core.nb style sheet and examining the format of the Output cell style. -_David > Does anyone know the cell style options which control how strings are > displayed? As a simple example, when you enter the following in a > notebook session: > > In[44]:= \x\ > Out[44]= x > > The output cell suppresses the double quotes \\. This also occurs with > things like NumberForm and so on. It becomes a pain when you, say, > print a table of numbers formatted using NumberForm, and then copy > this to a cell of a different type, where suddenly the quotes become > visible. > > What I'd like to know is what cell formatting option is controlling > the display/suppression of the quotes, so that I can add to whatever > other cell types I need to use (e.g. \Table\ styles). Digging in the > option inspector I have not been able to find anything, and there > doesn't seem to be much documentation either. > > Peter. === Subject: Problems with V7 Hi group! I installed the in home use Mathematica 7 and have used it for a while. \ Suddenly, the other day I started it and immediately noticed somethind was \ wrong, because the fonts used in an input cell looked strange. Furthermore, it does not evaluate the input cells. I tried to start the \ local kernel manualy, to no avail. Has anybody else experienced this? Any suggestions? Sergio Terrazas === Subject: Re: Problems with V7 On May 29, 6:58 pm, Sergio Miguel Terrazas Porras > Hi group! > > I installed the in home use Mathematica 7 and have used it for a while. \ S= uddenly, the other day I started it and immediately noticed somethind was \ w= rong, because the fonts used in an input cell looked strange. > > Furthermore, it does not evaluate the input cells. I tried to start the \ l= ocal kernel manualy, to no avail. > Has anybody else experienced this? > > Any suggestions? > > > Sergio Terrazas What OS version is this? Make a spare copy of your init.m file ($UserBaseDirectory/Library/Mathematica/FrontEnd/init.m) and try to restart Mathematica in a clean restart mode (init.m gets erased when started in this mode). On Mac's you hold down the Shift-Option when starting and on Windows you hold down the Shift-Control while restarting. If you get it to start correctly would suspect a corrupted init.m file, so if that appears to be the case you might try and take a look at the saved init.m file you made beforehand and see if you can spot any problems. Good Luck ... -Bob ps - when reporting strange errors I think it is always a good idea to say in a post the OS version as well as the exact Mathematica version and any other important information. === Subject: Print numbers to ASCII file with precise column widths I want to generate some \simple\ ASCII files suitable for reading by old Fortran programs, which expect numbers in precise formatted columns, e.g., \FORMAT(I5,F10.3,E10.5)\. I've been trying all sorts of variations of PaddedForm, FortranForm, OutputForm, ..... Here's an example with a simple negative integer: strm = OpenWrite[\testout.txt\]; WriteString[strm, ToString[ PaddedForm[-11, 5] ] <> \\\n\]; WriteString[strm, \1234567890\]; Close[strm]; FilePrint[\testout.txt\]; -11 1234567890 The font in this post doesn't show it, but the \-11\ ends in the 6th column, not the 5th. And then I need to tackle floats with exponents!! I obviously don't understand the underlying Mathematica V7 output functionality. === Subject: Re: Install problem of Mathematica kernel What OS is this running on? Is there both a mathematica and a mathkernel process running on the computer? Is there any messages in the system logs about errors when Mathematica tries to start up? Did you have a previous version of Mathematica installed before this 7.0 version. Were there any errors when you did the install? Did the license number install without any problems? Try to supply more info if you can. -Bob === Subject: Mathematica versions - release and feature history (from 1989 to Here is a nice summary of all the versions of Mathematica containing lots of interesting details about what features were developed as part of a new release of Mathematica (shows only the year that releases came out, but would be nice if they added the month also): http://www.wolfram.com/products/mathematica/quickrevisionhistory.html -Bob === Subject: Re: Mathematica for Behavioral Research? === Subject: RandomReal gets stuck For a simulation of a stochastic process I am making use of RandomReal. I noticed that at some point during the simulation the output of RandomReal[] becomes fixed. For some reason, totally beyond my comprehension, every time after I execute an optimization the RandomReal[] generates the same series of random numbers: In[217]:= optimalactivity Out[217]= {24, 336/25, 616/25, 32/5, 28/5, 76/25, 4, 8, 8, 4/5, 0, 0, \\ 0, 0, 0, 4/5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\ 0, 0, 0, 0, 0, 12, 28, 80, 0, 104/3, 0, 234/125, 0, 0, 0, 0, 4, 0, 0, \\ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} In[218]:= RandomReal[] Out[218]= 0.455719 In[219]:= RandomReal[] Out[219]= 0.977826 In[220]:= RandomReal[] Out[220]= 0.943215 In[221]:= RandomReal[] Out[221]= 0.962216 In[222]:= RandomReal[] Out[222]= 0.302348 In[223]:= optimalactivity Out[223]= {24, 336/25, 616/25, 32/5, 28/5, 76/25, 4, 8, 8, 4/5, 0, 0, \\ 0, 0, 0, 4/5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\ 0, 0, 0, 0, 0, 12, 28, 80, 0, 104/3, 0, 234/125, 0, 0, 0, 0, 4, 0, 0, \\ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} In[224]:= RandomReal[] Out[224]= 0.455719 In[225]:= RandomReal[] Out[225]= 0.977826 In[226]:= RandomReal[] Out[226]= 0.943215 In[227]:= RandomReal[] Out[227]= 0.962216 In[228]:= RandomReal[] Out[228]= 0.302348 optimalactivity simpy calculates an optimum allocation of resources: optimalactivity := Table[y[i], {i, Length[inputmatrix]}] /. Maximize[ Plus @@ (Table[y[i], {i, Length[inputmatrix]}].(outputmatrix - inputmatrix))[[consumables - 2]], CONDITIONS , Table[y[i], {i, Length[inputmatrix]}]][[2]] There is no SeedRandom[] anywhere to be found. Bas Straatman === Subject: Re: RandomReal gets stuck Hi Bas, I can confirm this bug. Executing an even simpler version, namely Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; will also set the random generator to a fixed starting point. The number 31 is crucial, as lower values do not appear to cause the bug, while higher values do. Changing Plus to Times appears to prevent the bug. In[394]:= Table[ Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; RandomReal[], {20} ] During evaluation of In[394]:= Maximize::natt: The maximum is not attained at any point satisfying the given constraints. >> Out[394]= {0.455719, 0.455719, 0.455719, 0.455719, 0.455719, \\ 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, \\ 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, \\ 0.455719} This is very nasty, as a lot of people critically depend on random functions to be random. I would urge you to report this to wolfram support. > > For a simulation of a stochastic process I am making use of RandomReal. > I noticed that at some point during the simulation the output of > RandomReal[] becomes fixed. For some reason, totally beyond my > comprehension, every time after I execute an optimization the > RandomReal[] generates the same series of random numbers: > > In[217]:= optimalactivity > > Out[217]= {24, 336/25, 616/25, 32/5, 28/5, 76/25, 4, 8, 8, 4/5, 0, 0, \\ > 0, 0, 0, 4/5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\ > 0, 0, 0, 0, 0, 12, 28, 80, 0, 104/3, 0, 234/125, 0, 0, 0, 0, 4, 0, 0, \\ > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} > > In[218]:= RandomReal[] > > Out[218]= 0.455719 > > In[219]:= RandomReal[] > > Out[219]= 0.977826 > > In[220]:= RandomReal[] > > Out[220]= 0.943215 > > In[221]:= RandomReal[] > > Out[221]= 0.962216 > > In[222]:= RandomReal[] > > Out[222]= 0.302348 > > In[223]:= optimalactivity > > Out[223]= {24, 336/25, 616/25, 32/5, 28/5, 76/25, 4, 8, 8, 4/5, 0, 0, \\ > 0, 0, 0, 4/5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\ > 0, 0, 0, 0, 0, 12, 28, 80, 0, 104/3, 0, 234/125, 0, 0, 0, 0, 4, 0, 0, \\ > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} > > In[224]:= RandomReal[] > > Out[224]= 0.455719 > > In[225]:= RandomReal[] > > Out[225]= 0.977826 > > In[226]:= RandomReal[] > > Out[226]= 0.943215 > > In[227]:= RandomReal[] > > Out[227]= 0.962216 > > In[228]:= RandomReal[] > > Out[228]= 0.302348 > > optimalactivity simpy calculates an optimum allocation of resources: > > optimalactivity := Table[y[i], {i, Length[inputmatrix]}] /. Maxi= mize[ > Plus @@ (Table[y[i], {i, Length[inputmatrix]}].(outputmatrix = - > inputmatrix))[[consumables - 2]], CONDITIONS , > Table[y[i], {i, Length[inputmatrix]}]][[2]] > > There is no SeedRandom[] anywhere to be found. > > > Bas Straatman === Subject: Re: Parallel processing Well, I know (from experience) that linear algebra routines were paralellized already prior to version 7. So, when I used NDSolve to solve large systems of coupled ordinary differential equations, which makes heavy use of such routines, the calculation actually used (magically, because I did not have to do anything for that) parallel processing even in version 5.2 and 6. >> >> I am running version 7.01 on a quad core CPU. I am doing some heavy >> calculations but was too lazy to use any special commands for >> parallelization. >> >> However, to my surprise, when I check the performance I see that all 4 >> kernels a busy calculating. >> >> Does anybody have any info about this automatic parallelization of >> Mathematica? >> >> Daniel >> >> >> > Prior to 7.0 there was talk that certain cpu-intensive algorithms would > make use of multiple cores where appropriate - presumable they still do. > Where does your program spend its time? > > David Bailey > http://www.dbaileyconsultancy.co.uk > === Subject: Re: Parallel processing > > I am running version 7.01 on a quad core CPU. I am doing some heavy > calculations but was too lazy to use any special commands for > parallelization. > > However, to my surprise, when I check the performance I see that all 4 > kernels a busy calculating. > > Does anybody have any info about this automatic parallelization of > Mathematica? > > Daniel According to this bit of Wolfram news from July 12, 2005 at http://www.wolfram.com/news/mathematica52.html: Mathematica 5.2 also supports automatically threaded numerical linear algebra on all mainstream platforms, enabling linear algebra operations to automatically run in parallel on all available processor cores whether multiple or multicore CPUs. Mainstream multicore-based systems are now available and are expected to be ubiquitous by early next year, including in notebooks and entry-level systems. -Bob === Subject: Re: Parallel processing > > I am running version 7.01 on a quad core CPU. I am doing some heavy > calculations but was too lazy to use any special commands for > parallelization. > > However, to my surprise, when I check the performance I see that all 4 > kernels a busy calculating. > > Does anybody have any info about this automatic parallelization of > Mathematica? > > Daniel So what kind of calculations were you doing? I think ever since version 5.2 Mathematica has taken advantage of multicore and/or multiprocessor systems for many common numerical linear algebra operations such as dot products, matrix inversions, etc by parallelizing them across multiple CPU's and this type of parallelism is applied automatically and is not controllable by the user. This is totally different from the new parallel user level routines built into 7.0 and newer versions and older versions with the PCT (Parallel Computing Toolkit). For example try: (extracted from \Fibonacci Determinants\ demonstration example by Michael Croucher on the http://demonstrations.wolfram.com/FibonacciDeterminants/ web site) fibon[size_] := If[size == 1, Text@Row[{\det(1)\, \ = \, 1}] , Text@Row[{det (MatrixForm[ SparseArray[{Band[{1, 1}] -> 1, Band[{2, 1}] -> Style[i, Italic], Band[{1, 2}] -> Style[i, Italic]}, {size, size}]]) , \ = \ , Det[ SparseArray[{Band[{1, 1}] -> 1, Band[{2, 1}] -> I, Band[{1, 2}] -> I}, {size, size}]] } ] ]; fibon[2000] and watch all your processors get pegged to the max but yet there is only one mathkernel and mathematica process running. If you're doing something the \PCT\ way then you would have multiple mathkernel's running (up to your license limit) but you would have to write code using the parallel routines to implement the task. -Bob === Subject: Re: Tube in ParametricPlot3D with too many details > > > I'm using the following code to get a tube around a homoclinic loop > > > hloop = ParametricPlot3D[{-2 Sech[ u], u - 2 Tanh[ u], 0 }, {u, -5, > > 5}, PlotStyle -> {Tube[0.1], Red}, Axes -> None] > > > The only issue is that, if I try to export it as a pdf, I get too many > > details which results in (too) big pdf. > > > Is there anyway to have Mathematica producing a plot with less > > > Giovanni Lanzani > > This problem came up with version 6 for graphics rendered using > GraphicsComplex. It has been discussed in this group. The best solution > is to use File->PrintSelection. In the printer menu chose \save\ to > print to a pdf. > > The drawback is, the picture takes a whole page, so you have to open it > in a graphics program like GraphicsConverter (on Mac) to adjust the \ regio= n. > > -- > _________________________________________________________________ > Peter Breitfeld, Bad Saulgau, Germany --http://www.pBreitfeld.de this did the trick. > It has been discussed in this group. The best solution > is to use File->PrintSelection. Would it be possible to point me the discussions where the others solutions are explained? === Subject: Better version of V3 of Mathematica Book? The website version of the Mathematica Book v3 is riddled with formating errors in the html presentation. I am hoping someone has a properly formatted pdf version of V3 they would not mind sharing. If so, contact me off list. Or they have v3 running on some ancient box Andrew === Subject: Re: RandomReal gets stuck >For a simulation of a stochastic process I am making use of >RandomReal. I noticed that at some point during the simulation the >output of RandomReal[] becomes fixed. For some reason, totally >beyond my comprehension, every time after I execute an optimization >the RandomReal[] generates the same series of random numbers: >optimalactivity simpy calculates an optimum allocation of resources: >optimalactivity := Table[y[i], {i, Length[inputmatrix]}] /. Maximize[ >Plus @@ (Table[y[i], {i, Length[inputmatrix]}].(outputmatrix - >inputmatrix))[[consumables - 2]], CONDITIONS , Table[y[i], {i, >Length[inputmatrix]}]][[2]] >There is no SeedRandom[] anywhere to be found. While it is true the code fragment above makes no call to SeedRandom, that really doesn't mean much at all. This code fragment calls several other things that are defined elsewhere and makes no call to RandomReal. That is the problem has to be at a lower level in the code you've written. On my machine, there is no evidence RandomReal gets \stuck\. For example, In[1]:= Length@Union@Table[RandomReal[], {10^6}] Out[1]= 1000000 In[2]:= $Version Out[2]= 7.0 for Mac OS X x86 (64-bit) (February 19, 2009) Note, it is more efficient to generate a million random values using RandomReal[1, {10^6}] I simply chose to use Table to call RandomReal a large number of times since this is what you were doing. === Subject: String as a variable name In a data analysis package I use often, a facility is provided for substituting a string for the name of a variable. Quoting from the user manual: \String Substitution Using $: Wherever Igor expects the literal name of an operand, such as the name of a wave, you can instead provide a string expression preceded by the $ character. The $ character tells Igor to evaluate the string expression and substitute that value as the name it expected.\ For example, I can write: VariableName=\variable\+\1\ $variableName=10, the variable whose name is variable1 would then be assigned the value 10. I was looking for an equivalent in Mathematica. I tried looking into the Symbol function, but haven't found a way to use it for this purpose. Thus, something like: Symbol[\variable\<>\1\]=10 does not work. I sometimes need to create variables during the execution of a program \ whose names are made up from concatenated strings and I need to be able to assign values to them. Any idea ? A.B. === Subject: Re: String as a variable name I found it: I forgot to wrap Evaluate around the assignment. This works: Symbol[\variable\<>\1\]//Evaluate=10 A.B. > In a data analysis package I use often, a facility is provided for > substituting a string for the name of a variable. Quoting from the user > manual: > > \String Substitution Using $: > Wherever Igor expects the literal name of an operand, such as the name of \ a > wave, you can instead provide a string expression preceded by the $ \ character. > The $ character tells Igor to evaluate the string expression and \ substitute > that value as the name it expected.\ > > For example, I can write: > VariableName=\variable\+\1\ > $variableName=10, > > the variable whose name is variable1 would then be assigned the value 10. > > I was looking for an equivalent in Mathematica. I tried looking into the > Symbol function, but haven't found a way to use it for this purpose. \ Thus, > something like: > > Symbol[\variable\<>\1\]=10 > > does not work. > > I sometimes need to create variables during the execution of a program \ whose > names are made up from concatenated strings and I need to be able to \ assign > values to them. > > Any idea ? > > A.B. === Subject: can SendMail use HTML and embedded images A nice new feature of v7 is SendMail. I use Mathematica to run hourly/daily stats on my web servers, and I started to use SendMail to send the stats. I searched the documentation at length, but I have not figured out how to send the email with an HTML and embedded images. Has anyone looked into this? I believe html in emails can use a Hello MathGroup: > > I have this exceeding simple Mathematica program: > > dumpEthn[ctry_String] := Module[ > {leg , dat, cData}, > cData = CountryData[ctry, \EthnicGroupsFractions\]; > If[Head@cData == ToExpression[\CountryData\] > , Return[\Invalid Country(\ <> ctry <> \)\]]; > If[MatchQ[cData[[1, 2]], _Missing] > , Return[\Missing fraction data for \ <> ctry]]; > leg = #[[1]] & /@ cData; > dat = #[[2]] & /@ cData; > PieChart[dat > , ChartLegends -> leg > , PlotLabel -> \Ethnic groups in \ <> ctry > ] > ] > > I invoke it thusly: > > dumpEthn[#] & /@ CountryData[\Asia\] > > It produces a bunch of PieCharts. > > When I print it is gives 50 *blank* pages. When I Save-As-PDF, I get > 50 *blank* pages. > > A single pie chart seems to print, i.e. dumpEthn[\Iran\]. > > I reported this to WRI support. > > Can anyone suggest any other work-around on this? In the excitement > about W|A, I wanted to show this to someone. > > TIA and I am running 7.0.1/XPSP3. > > > Roger Williams > Franklin Laboratory > http://www.meetup.com/The-San-Francisco-Math-Meetup-Group/ > === Subject: printing problem with very simple application Hello MathGroup: I have this exceeding simple Mathematica program: dumpEthn[ctry_String] := Module[ {leg , dat, cData}, cData = CountryData[ctry, \EthnicGroupsFractions\]; If[Head@cData == ToExpression[\CountryData\] , Return[\Invalid Country(\ <> ctry <> \)\]]; If[MatchQ[cData[[1, 2]], _Missing] , Return[\Missing fraction data for \ <> ctry]]; leg = #[[1]] & /@ cData; dat = #[[2]] & /@ cData; PieChart[dat , ChartLegends -> leg , PlotLabel -> \Ethnic groups in \ <> ctry ] ] I invoke it thusly: dumpEthn[#] & /@ CountryData[\Asia\] It produces a bunch of PieCharts. When I print it is gives 50 *blank* pages. When I Save-As-PDF, I get 50 *blank* pages. A single pie chart seems to print, i.e. dumpEthn[\Iran\]. I reported this to WRI support. Can anyone suggest any other work-around on this? In the excitement about W|A, I wanted to show this to someone. TIA and I am running 7.0.1/XPSP3. Roger Williams Franklin Laboratory http://www.meetup.com/The-San-Francisco-Math-Meetup-Group/ === Subject: Re: printing problem with very simple application Hi Roger, A workaround would be to add //Column after the invocation of your function. At least, it works for generating a PDF. Have not tried printing it. I can confirm that in the original version a blank PDF is obtained. BTW the part > leg = #[[1]] & /@ cData; > dat = #[[2]] & /@ cData; in your function is a complicated way to address certain columns in your data (although cData actually contains rules instead of lists). In my opinion, a prettier version would be leg = cData[[All, 1]]; dat = cData[[All, 2]]; > Hello MathGroup: > > I have this exceeding simple Mathematica program: > > dumpEthn[ctry_String] := Module[ > {leg , dat, cData}, > cData = CountryData[ctry, \EthnicGroupsFractions\]; > If[Head@cData == ToExpression[\CountryData\] > , Return[\Invalid Country(\ <> ctry <> \)\]]; > If[MatchQ[cData[[1, 2]], _Missing] > , Return[\Missing fraction data for \ <> ctry]]; > leg = #[[1]] & /@ cData; > dat = #[[2]] & /@ cData; > PieChart[dat > , ChartLegends -> leg > , PlotLabel -> \Ethnic groups in \ <> ctry > ] > ] > > I invoke it thusly: > > dumpEthn[#] & /@ CountryData[\Asia\] > > It produces a bunch of PieCharts. > > When I print it is gives 50 *blank* pages. When I Save-As-PDF, I get > 50 *blank* pages. > > A single pie chart seems to print, i.e. dumpEthn[\Iran\]. > > I reported this to WRI support. > > Can anyone suggest any other work-around on this? In the excitement > about W|A, I wanted to show this to someone. > > TIA and I am running 7.0.1/XPSP3. > > > Roger Williams > Franklin \ Laboratoryhttp://www.meetup.com/The-San-Francisco-Math-Meetup-Gr= oup/ === Subject: two questions a. I made a package and I want to retrieve the functions it has. What I \ would want is: Command[mypackage] Output: functions for the user contained in myg package How can I do this? Somehow, I have failed to find this in the \ documentation. b. According to you what are the best references to study the theme of \ packages in Mathematica? Francisco === Subject: Re: How can I get the previous Fibonacci calculated number in a \ specific Try the function Fibonacci. Look it up in the documentation center. Best, Harvey -----Original Message----- === Subject: How can I get the previous Fibonacci calculated number in a specific How can I get a previous Fibonacci calculated number in a specific range. I can calculate the previous number of phi see below phi1 =(1+sqrt(5))/2 13/phi1 I tested it with 13 and got 8.034441857 .....so that works but how can I get only the previous numbers of Fibonacci in a specified range from 20 to 20000 if I input a large number like 234.34e10 tia sal2 === Subject: Re: printing problem with very simple application Include Print in definition of dumpEthn and suppress output when calling \ dumpEthn. dumpEthn[ctry_String] := Module[ {leg, dat, cData}, cData = CountryData[ctry, \EthnicGroupsFractions\]; If[Head@cData == ToExpression[\CountryData\], Return[Print[\Invalid Country(\ <> ctry <> \)\]]]; If[MatchQ[cData[[1, 2]], _Missing], Return[Print[\Missing fraction data for \ <> ctry]]]; leg = #[[1]] & /@ cData; dat = #[[2]] & /@ cData; Print[ PieChart[dat, ChartLegends -> leg, PlotLabel -> \Ethnic groups in \ <> ctry]]] dumpEthn[#] & /@ CountryData[\Asia\]; This works on my Mac when I print the result to a PDF. Bob Hanlon Hello MathGroup: I have this exceeding simple Mathematica program: dumpEthn[ctry_String] := Module[ {leg , dat, cData}, cData = CountryData[ctry, \EthnicGroupsFractions\]; If[Head@cData == ToExpression[\CountryData\] , Return[\Invalid Country(\ <> ctry <> \)\]]; If[MatchQ[cData[[1, 2]], _Missing] , Return[\Missing fraction data for \ <> ctry]]; leg = #[[1]] & /@ cData; dat = #[[2]] & /@ cData; PieChart[dat , ChartLegends -> leg , PlotLabel -> \Ethnic groups in \ <> ctry ] ] I invoke it thusly: dumpEthn[#] & /@ CountryData[\Asia\] It produces a bunch of PieCharts. When I print it is gives 50 *blank* pages. When I Save-As-PDF, I get 50 *blank* pages. A single pie chart seems to print, i.e. dumpEthn[\Iran\]. I reported this to WRI support. Can anyone suggest any other work-around on this? In the excitement about W|A, I wanted to show this to someone. TIA and I am running 7.0.1/XPSP3. Roger Williams Franklin Laboratory http://www.meetup.com/The-San-Francisco-Math-Meetup-Group/ === Subject: Re: TIFF file specification the new command is ImageData[Import[\imagefile\, \TIFF\]] The old version returned an Graphics[Raster[bitmapdata,__],__] the new version return Image[bitmapdata,___] Jens > extract parts of bitmap tiff images (lines representing the horizon in > fisheye photos of the sky). I used to open the bitmap array (i.e. an > R x C list, where R is the pixel height of the image and C its pixel > width) with the command: > > Import[\imagefile\, \TIFF\][[1,1]]; > > I recently tried to use my program in Mathematica 7.0 and it seems the > TIFF format that Mathematica is expecting has changed. I now have to > import element [[1]] of the file, not element [[1,1]]. i.e. the new > command to extract the array is: > > Import[\imagefile\, \TIFF\][[1]]; > > This is not a big problem, but I cannot find when Wolfram changed the > format that Mathematica expects to see for a TIFF file, and whether > anything else in the specification changed. Can anyone point me at > Mathematica documentation on this change? I want to be sure that > nothing else changed (e.g. is Mathematica still reading the array from > bottom left to top right of the image, etc). > > > John Stone > Earth & Space Sciences, University of Washington; stone(at)geology. > (washington).(edu) > === Subject: Indexed Slot in a Rule - How to do it?? Here's the problem. Convert a vector (list) with symbol names into indexed slots. I'm doing this so that I can turn the vector into function that takes a list. Here's an example of the desired behavior: eqs = {0, 5*x1, 1, 10*x3, 3*x2}; convert this to: indexedeqs = {0, 5*#[[1]], 1, 10*#[[3]], 3*#[[2]]}; T[q_]:=indexedeqs; T[{1,2,3}] = {0,5,1,30,6} I can't for the life of me figure out how to do this. I've been performing meta-Mathematica all week. Here's the closest I've come: xvars={x1,x2,x3}; MapIndexed[Rule[#1, #[[First@#2]]] &, xvars] But, this treats the second # literally, and puts in the current item from xvars. I need a way for the second # to just be # without it really taking a value. So, I tried doing it as a string: xvars={x1,x2,x3}; MapIndexed[Rule[#1, \#[[\ <> ToString[First@#2] <> \]]\] &, xvars] And this creates a rule that looks correct, but, its right hand side of the rule is a string instead of an expression. I can't figure this out!!! Any help is greatly appreciated. All the best, Alan === Subject: Re: InverseLaplaceTransform Looks like a bug to me. For all u except -1 M[u] simplifies to 1 so the output should be DiracDelta[t] not 1/(E^t*2) > OK, I give up on this one. Can anybody explain me the reason for these > two different outputs? > > > Andrea > > In[304] psi[u_] := LaplaceTransform[Exp[-t], t, u] > M[u_] := u*psi[u]/(1 - psi[u]) > InverseLaplaceTransform[M[u], u, t] > InverseLaplaceTransform[FullSimplify[M[u]], u, t] > > Out[306] 1/(E^t*2) > Out[307] DiracDelta[t] === Subject: treatment on C[i] Hi mathematica community, C[i] is the default form for the i th parameter or constant generated by mathematica in representing the results of various symbolic computations in such functions as DSolve, RSolve and Reduce. My question is: is it possible to know in advance how many C[i] will be generated? If not how to represent the generic form of them: For example I have an input with reduce and mathematica generates in the output C[1],C [2],C[3] and C[4] so four C[i] in the solutions but before that when I need to use something in the input that represent C[i] in general without knowing how many of them will be generated? I have tried to use the pattern object _ like that C[ _ ] but it does not work. Any suggestion? === Subject: Re: Bug in analytical sum > Consider the following sum > > f[k_] := Sum[n! (-I \\[Alpha])^n Cos[\\[Phi]/2]^n \\[Alpha]^n \ Sin[\\[Phi]/ > 2]^n, {n, > 0, k}]/Sum[n! \\[Alpha]^(2 n) Cos[\\[Phi]/2]^(2 n), {n, 0, k}] > > I am interested in taking alpha and k to infinity. Now clearly for > finite k this is just a rational function in alpha. So if we want to > take alpha to infinity we should get > > (-i Tan[\\[Phi]/2])^k. > > But try this in Mathematica Limit[f[k], \\[Alpha] -> \\[Infinity]] and > you will get I Cot[\\[Phi]/2]. This is Mathematica 7.0.0. > > The reason seems to be that Mathematica evaluates the sum first and > obtains a fraction consisting of the incomplete gamma functions and Ei > integrals. It seems that the limits of those functions are not taken > properly. Offhand I do not know what is the correct result. But I can say that Limit will have trouble managing branch cuts, if not given suitable assumptions (and it may have trouble anyway...). So you might instead do: In[18]:= Limit[f[k], \\[Alpha] -> Infinity, Assumptions -> {k > 0, Element[\\[Phi], Reals]}] Out[18]= (-(1/2))^k/(Cos[\\[Phi]/2]^(2*k)*((-I)*Csc[\\[Phi]])^k) Daniel Lichtblau Wolfram Research === Subject: Bug in analytical sum Consider the following sum f[k_] := Sum[n! (-I \\[Alpha])^n Cos[\\[Phi]/2]^n \\[Alpha]^n Sin[\\[Phi]/ 2]^n, {n, 0, k}]/Sum[n! \\[Alpha]^(2 n) Cos[\\[Phi]/2]^(2 n), {n, 0, k}] I am interested in taking alpha and k to infinity. Now clearly for finite k this is just a rational function in alpha. So if we want to take alpha to infinity we should get (-i Tan[\\[Phi]/2])^k. But try this in Mathematica Limit[f[k], \\[Alpha] -> \\[Infinity]] and you will get I Cot[\\[Phi]/2]. This is Mathematica 7.0.0. The reason seems to be that Mathematica evaluates the sum first and obtains a fraction consisting of the incomplete gamma functions and Ei integrals. It seems that the limits of those functions are not taken properly. === Subject: Re: Image[], Graphics[Raster[]] You can use Image, ImageData and ArrayPlot, with a little manipulation, to meld images into regular graphics. With Presentations it is easy to combine images and graphics. Example: Needs[\Presentations`Master`\] imag1 = Image[Import[\ExampleData/lena.tif\], \Real\]; Draw2D[ {ArrayDraw[Map[RGBColor, ImageData[imag1, \Real\], {2}], DataRange -> {{0, 2 \\[Pi]}, {-1, 1}}], Draw[Sin[x], {x, 0, 2 \\[Pi]}], White, Text[Style[\Lena and a Sine Wave\, 16], {2, -.8}]}, AspectRatio -> .8, Frame -> True, ImageSize -> 300] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm taking a look at the new V7 Image[] command, and I'm left a bit confused. 1. Is Image[] any different than Graphics[Raster[]] that I'm more accustomed to? 2. If not, what was the point of introducing Image[]? Was it any effort to provide a more streamlined set of commands all revolving around Image[], e.g., ImageRotate[], etc.? 3. Image[] somehow upsets my unified view of Mathematica. That is, I like to try to \think\ like Mathematica, and so I understand that all commands \ like Plot[], ListPlot[], etc., reduce to a Graphics[] object in FullForm[]. Similarly, I can build my own type of plotting function with Graphics[]. Most importantly, I can combine many different types of objects into a single Graphics[]. Am I correct that Image[] represents then a completely new display object? If so, is there a way, for example, to have an Image[] and then draw across it with an Epilog rule like you can do with Graphics[]? It seems a major setback if Image[] and Graphics[] cannot be readily mixed. Anyone out there to make the case that Image[] represents an important new capability? I see it as a little worse than the usual \new command that does same thing old stuff did\ because it seems to lose the capability to mix Graphics[] and Image[]. Please inform me if I'm completely off base. As I said, I'm just digging into Image[] now for the first time, and I'm a bit confused about possible merits---please do inform! === Subject: Image[], Graphics[Raster[]] I'm taking a look at the new V7 Image[] command, and I'm left a bit confused. 1. Is Image[] any different than Graphics[Raster[]] that I'm more accustomed to? 2. If not, what was the point of introducing Image[]? Was it any effort to provide a more streamlined set of commands all revolving around Image[], e.g., ImageRotate[], etc.? 3. Image[] somehow upsets my unified view of Mathematica. That is, I like to try to \think\ like Mathematica, and so I understand that all commands \ like Plot[], ListPlot[], etc., reduce to a Graphics[] object in FullForm[]. Similarly, I can build my own type of plotting function with Graphics[]. Most importantly, I can combine many different types of objects into a single Graphics[]. Am I correct that Image[] represents then a completely new display object? If so, is there a way, for example, to have an Image[] and then draw across it with an Epilog rule like you can do with Graphics[]? It seems a major setback if Image[] and Graphics[] cannot be readily mixed. Anyone out there to make the case that Image[] represents an important new capability? I see it as a little worse than the usual \new command that does same thing old stuff did\ because it seems to lose the capability to mix Graphics[] and Image[]. Please inform me if I'm completely off base. As I said, I'm just digging into Image[] now for the first time, and I'm a bit confused about possible merits---please do inform! === Subject: Re: Image[], Graphics[Raster[]] > > 1. Is Image[] any different than Graphics[Raster[]] that I'm more > accustomed to? No it has a fixed data range, i.e., \Byte\ is [0,255], \Real\ [0,1] while Graphics[Raster[]] can handle undestructive every thing. > > 2. If not, what was the point of introducing Image[]? Was it any effort to \ > provide a more streamlined set of commands all revolving around Image[], > e.g., ImageRotate[], etc.? The reason was a faster display of the bitmap. With fixed data range the FE don't have to do a scaling of every pixel. > > > 3. Image[] somehow upsets my unified view of Mathematica. That is, I like \ > to try to \think\ like Mathematica, and so I understand that all \ commands > like Plot[], ListPlot[], etc., reduce to a Graphics[] object in > FullForm[]. Similarly, I can build my own type of plotting function with > Graphics[]. Most importantly, I can combine many different types of > objects into a single Graphics[]. Am I correct that Image[] represents > then a completely new display object? If so, is there a way, for example, \ > to have an Image[] and then draw across it with an Epilog rule like you > can do with Graphics[]? It seems a major setback if Image[] and Graphics[] \ > cannot be readily mixed. > Oh mixing is easy: img = Import[\http://www.stephenwolfram.com/img/home/sw-portrait.jpg\] Graphics[ {Image`ToGraphicsRaster[img][[1]], Circle[{110.5, 110.5}, 10]}] draw a circle on the image. > Anyone out there to make the case that Image[] represents an important new \ > capability? No, it make many things more complicated, and a lot of image processing tasks impossible -- registration for example .. I see it as a little worse than the usual \new command that > does same thing old stuff did\ because it seems to lose the capability to \ > mix Graphics[] and Image[]. > > Please inform me if I'm completely off base. As I said, I'm just digging > into Image[] now for the first time, and I'm a bit confused about possible \ > merits---please do inform! There is no merit, it make many things worse than the original Graphics[Raster[]] Jens === Subject: Stopping NDSolve after a condition is met x times I am trying to stop integrating the equations of motion of a simple pendulum \ after the bob has crossed the vertical a certain number of times. This is \ the code I have so far. \k\ counts the number of times the bob crosses the \ vertical. EOM = x''[t] + 9.8 Sin[x[t]]; x1ic = Pi/2; x1pic = 0; k = {0}; NDSolve[{EOM == 0, x[0] == x1ic, x'[0] == x1pic}, {x}, {t, 0, 10}, Method -> \ {EventLocator, \Event\ -> {x[t],First[k] - 5}, EventAction :> {k == k++; \ Print[k],Throw[t1 = t; xt1 = x[t]; xpt1 = x'[t];,StopIntegration\]}}] === Subject: MatrixForm affects values instead of only printing ????? Here is the example: test1={-3, 7, 5} test1[[3]] returns the list and 5 as expected; test2={-3, 7, 5}//MatrixForm test2[[3]] returns a column vector and error: \part 3 of blah blah doesn't exist\. \ The actual list itself is test2[[1]]. To get the right 3rd element I have to \ do: test2[[1,3]] which returns 5 as expected. The problem is MatrixForm is NOT supposed to change the expression it is \ applied on according to the manual. Is that a bug or there's logical \ explanation? === Subject: Re: Install problem of Mathematica kernel The Mathematica is running on WinXP, and there is no error record in system \ logs. When I installed Version 7.0 ,I have deleted the file in folder of \ \\\Application Data\\Mathematica\\Licensing\ of previous version. After \ installed, the \*.nb\ files can be opened by Mathematica ,even the \ animations can be activated, and Mathkernel can be running and executed \ command separately, but if the command is runned in Mathematica notebook, it \ will prompt a dialog box saying \Mathematica could not establish a \ connection to the kernel\.How could I overcome the problem ? === Subject: Reading Fortran Data file Have data fortran data file with numbers like 0.447562485933D-01. I need all the digits, but mathematica seems to only read this as 0.0448062. I can read it as a string and get \0.448062494397D-01\ but when I use ToExpression, I get -1 + 0.448062 D So how can I read in all the digits. === Subject: problem Hi I'm having trouble solving this set of equations: y''[x] =-y[x]*((y[x])^2 + (z[x])^2)^0.5 z''[x] =-z[x]*((y[x])^2 + (z[x])^2)^0.5 NDSolve[{y''[x] == -y[x]*((y[x])^2 + (z[x])^2)^0.5, z''[x] == -z[x]*((y[x])^2 + (z[x])^2)^0.5, y'[0] == 0.5, z[0] == 1, y[0] == 1, z'[0] == 0.5}, {y, z}, {x, -100, 100}] I can plot this answer but what I really need is the parametric solution(a \ set of equations for z and y depending on x). Please help me find the answer. thanx parmida === Subject: Re: volume calculation works great! Filippo > > I would just use NIntegrate[Boole[D(x1,x2,x3,...,xn) < L],{whatever > your > limits in xi}]. possibly with a Monte-Carlo method. If integration > limits in > coordinates depend on other coordinates in a way that is hard to > disentangle, I would find the minimal multidimensional \box\ with > fixed > dimensions that contains your domain, and integrate over that box. > > Leonid > > > >> I need a way to find the volume of a multidimensional shape in the >> coordinates (x1,x2,x3,...,xn), that comes from an inequality like >> D(x1,x2,x3,...,xn) < L (with 3 variables i get a nice weird shape in >> R^3, with more i don't plot it) >> In other words I let Mathematica calculate where in the space of the >> solutions the inequality is solved and i'd like to have the numerical >> \volume of the solutions\. >> What strategy should i use? The function D is not invertible... >> Filippo >> >> >> >> ------------------------------------------------------------ >> Mobile (IT): +39 340 6104269 >> Mobile (NL): +31 064 3949827 >> Home (IT): +39 0438 59360 >> >> P.O. Box 9504 >> NL 2300 RA LEIDEN >> >> msn: dr.ziofil@hotmail.com >> skype: filippo.miatto >> Quantum Optics >> Group Mail: miatto@molphys.leidenuniv.nl >> ------------------------------------------------------------ Mobile (IT): +39 340 6104269 Mobile (NL): +31 064 3949827 Home (IT): +39 0438 59360 P.O. Box 9504 NL 2300 RA LEIDEN msn: dr.ziofil@hotmail.com skype: filippo.miatto Quantum Optics Group Mail: miatto@molphys.leidenuniv.nl === Subject: Re: volume calculation > I need a way to find the volume of a multidimensional shape in the > coordinates (x1,x2,x3,...,xn), that comes from an inequality like > D(x1,x2,x3,...,xn) < L (with 3 variables i get a nice weird shape in > R^3, with more i don't plot it) > In other words I let Mathematica calculate where in the space of the > solutions the inequality is solved and i'd like to have the numerical > \volume of the solutions\. > What strategy should i use? The function D is not invertible... > Filippo > > ------------------------------------------------------------ > Mobile (IT): +39 340 6104269 > Mobile (NL): +31 064 3949827 > Home (IT): +39 0438 59360 > > P.O. Box 9504 > NL 2300 RA LEIDEN > > msn: dr.zio...@hotmail.com > skype: filippo.miatto > Quantum Optics > Group Mail: mia...@molphys.leidenuniv.nl Try Monte Carlo integration, that's probably the easiest way to do high dimensional integrals. Of course this will only work if you are happy with a numerical result. === Subject: Re: volume calculation Use : Integrate[ Boole[D(x1,x2,x3,...,xn) < L ], {x1,x1min,x1max} ...{xn,xnMin,xnMax} ] Try also: - NIntegrate instead of Integrate - Infinity (-Infinity) instead max boundaries (min boundaries) it works fine symbolically and numericaly gvn74b$ets$1@smc.vnet.net... > I need a way to find the volume of a multidimensional shape in the > coordinates (x1,x2,x3,...,xn), that comes from an inequality like > D(x1,x2,x3,...,xn) < L (with 3 variables i get a nice weird shape in > R^3, with more i don't plot it) > In other words I let Mathematica calculate where in the space of the > solutions the inequality is solved and i'd like to have the numerical > \volume of the solutions\. > What strategy should i use? The function D is not invertible... > Filippo > > > > ------------------------------------------------------------ > Mobile (IT): +39 340 6104269 > Mobile (NL): +31 064 3949827 > Home (IT): +39 0438 59360 > > P.O. Box 9504 > NL 2300 RA LEIDEN > > msn: dr.ziofil@hotmail.com > skype: filippo.miatto > Quantum Optics > Group Mail: miatto@molphys.leidenuniv.nl > === Subject: Re: volume calculation I would just use NIntegrate[Boole[D(x1,x2,x3,...,xn) < L],{whatever your limits in xi}]. possibly with a Monte-Carlo method. If integration limits \ in coordinates depend on other coordinates in a way that is hard to disentangle, I would find the minimal multidimensional \box\ with fixed dimensions that contains your domain, and integrate over that box. Leonid > I need a way to find the volume of a multidimensional shape in the > coordinates (x1,x2,x3,...,xn), that comes from an inequality like > D(x1,x2,x3,...,xn) < L (with 3 variables i get a nice weird shape in > R^3, with more i don't plot it) > In other words I let Mathematica calculate where in the space of the > solutions the inequality is solved and i'd like to have the numerical > \volume of the solutions\. > What strategy should i use? The function D is not invertible... > Filippo > > > > ------------------------------------------------------------ > Mobile (IT): +39 340 6104269 > Mobile (NL): +31 064 3949827 > Home (IT): +39 0438 59360 > > P.O. Box 9504 > NL 2300 RA LEIDEN > > msn: dr.ziofil@hotmail.com > skype: filippo.miatto > Quantum Optics > Group Mail: miatto@molphys.leidenuniv.nl > === Subject: comments on Wolfram Alpha input: arima output: Arima,Trinidad and Tobago Population: city population | 34997 people my comment: Nothing about ARIMA time series models, which comes up as the 3rd link on Google. input: garch output: Wolfram|Alpha isn't sure what to do with your input. * Did you mean:march my comment: nothing about GARCH time series models, widely used in finance input: united states budget deficit output: -$347 billion per year (US dollars per year) (2005 estimate) my comment: Users would want more recent data, such as the 2008 deficit and the estimated 2009 deficit. Wolfram Alpha appears much less useful than the combination of Google and Mathematica, so I wonder if resources are better spent adding functionality to Mathematica. === Subject: matching misspelled names I would like to compare 2 very large lists of names to identify a shortlist of possible matches where someone from the list A appears in the list B. However as English is not the local language, the most names have many spelling alternatives. Also in different contexts, the same person is referred to by the full name with one or more middle names and family names or just by a smaller combination of these. I imagine comparing lists with one or few typos is quite simple. But is there a way to do this in Mathematica which can also handle the type of variations I've outlined? I was thinking of arranging the names into clusters, isolating those clusters which include a list A person, and then generating lists of the closest matches for each cluster around a list A person. Is there a simple way to do this or a better way? Jess === Subject: Re: problem writing debugging utility function I use this function: peek = (Print[#1]; #1) & My programming style is to pipe functions: x//f1//f2//f3...//fn so sticking in a //peek is easy. Ken Levasseur http://homepage.mac.com/klevasseur/ > This matter is pretty unimportant, but perhaps of interest in laying > out a persistent source confusion for me with Mathematica: evaluation > control. > > I'm skeptical of the built-in debugger because it seems to crash the > kernel often, so I do most of my debugging by inserting print > statements like > > Print[\variableOne = \,variableOne]. > > Being extraordinarily lazy I soon thought it might be nice to have a > little function, say dbgv, which takes a variable or name of a > variable as an argument, and produces the same result as the print > statement above. > > At first I assumed this would be easy, since almost every programming > problem turns out to be pretty easy with Mathematica. But after an > hour > or so I began to wonder whether it would be possible at all. I did > eventually find a solution, a function dbgv such that > dbgv[variableOne] > produces exactly the effect of the print statement, but it's really > ugly. > I'll post it later. > > Granted this is not an important problem since it's not too much > trouble to just type in the whole print statement. But it's worth > noting that this would trivial to solve with a Lisp macro, and despite > the fantastic expressibility of Mathematica it doesn't seem to have a > good replacement for macros. The closest equivalents are $Pre(Read), > which I used in my solution, but they're not nearly as nice to work > with. > > Can anyone think of an elegant solution? > === Subject: Re: problem writing debugging utility function the way to do it is to use non-standard evaluation. Here is the function that probably does what you want In[1] = SetAttributes[ShowIt, HoldAll]; ShowIt[code_] := Module[{y}, Print[ToString[Unevaluated[code]], \ = \, y = code]; y]; This will print the variable name, its value, and then return the variable value itself so that you can use it in your code, just as before - you just need to \stick\ ShowIt in the place where you need to print the info. \ The parameter of the function does not necessarily have to be a variable - you can wrap it around any piece of code (there could be a few subtleties if your code also uses non-standard evaluation, but this is rarely the case). Note that we take care that the code () is executed only once, so the case of side effects (like i++ etc) is handled correctly. Example: In[2] = Block[{i, res = Table[0, {5}]}, For[i = 1, i <= 5, i++, res[[i]] = ShowIt[i]]; res] i = 1 i = 2 i = 3 i = 4 i = 5 Out[2] = {1,2,3,4,5} >But it's worth >noting that this would trivial to solve with a Lisp macro, and despite >the fantastic expressibility of Mathematica it doesn't seem to have a >good replacement for macros. This is just not true. The ShowIt function above *is* a macro, since, due \ to the HoldAll attribute, it expands the code before it is run. As another \ very simple macro example, consider this: ClearAll[withCodeAfter]; SetAttributes[withCodeAfter,HoldRest]; withCodeAfter[before_,after_]:=(after;before); This macro can be used to avoid an introduciton of auxilliary variable in case when the result is computed somewhere in the middle of the code (by the piece), but when some other code must be executed ( piece), before the result is returned. Example: In[3] = Clear[i]; i = 0; withCodeAfter[Print[i], i++] 0 In[4] = i Out[4] = 1 The availability of macros in Mathematica is apparent from the fact that \ all the code we write is data as well (as can be seen by the FullForm command), and the availability of non-standard evaluation. This fact is obscured by the built-in pretty-printer/preprocessor which allows us to use shortcut \ and infix notation. However indeed there are a few reasons that make macros harder to write in Mathematica: a) Evaluator is more complex, than in Lisp. There are several kinds of global rules, there are attributes, there are several ways to make evaluation non-standard, there are built-in rules for system functions that the user may not be aware of, there is dynamic scoping with Block that is very powerful but can be easily abused, there are several lexical scoping constructs (Module, With, Function, SetDelayed, etc) and associated with them rules for variable collision resolution, etc, etc. It is harder to \compute\ the consequences of the macro expansion, or to get it right in \ all cases of intended use. b) Pattern-matching gets in the way when some portion of the code is rule-based, since evaluation depends on whether or not some patterns match. c) This is a consequence of b): when we define a function with restricted patterns such as f[x_Integer]:=... etc, we effectively introduce a (weak) typing, which also gets in the way. d) It requires conscious effort not to use (at all) short-hand and/or infix notation, which is handy but often hides that the code may expressed as an expansion of some macro. I think it will generally be very nice if macros would find their way into the mainstream Mathematica programming, but this will probably start to really pay off for those who intend to use Mathematica to build rather large/complex systems (or their prototypes). Leonid > This matter is pretty unimportant, but perhaps of interest in laying > out a persistent source confusion for me with Mathematica: evaluation > control. > > I'm skeptical of the built-in debugger because it seems to crash the > kernel often, so I do most of my debugging by inserting print > statements like > > Print[\variableOne = \,variableOne]. > > Being extraordinarily lazy I soon thought it might be nice to have a > little function, say dbgv, which takes a variable or name of a > variable as an argument, and produces the same result as the print > statement above. > > At first I assumed this would be easy, since almost every programming > problem turns out to be pretty easy with Mathematica. But after an hour > or so I began to wonder whether it would be possible at all. I did > eventually find a solution, a function dbgv such that dbgv[variableOne] > produces exactly the effect of the print statement, but it's really ugly. > I'll post it later. > > Granted this is not an important problem since it's not too much > trouble to just type in the whole print statement. But it's worth > noting that this would trivial to solve with a Lisp macro, and despite > the fantastic expressibility of Mathematica it doesn't seem to have a > good replacement for macros. The closest equivalents are $Pre(Read), > which I used in my solution, but they're not nearly as nice to work with. > > Can anyone think of an elegant solution? > > === Subject: problem writing debugging utility function This matter is pretty unimportant, but perhaps of interest in laying out a persistent source confusion for me with Mathematica: evaluation control. I'm skeptical of the built-in debugger because it seems to crash the kernel often, so I do most of my debugging by inserting print statements like Print[\variableOne = \,variableOne]. Being extraordinarily lazy I soon thought it might be nice to have a little function, say dbgv, which takes a variable or name of a variable as an argument, and produces the same result as the print statement above. At first I assumed this would be easy, since almost every programming problem turns out to be pretty easy with Mathematica. But after an hour or so I began to wonder whether it would be possible at all. I did eventually find a solution, a function dbgv such that dbgv[variableOne] produces exactly the effect of the print statement, but it's really ugly. I'll post it later. Granted this is not an important problem since it's not too much trouble to just type in the whole print statement. But it's worth noting that this would trivial to solve with a Lisp macro, and despite the fantastic expressibility of Mathematica it doesn't seem to have a good replacement for macros. The closest equivalents are $Pre(Read), which I used in my solution, but they're not nearly as nice to work with. Can anyone think of an elegant solution? === Subject: Re: problem writing debugging utility function liked Leonid's the best, being both much simpler and more general than mine. SetAttributes[ShowIt, HoldAll]; ShowIt[code_] := Module[{y}, Print[ToString[Unevaluated[code]], \ = \, y = code]; y]; My own solution was the hideous $PreRead=ReplaceAll[#,{{\dbgv\,\[\,var_,\]\}:>{\Print\,\[\,RowBox [{\\\\\<>var<>\ = \<>\\\\\,\,\,var}],\]\}}]&; which makes dbgv work like a macro. The grotesqueness is because what $PreRead sees is a very raw input form, with expressions broken down into RowBox's. In a sense this is the most direct analog to Lisp's macros, but ... yechh. The Unevaluated[] function had slipped off my radar, probably because I never fully grokked the distinction between it and Hold[]. In fact I'm still a bit confused about it. At first I thought it might like the evaluation inhibitor ` in Lisp, but some examples disabused me of that. In[2]:= f@Unevaluated[5 + 6 + 7 + 8] Out[2]= f[Unevaluated[5 + 6 + 7 + 8]] In[11]:= ToString@Unevaluated[5 + 6 + 7 + 8] Out[11]= \5 + 6 + 7 + 8\ I might have expected Out[11]= \Unevaluated[5 + 6 + 7 + 8]\ In[13]:= sqr[x_] := x^2 In[14]:= sqr@Unevaluated[5 + 6 + 7 + 8] Out[14]= 676 I might have expected Out[14]= sqr[5 + 6 + 7 + 8] since sqr does not know what to do with the pattern _+_+_+_ or _+_ for that matter. Could anyone elucidate this for me? === Subject: Re: problem writing debugging utility function SetAttributes[printVariable, HoldAll]; printVariable[var_] := Print[ToString[HoldForm[var]] <> \ = \ <> ToString[var]] ape = 1; printVariable[ape] Out: ape = 1 On May 30, 2:57 am, \dabro...@indiana.edu\ > This matter is pretty unimportant, but perhaps of interest in laying > out a persistent source confusion for me with Mathematica: evaluation > control. > > I'm skeptical of the built-in debugger because it seems to crash the > kernel often, so I do most of my debugging by inserting print > statements like > > Print[\variableOne = \,variableOne]. > > Being extraordinarily lazy I soon thought it might be nice to have a > little function, say dbgv, which takes a variable or name of a > variable as an argument, and produces the same result as the print > statement above. > > At first I assumed this would be easy, since almost every programming > problem turns out to be pretty easy with Mathematica. But after an hou= r > or so I began to wonder whether it would be possible at all. I did > eventually find a solution, a function dbgv such that dbgv[variableOne] > produces exactly the effect of the print statement, but it's really ugly. > I'll post it later. > > Granted this is not an important problem since it's not too much > trouble to just type in the whole print statement. But it's worth > noting that this would trivial to solve with a Lisp macro, and despite > the fantastic expressibility of Mathematica it doesn't seem to have a > good replacement for macros. The closest equivalents are $Pre(Read), > which I used in my solution, but they're not nearly as nice to work with. > > Can anyone think of an elegant solution? === Subject: Re: problem writing debugging utility function SetAttributes[printVariable,HoldAll] printVariable[var_]:=Print[ToString[Unevaluated[var]],\ = \,var] ? Jens > This matter is pretty unimportant, but perhaps of interest in laying > out a persistent source confusion for me with Mathematica: evaluation > control. > > I'm skeptical of the built-in debugger because it seems to crash the > kernel often, so I do most of my debugging by inserting print > statements like > > Print[\variableOne = \,variableOne]. > > Being extraordinarily lazy I soon thought it might be nice to have a > little function, say dbgv, which takes a variable or name of a > variable as an argument, and produces the same result as the print > statement above. > > At first I assumed this would be easy, since almost every programming > problem turns out to be pretty easy with Mathematica. But after an hour > or so I began to wonder whether it would be possible at all. I did > eventually find a solution, a function dbgv such that dbgv[variableOne] > produces exactly the effect of the print statement, but it's really ugly. > I'll post it later. > > Granted this is not an important problem since it's not too much > trouble to just type in the whole print statement. But it's worth > noting that this would trivial to solve with a Lisp macro, and despite > the fantastic expressibility of Mathematica it doesn't seem to have a > good replacement for macros. The closest equivalents are $Pre(Read), > which I used in my solution, but they're not nearly as nice to work with. > > Can anyone think of an elegant solution? > === Subject: Re: problem writing debugging utility function > This matter is pretty unimportant, but perhaps of interest in laying > out a persistent source confusion for me with Mathematica: evaluation > control. > > I'm skeptical of the built-in debugger because it seems to crash the > kernel often, so I do most of my debugging by inserting print > statements like > > Print[\variableOne = \,variableOne]. > > Being extraordinarily lazy I soon thought it might be nice to have a > little function, say dbgv, which takes a variable or name of a > variable as an argument, and produces the same result as the print > statement above. > > At first I assumed this would be easy, since almost every programming > problem turns out to be pretty easy with Mathematica. But after an hour > or so I began to wonder whether it would be possible at all. I did > eventually find a solution, a function dbgv such that dbgv[variableOne] > produces exactly the effect of the print statement, but it's really ugly. > I'll post it later. > > Granted this is not an important problem since it's not too much > trouble to just type in the whole print statement. But it's worth > noting that this would trivial to solve with a Lisp macro, and despite > the fantastic expressibility of Mathematica it doesn't seem to have a > good replacement for macros. The closest equivalents are $Pre(Read), > which I used in my solution, but they're not nearly as nice to work with. > > Can anyone think of an elegant solution? > For a function that works like the Print expression above, one could use one of the following: Non-string version: SetAttributes[dbg, HoldAll] dbg[var_] := Print[ToString[Unevaluated[var]], \ = \, var] String version: dbg2[name_String] := ToExpression[name, InputForm, Print[name, \ = \, #] &] Though I am not sure I understand your question because I don't see what relation $Pre or Read have with this. For debugging, take a look at Trace, On[] and Off[], and Monitor as well. === Subject: Re: How can I get the previous Fibonacci calculated prevFib[x_] := Module[{m, n, x2}, x2 = SetPrecision[x, 100]; If[x > 10^15, N[x/GoldenRatio], m = (n /. FindRoot[Fibonacci[n] - x2 == 0, {n, 100}, WorkingPrecision -> 100]) - 1; If[Abs[m - Round[m]] < 10^-10, Fibonacci[Round[m]], N[Fibonacci[m]]]]] prevFib[13] 8 prevFib[Fibonacci[50]] == Fibonacci[49] True prevFib[Fibonacci[10000]] == Fibonacci[9999] True prevFib[Fibonacci[20000]] == Fibonacci[19999] True prevFib[234.34*^10] 1.4483008492365037*^12 Bob Hanlon How can I get a previous Fibonacci calculated number in a specific range. I can calculate the previous number of phi see below phi1 =(1+sqrt(5))/2 13/phi1 I tested it with 13 and got 8.034441857 .....so that works but how can I get only the previous numbers of Fibonacci in a specified range from 20 to 20000 if I input a large number like 234.34e10 tia sal2 === Subject: Re: Tube in ParametricPlot3D with too many details > > I'm using the following code to get a tube around a homoclinic loop > > hloop = ParametricPlot3D[{-2 Sech[ u], u - 2 Tanh[ u], 0 }, {u, -5, > 5}, PlotStyle -> {Tube[0.1], Red}, Axes -> None] > > The only issue is that, if I try to export it as a pdf, I get too many > details which results in (too) big pdf. > > Is there anyway to have Mathematica producing a plot with less > > Giovanni Lanzani > This problem came up with version 6 for graphics rendered using GraphicsComplex. It has been discussed in this group. The best solution is to use File->PrintSelection. In the printer menu chose \save\ to print to a pdf. The drawback is, the picture takes a whole page, so you have to open it in a graphics program like GraphicsConverter (on Mac) to adjust the region. -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: How to handle Units of Measure May I ask you how you would enter such a calculation on a simple calculator? You only use the numbers, taking care that they're based on comparable units (so not to add grams and kilograms etc.). In Mathematica you do the same. If you want to do unit conversions there is the Units package that you read in using Needs[\Units`\] In this package the function Convert will do unit conversions. > In this very simple example if I write > R+iwL > where R is measured in Ohms, w in s^-1, L in H, I expect that the > result is given in Ohms. > Why it doesn't happen in Mathematica ? Ho can I do to handle in a > simple way those conversions ? === Subject: Install problem of Mathematica kernel === Subject: Re: NDSolve with Numeric Function Hi Hugh, I have rewritten your code a bit. You can write the function RHS with vector notation, then your problems disappear. ClearAll[RHS]; RHS[x_, y_, f_] := Module[{}, -{{1, 2, 3, 5}, {3, 2, 1, 2}, {5, 7, 1, 1}, {3, 2, 4, 5}}.x + 3 y ] sol = NDSolve[{x''[t] == RHS[x[t], x'[t], 1], x[0] == {-1, 0, 1, 0}, x'[0] == {0, 0, 0, 0}}, x, {t, 0, 2} ] Neverthelesse, there is something fishy. The second case should actually work. However: MatchQ[#1, x_ /; NumericQ[ x[[1]] ]] returns True. Maybe you want to report this to Wolfram. Daniel > Please could someone explain why my NDSolve examples below don't work? > In the first case I think it fails because NDSolve attempts to > evaluate the function RHS symbolically. > The second case should remain unevaluated and signal to NDSolve to go > numerical but this fails why? > In the third case a similar check to the second works. Why? > > Hugh Goyder > > ClearAll[RHS]; > RHS[x_, v_, f_] := Module[{x1, y1, x2, y2, x1v, y1v, x2v, y2v}, > {x1, y1, x2, y2} = x; > {x1v, y1v, x2v, y2v} = v; > -{{1, 2, 3, 5}, {3, 2, 1, 2}, {5, 7, 1, 1}, {3, 2, 4, 5}}.{x1, y1, > x2, y2} + 3 {x1v, y1v, x2v, y2v} > ] > > sol = NDSolve[{x''[t] == RHS[x[t], x'[t], 1], x[0] == {-1, 0, 1, 0}, > x'[0] == {0, 0, 0, 0}}, x, {t, 0, 2}] > > ClearAll[RHS]; > RHS[x_ /; NumericQ[x[[1]]], v_, f_] := > Module[{x1, y1, x2, y2, x1v, y1v, x2v, y2v}, > {x1, y1, x2, y2} = x; > {x1v, y1v, x2v, y2v} = v; > -{{1, 2, 3, 5}, {3, 2, 1, 2}, {5, 7, 1, 1}, {3, 2, 4, 5}}.{x1, y1, > x2, y2} + 3 {x1v, y1v, x2v, y2v} > ] > > sol = NDSolve[{x''[t] == RHS[x[t], x'[t], 1], x[0] == {-1, 0, 1, 0}, > x'[0] == {0, 0, 0, 0}}, x, {t, 0, 2}] > > ClearAll[RHS]; > RHS[x_ /; Head[x] == List, v_, f_] := > Module[{x1, y1, x2, y2, x1v, y1v, x2v, y2v}, > {x1, y1, x2, y2} = x; > {x1v, y1v, x2v, y2v} = v; > -{{1, 2, 3, 5}, {3, 2, 1, 2}, {5, 7, 1, 1}, {3, 2, 4, 5}}.{x1, y1, > x2, y2} + 3 {x1v, y1v, x2v, y2v} > ] > > sol = NDSolve[{x''[t] == RHS[x[t], x'[t], 1], x[0] == {-1, 0, 1, 0}, > x'[0] == {0, 0, 0, 0}}, x, {t, 0, 2}] > === Subject: Re: Parallel processing > > I am running version 7.01 on a quad core CPU. I am doing some heavy > calculations but was too lazy to use any special commands for > parallelization. > > However, to my surprise, when I check the performance I see that all 4 > kernels a busy calculating. > > Does anybody have any info about this automatic parallelization of > Mathematica? > > Daniel > > > Prior to 7.0 there was talk that certain cpu-intensive algorithms would make use of multiple cores where appropriate - presumable they still do. Where does your program spend its time? David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Parallel processing As far as I know, Mathematica does not paralellize unless you explicitedly tell it to. Did you see 4 Mathematica kernels running or just 4 cores being busy with unknown processes? > > I am running version 7.01 on a quad core CPU. I am doing some heavy > calculations but was too lazy to use any special commands for > parallelization. > > However, to my surprise, when I check the performance I see that all 4 > kernels a busy calculating. > > Does anybody have any info about this automatic parallelization of > Mathematica? > > Daniel === Subject: Re: new to group - Chemical Equation Jem, I will just add that the solution to chemical equilibrium equations involves a constrained matrix of log-linear combinations. Typically, the approach is a numerical solution, using on of the advanced minimization functions like a simplex algorithm (although I am not a mathematician so others on this site may have more developed opinions than mine of \forget analytical solutions and go for a numerical solution\). Simplex is available as the method \NelderMead\ of the NMinimize[] function. > Jem, > > I'm a chemist, and I have various thermodynamic and kinetic solvers. \ Here's > one that could do what you want. It's from April 1999, but it should still \ > work fine (though I haven't tested it): > > http://www.seas.harvard.edu/~smartin/surface complexation model.nb > > This program does more than you want, i.e., the equilibrium equations \ include > a term for adsorption to a surface. Nevertheless, maybe you'll find the > package helpful for your application. > > Best, Scot > > > [mailto:not.a.ninja25@gmail.com] > >> >> starting to realise the possibilities. >> >> I am trying to do a chemical speciation calculation. >> I have a set of simultaneous equations which represents the equilibria, >> mass >> balance, and charge balance in the system. >> >> I want to eliminate some of the variables, and then be able to solve for \ >> the >> remaining ones. >> My system of equations looks like this: >> a=b+c+d >> e=f+g+c+2d >> h=c/(bg) >> i=d/(cg) >> hi=d/(bg^2) >> j=mg/f >> k=lm >> n+m+b+c=g+l >> >> I will try to attach an image of what my formula looks like sofar. >> Basically, I can solve for the variable I want, but I am having trouble >> eliminating the ones I don't want (ie. I am getting an answer that is in >> terms of the wrong variables) >> >> I have been in the help files for ages, and don't really understand how \ to >> do this. >> I would really appreciate some pointers!! >> >> >> Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), >> i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, >> n + m + b + c == g + l}, {g}] >> >> >> >> >> > === Subject: Re: new to group - Chemical Equation Jem, I'm a chemist, and I have various thermodynamic and kinetic solvers. Here's one that could do what you want. It's from April 1999, but it should still work fine (though I haven't tested it): http://www.seas.harvard.edu/~smartin/surface complexation model.nb This program does more than you want, i.e., the equilibrium equations include a term for adsorption to a surface. Nevertheless, maybe you'll find the package helpful for your application. Best, Scot [mailto:not.a.ninja25@gmail.com] > > > starting to realise the possibilities. > > I am trying to do a chemical speciation calculation. > I have a set of simultaneous equations which represents the equilibria, \ mass > balance, and charge balance in the system. > > I want to eliminate some of the variables, and then be able to solve for \ the > remaining ones. > My system of equations looks like this: > a=b+c+d > e=f+g+c+2d > h=c/(bg) > i=d/(cg) > hi=d/(bg^2) > j=mg/f > k=lm > n+m+b+c=g+l > > I will try to attach an image of what my formula looks like sofar. > Basically, I can solve for the variable I want, but I am having trouble > eliminating the ones I don't want (ie. I am getting an answer that is in > terms of the wrong variables) > > I have been in the help files for ages, and don't really understand how \ to > do this. > I would really appreciate some pointers!! > > > Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), > i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, > n + m + b + c == g + l}, {g}] > > > > > === Subject: Re: Shade area between two polar curves Of course Cos[t] and 1/Sqrt[1+Tan[t]^2] do NOT have the same values over their entire domains, e.g., for Pi/2 < t < 3 Pi/2. So one must be careful if going from polar to cartesian coordinates in order to apply a RegionPlot for filling a PolarPlot. All of this begs the question as to why PolarPlot and ParametricPlot don't have a Filling option! > Hi Chee, > > try RegionPlot. Remember that Cos[t]=1/Sqrt[1+Tan[t]^2]: > > > f[x_, y_] := > > 1 + 2/Sqrt[1 + y^2/x^2] > Sqrt[x^2 + y^2] && Sqrt[x^2 + y^2] > 2 > > > > RegionPlot[f[x, y], {x, 0, 3}, {y, -2, 2}] > > > Daniel > > > > >> Hi All > > >> I have plotted two graphs using PolarPlot, namely the limacon r=1+2 \ cos(t) > >> and the circle r = 2 from t = 0 to t = 2 Pi. and I wish to shade the \ area > >> inside the limacon but outside the circle. Can anyone suggest a way to \ do > >> it? > > > >> Chee > > > > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Working with Indeterminate in large numerical lists simply try negation: Select[x, ! NumberQ[#] &] Daniel > Hi everyone, > I'm wondering about the optimal way to work with Indeterminate in > large matrices. I've been using this to replace \bad\ data points that > I want to prevent from polluting calculations involving lists of data, > but I'm not sure I'm working as smartly as I could be. > > As an example, suppose I have a list of machine-precision reals and > some Indeterminate elements: > > x = RandomSample[Join[RandomReal[1, 1000], ConstantArray > [Indeterminate, 10]]; > > If I want to take only the valid entries, the best I have been able to > find is something like: > > Select[x, NumberQ] > > This seems to work reasonably well. But if I want to specifically > select the Indeterminate entries, there doesn't seem to be any > function (equivalent to, say, \isnan\ from another system), so I have \ to > resort to something less succinct like > > > Does anyone have any suggestions on better ways to do this, or any > general tips for working with Indeterminate in this context? > > I'm particularly keen to do things in the most efficient way possible > as I'm working with rather large lists. > > Peter. > === Subject: Re: Working with Indeterminate in large numerical lists $HistoryLength = 0; n = 1000; x = RandomSample[Join[RandomReal[1, 100 n], ConstantArray[Indeterminate, n]]]; Timing[a1 = Select[x, ! NumberQ[#] &];] {0.096885,Null} However, note that NumberQ /@ {1, 1., Pi, E, I} {True,True,False,False,True} NumericQ /@ {1, 1., Pi, E, I} {True,True,True,True,True} So in most cases, you would want to use NumericQ rather than NumberQ Timing[a2 = Select[x, ! NumericQ[#] &];] {0.096093,Null} {0.069981,Null} Oddly, this is faster Timing[a4 = x[[Flatten[Position[x, Indeterminate]]]];] {0.016217,Null} Cases appears to be much more efficient than Select in this case Timing[a5 = Cases[x, Indeterminate];] {0.007767,Null} True However, for valid entries Timing[b1 = Select[x, NumericQ];] {0.035489,Null} Timing[b2 = Cases[x, _?NumericQ];] {0.064408,Null} True Bob Hanlon Hi everyone, I'm wondering about the optimal way to work with Indeterminate in large matrices. I've been using this to replace \bad\ data points that I want to prevent from polluting calculations involving lists of data, but I'm not sure I'm working as smartly as I could be. As an example, suppose I have a list of machine-precision reals and some Indeterminate elements: x = RandomSample[Join[RandomReal[1, 1000], ConstantArray [Indeterminate, 10]]; If I want to take only the valid entries, the best I have been able to find is something like: Select[x, NumberQ] This seems to work reasonably well. But if I want to specifically select the Indeterminate entries, there doesn't seem to be any function (equivalent to, say, \isnan\ from another system), so I have to resort to something less succinct like Does anyone have any suggestions on better ways to do this, or any general tips for working with Indeterminate in this context? I'm particularly keen to do things in the most efficient way possible as I'm working with rather large lists. Peter. === Subject: volume calculation I need a way to find the volume of a multidimensional shape in the coordinates (x1,x2,x3,...,xn), that comes from an inequality like D(x1,x2,x3,...,xn) < L (with 3 variables i get a nice weird shape in R^3, with more i don't plot it) In other words I let Mathematica calculate where in the space of the solutions the inequality is solved and i'd like to have the numerical \volume of the solutions\. What strategy should i use? The function D is not invertible... Filippo ------------------------------------------------------------ Mobile (IT): +39 340 6104269 Mobile (NL): +31 064 3949827 Home (IT): +39 0438 59360 P.O. Box 9504 NL 2300 RA LEIDEN msn: dr.ziofil@hotmail.com skype: filippo.miatto Quantum Optics Group Mail: miatto@molphys.leidenuniv.nl === Subject: Re: RandomReal gets stuck On May 31, 6:33 am, \Sjoerd C. de Vries\ > Hi Bas, > > I can confirm this bug. > > Executing an even simpler version, namely > > Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; > > will also set the random generator to a fixed starting point. The > number 31 is crucial, as lower values do not appear to cause the bug, > while higher values do. Changing Plus to Times appears to prevent the > bug. > > In[394]:= Table[ > Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; > RandomReal[], > {20} > ] > > During evaluation of In[394]:= Maximize::natt: The maximum is not > attained at any point satisfying the given constraints. >> > > Out[394]= {0.455719, 0.455719, 0.455719, 0.455719, 0.455719, \\ > 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, > \\ > 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, > \\ > 0.455719} > > This is very nasty, as a lot of people critically depend on random > functions to be random. I would urge you to report this to wolfram > support. > > > > > > For a simulation of a stochastic process I am making use of RandomReal. > > I noticed that at some point during the simulation the output of > > RandomReal[] becomes fixed. For some reason, totally beyond my > > comprehension, every time after I execute an optimization the > > RandomReal[] generates the same series of random numbers: > > > In[217]:= optimalactivity > > > Out[217]= {24, 336/25, 616/25, 32/5, 28/5, 76/25, 4, 8, 8, 4/5, 0, 0,= \\ > > 0, 0, 0, 4/5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\ > > 0, 0, 0, 0, 0, 12, 28, 80, 0, 104/3, 0, 234/125, 0, 0, 0, 0, 4, 0, 0, \ \\ > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} > > > In[218]:= RandomReal[] > > > Out[218]= 0.455719 > > > In[219]:= RandomReal[] > > > Out[219]= 0.977826 > > > In[220]:= RandomReal[] > > > Out[220]= 0.943215 > > > In[221]:= RandomReal[] > > > Out[221]= 0.962216 > > > In[222]:= RandomReal[] > > > Out[222]= 0.302348 > > > In[223]:= optimalactivity > > > Out[223]= {24, 336/25, 616/25, 32/5, 28/5, 76/25, 4, 8, 8, 4/5, 0, 0,= \\ > > 0, 0, 0, 4/5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\ > > 0, 0, 0, 0, 0, 12, 28, 80, 0, 104/3, 0, 234/125, 0, 0, 0, 0, 4, 0, 0, \ \\ > > 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} > > > In[224]:= RandomReal[] > > > Out[224]= 0.455719 > > > In[225]:= RandomReal[] > > > Out[225]= 0.977826 > > > In[226]:= RandomReal[] > > > Out[226]= 0.943215 > > > In[227]:= RandomReal[] > > > Out[227]= 0.962216 > > > In[228]:= RandomReal[] > > > Out[228]= 0.302348 > > > optimalactivity simpy calculates an optimum allocation of resources: > > > optimalactivity := Table[y[i], {i, Length[inputmatrix]}] /. Ma= xi= > mize[ > > Plus @@ (Table[y[i], {i, Length[inputmatrix]}].(outputmatri= x = > - > > inputmatrix))[[consumables - 2]], CONDITIONS , > > Table[y[i], {i, Length[inputmatrix]}]][[2]] > > > There is no SeedRandom[] anywhere to be found. > > > > Bas Straatman > > Very disturbing. Dan, Rob, Darren: Any ideas as to what's going on and how to avoid it until it's fixed (soon, I hope). --Mark === Subject: Re: How can I get the previous Fibonacci calculated > prevFib[x_] := Module[{m, n, x2}, > x2 = SetPrecision[x, 100]; > If[x > 10^15, > N[x/GoldenRatio], > m = (n /. FindRoot[Fibonacci[n] - x2 == 0, {n, 100}, > WorkingPrecision -> 100]) - 1; > If[Abs[m - Round[m]] < 10^-10, > Fibonacci[Round[m]], > N[Fibonacci[m]]]]] > > prevFib[13] > > 8 > > prevFib[Fibonacci[50]] == Fibonacci[49] > > True > > prevFib[Fibonacci[10000]] == Fibonacci[9999] > > True > > prevFib[Fibonacci[20000]] == Fibonacci[19999] > > True > > prevFib[234.34*^10] > > 1.4483008492365037*^12 But that's not a Fibonacci number! I suggest In[7]:= n = 234.34*^10; inv = Round[Log[GoldenRatio, Sqrt[(Sqrt[5]*n + Sqrt[5*n^2 - 4])* (Sqrt[5]*n + Sqrt[5*n^2 + 4])]/2]]; Fibonacci[inv - 1] Out[7]= 1548008755920 I am guessing that the OP actually wants to find the Fibonacci number which immediately precedes a given _Fibonacci number_. If that guess is correct, that is, if n is actually supposed to be a Fibonacci number, then my inv will always work correctly for n >= 2. But CAUTION: If n is not a Fibonacci number, then my method may give an incorrect answer. In the example, 234.34*^10 is not a Fibonacci number and so there was no guarantee that my method would give the correct result, although it happened to do so. David W. Cantrell > > > How can I get a previous Fibonacci calculated number in a specific > range. I can calculate the previous number of phi see below > > phi1 =(1+sqrt(5))/2 > > 13/phi1 > > I tested it with 13 and got 8.034441857 .....so that works > > but how can I get only the previous numbers of Fibonacci in a > specified range from 20 to 20000 if I input a large number like > 234.34e10 > > tia sal2 === Subject: Re: MatrixForm affects values instead of only printing You included MatrixForm as part of the definition of test2 test2 = {-3, 7, 5} // MatrixForm MatrixForm[{-3, 7, 5}] ?test2 Global`test2 test2=MatrixForm[{-3,7,5}] You want MatrixForm applied to the output not the definition, i.e., (test2 = {-3, 7, 5}) // MatrixForm MatrixForm[{-3, 7, 5}] ?test2 Global`test2 test2={-3,7,5} test2[[3]] 5 Bob Hanlon Here is the example: test1={-3, 7, 5} test1[[3]] returns the list and 5 as expected; test2={-3, 7, 5}//MatrixForm test2[[3]] returns a column vector and error: \part 3 of blah blah doesn't exist\. \ The actual list itself is test2[[1]]. To get the right 3rd element I have to \ do: test2[[1,3]] which returns 5 as expected. The problem is MatrixForm is NOT supposed to change the expression it is \ applied on according to the manual. Is that a bug or there's logical \ explanation? === Subject: Re: treatment on C[i] > Hi mathematica community, > C[i] is the default form for the i th parameter or constant generated > by mathematica in representing the results of various symbolic > computations in such functions as DSolve, RSolve and Reduce. > My question is: is it possible to know in advance how many C[i] will > be generated? > If not how to represent the generic form of them: For example I have > an input with reduce and mathematica generates in the output C[1],C > [2],C[3] and C[4] so four C[i] in the solutions but before that when I > need to use something in the input that represent C[i] in general > without knowing how many of them will be generated? I have tried to > use the pattern object _ like that C[ _ ] but it does not work. > You can always count them Count[C[1] + C[2]/x, C[_], {0, \\[Infinity]}] or retrieve them Cases[C[1] + C[2]/x, C[_], {0, \\[Infinity]}] === Subject: Re: treatment on C[i] it is a question of mathematics, how many free constants you have. For example: DSolve[x''[t] + x[t] == 0, x[t], t] has two free constants, because it is a differential equation of second order and no initial conditions are given. So, look onto your problem and you will know how many free constants you have. And sol = DSolve[x''[t] + x[t] == 0, x[t], t]; Cases[sol, C[_], Infinity] // Union work fine to extract the parameters Jens > Hi mathematica community, > C[i] is the default form for the i th parameter or constant generated > by mathematica in representing the results of various symbolic > computations in such functions as DSolve, RSolve and Reduce. > My question is: is it possible to know in advance how many C[i] will > be generated? > If not how to represent the generic form of them: For example I have > an input with reduce and mathematica generates in the output C[1],C > [2],C[3] and C[4] so four C[i] in the solutions but before that when I > need to use something in the input that represent C[i] in general > without knowing how many of them will be generated? I have tried to > use the pattern object _ like that C[ _ ] but it does not work. > > Any suggestion? > === Subject: Re: String as a variable name > I found it: I forgot to wrap Evaluate around the assignment. This works: > > Symbol[\variable\<>\1\]//Evaluate=10 > This is not going to work if variable1 already has a value. Because of how Mathematica evaluates expressions, the only way around this is using the third argument of ToExpression: assignToName[name_String, value_] := ToExpression[name, InputForm, Function[var, var = value, HoldAll]] Assign 1 to variable1 assignToName[\variable\ <> \1\, 1] However, whenever one feels the need to use something like this, it's worth thinking over if variable[1] = 1 would work in its stead. It's simpler and safer. === Subject: Re: can SendMail use HTML and embedded images > A nice new feature of v7 is SendMail. > I use Mathematica to run hourly/daily stats on my web servers, and I > started to use SendMail to send the stats. > > I searched the documentation at length, but I have not figured out how > to send the email with an HTML and embedded images. > > Has anyone looked into this? > > I believe html in emails can use a for the email, the \content-type\ needs to be set to text/html, it would \ > be nice if that was an option (I suspect there is a way to do it, I just > have not figured it out). Maybe even detect {\EventLocator\, \Event\ -> x[t], \EventAction\ :> (k++; If[k > 4, Throw[Null, \StopIntegration\]])}] work fine. Jens > I am trying to stop integrating the equations of motion of a simple \ pendulum after the bob has crossed the vertical a certain number of times. \ This is the code I have so far. \k\ counts the number of times the bob \ crosses the vertical. > > EOM = x''[t] + 9.8 Sin[x[t]]; > x1ic = Pi/2; > x1pic = 0; > k = {0}; > NDSolve[{EOM == 0, x[0] == x1ic, x'[0] == x1pic}, {x}, {t, 0, 10}, Method \ -> {EventLocator, \Event\ -> {x[t],First[k] - 5}, EventAction :> {k == k++; \ Print[k],Throw[t1 = t; xt1 = x[t]; xpt1 = x'[t];,StopIntegration\]}}] > === Subject: Re: Indexed Slot in a Rule - How to do it?? Alan, I'm not sure I fully understand your question. Is below what you're after? In[1]:= func[list_List] := {0, 5 list[[1]], 1, 10 list[[3]], 3 list[[2]]} In[2]:= func[{1, 2, 3}] Out[2]= {0, 5, 1, 30, 6} In[3]:= func[{x1, x2, x3}] Out[3]= {0, 5 x1, 1, 10 x3, 3 x2} > Here's the problem. Convert a vector (list) with symbol names into > indexed slots. I'm doing this so that I can turn the vector into > function that takes a list. Here's an example of the desired > behavior: > > eqs = {0, 5*x1, 1, 10*x3, 3*x2}; > > convert this to: > > indexedeqs = {0, 5*#[[1]], 1, 10*#[[3]], 3*#[[2]]}; > > T[q_]:=indexedeqs; > > T[{1,2,3}] = {0,5,1,30,6} > > I can't for the life of me figure out how to do this. I've been > performing meta-Mathematica all week. Here's the closest I've come: > > xvars={x1,x2,x3}; > MapIndexed[Rule[#1, #[[First@#2]]] &, xvars] > > But, this treats the second # literally, and puts in the current item > from xvars. I need a way for the second # to just be # without it > really taking a value. > > So, I tried doing it as a string: > xvars={x1,x2,x3}; > MapIndexed[Rule[#1, \#[[\ <> ToString[First@#2] <> \]]\] &, xvars] > > And this creates a rule that looks correct, but, its right hand side > of the rule is a string instead of an expression. > > I can't figure this out!!! Any help is greatly appreciated. > > All the best, > Alan > > === Subject: Re: Indexed Slot in a Rule - How to do it?? eqs = {0, 5*x1, 1, 10*x3, 3*x2}; Extract all variable names xvars = Union[Cases[eqs, _Symbol?(! NumericQ[#] &), Infinity]]; Attributes[Function] {HoldAll,Protected} Since Function has attribute HoldAll T = Function[Evaluate[xvars], Evaluate[eqs]]; The argument to T is a Sequence T[1, 2, 3] {0,5,1,30,6} T[Sequence @@ {1, 2, 3}] {0,5,1,30,6} Consequently, Apply T to a List T @@ {1, 2, 3} {0,5,1,30,6} Apply[T, {1, 2, 3}] {0,5,1,30,6} Bob Hanlon Here's the problem. Convert a vector (list) with symbol names into indexed slots. I'm doing this so that I can turn the vector into function that takes a list. Here's an example of the desired behavior: eqs = {0, 5*x1, 1, 10*x3, 3*x2}; convert this to: indexedeqs = {0, 5*#[[1]], 1, 10*#[[3]], 3*#[[2]]}; T[q_]:=indexedeqs; T[{1,2,3}] = {0,5,1,30,6} I can't for the life of me figure out how to do this. I've been performing meta-Mathematica all week. Here's the closest I've come: xvars={x1,x2,x3}; MapIndexed[Rule[#1, #[[First@#2]]] &, xvars] But, this treats the second # literally, and puts in the current item from xvars. I need a way for the second # to just be # without it really taking a value. So, I tried doing it as a string: xvars={x1,x2,x3}; MapIndexed[Rule[#1, \#[[\ <> ToString[First@#2] <> \]]\] &, xvars] And this creates a rule that looks correct, but, its right hand side of the rule is a string instead of an expression. I can't figure this out!!! Any help is greatly appreciated. All the best, Alan === Subject: Sidebar Tools I have updated the package Sidebar`. It includes several interactive tools to control, to navigate, and to trace notebook changes. Main properties of Sidebar` palettes include: - Navigation between the arbitrary selected places in the notebooks - Automatic preserving of the notebook modified cells - Notebook clearing, backuping etc. - Generation of the active table of contents (TOC) - Work with the group of choosen sections/subsections of the notebook (selection, evaluation, hiding, revealing) - Clipboard stack - Symbol information window - Tracing graphics coordinates and the evaluation time - Easy access to special notebooks (ToDo, Memo, Code) - Few more functions, like comparing of two cells of the notebook, locking/unlocking etc It works OK for me but it is still experimental. Please be careful when you start to use it! The package link Yuri Kandrashkin === Subject: Re: Image[], Graphics[Raster[]] On May 31, 2:32 pm, Jens-Peer Kuska > Oh mixing is easy: > > img = Import[\http://www.stephenwolfram.com/img/home/sw-portrait.jpg\] > Graphics[ > {Image`ToGraphicsRaster[img][[1]], > Circle[{110.5, 110.5}, 10]}] > > draw a circle on the image. function \Image`ToGraphicsRaster\ is documented? I have not found anything in the Documentation about this. === Subject: Re: Image[], Graphics[Raster[]] I think that the documentation on how to integrate graphics and images from the new image processing features in V7 is not to par with the rest of the documentation. Image Processing feels a bit of an orphan in V7, it makes sense, since it is new. Some suggestions: 1- guide/CombiningGraphics could show how to use an image in a Graphics[] or as a background of a plot 3 - \Basic Image Processing tutorial \, \Image\, \Import\ could demonstrate our to mix images and graphics 2- \Import\,\Show\,\Graphics\,\Inset\ documentations could explain \ more clearly that Import[filename,\Graphics\] will import a file the old way and show examples of integration. Luc -----Original Message----- === Subject: Re: Image[], Graphics[Raster[]] > > 1. Is Image[] any different than Graphics[Raster[]] that I'm more > accustomed to? No it has a fixed data range, i.e., \Byte\ is [0,255], \Real\ [0,1] while Graphics[Raster[]] can handle undestructive every thing. > > 2. If not, what was the point of introducing Image[]? Was it any effort to > provide a more streamlined set of commands all revolving around Image[], > e.g., ImageRotate[], etc.? The reason was a faster display of the bitmap. With fixed data range the FE don't have to do a scaling of every pixel. > > > 3. Image[] somehow upsets my unified view of Mathematica. That is, I like > to try to \think\ like Mathematica, and so I understand that all commands > like Plot[], ListPlot[], etc., reduce to a Graphics[] object in > FullForm[]. Similarly, I can build my own type of plotting function with > Graphics[]. Most importantly, I can combine many different types of > objects into a single Graphics[]. Am I correct that Image[] represents > then a completely new display object? If so, is there a way, for example, > to have an Image[] and then draw across it with an Epilog rule like you > can do with Graphics[]? It seems a major setback if Image[] and Graphics[] > cannot be readily mixed. > Oh mixing is easy: img = Import[\http://www.stephenwolfram.com/img/home/sw-portrait.jpg\] Graphics[ {Image`ToGraphicsRaster[img][[1]], Circle[{110.5, 110.5}, 10]}] draw a circle on the image. > Anyone out there to make the case that Image[] represents an important new > capability? No, it make many things more complicated, and a lot of image processing tasks impossible -- registration for example .. I see it as a little worse than the usual \new command that > does same thing old stuff did\ because it seems to lose the capability to > mix Graphics[] and Image[]. > > Please inform me if I'm completely off base. As I said, I'm just digging > into Image[] now for the first time, and I'm a bit confused about possible > merits---please do inform! There is no merit, it make many things worse than the original Graphics[Raster[]] Jens === Subject: Re: Reading Fortran Data file >Have data fortran data file with numbers like 0.447562485933D-01. I >need all the digits, but mathematica seems to only read this as >0.0448062. >So how can I read in all the digits. It is far from clear all of the digits have not been read. Mathematica by default does not display all of the digits in a machine precision number. For example, In[1]:= x = RandomReal[] Out[1]= 0.436287 In[2]:= RealDigits[x] Out[2]= {{4,3,6,2,8,7,3,0,2,4,3,3,0,6,3,1},0} Here the value returned by RandomReal has 16 significant digits but only 6 are displayed. My guess is all of the digits in your file have been read. === Subject: Re: two questions >a. I made a package and I want to retrieve the functions it has. >What I would want is: Command[mypackage] Output: functions for the >user contained in myg package >How can I do this? Somehow, I have failed to find this in the >documentation. First, load the package using either Get or Needs. Then doing ?contextname`* will list all of the symbols available to the user where contextname is the name of the context for the package loaded. Usually (not always), this is the same as the package name. For example, if I load a package I've created for my usage by doing: In[1]:= << Statistics`SplineSmoothing` In[2]:= ?Statistics`SplineSmoothing`* Statistics`SplineSmoothing` EDF NaturalSpline SplinePolynomial MonotonicQ SplineD SplineResiduals MonotonicSmoothing SplineEvaluate SplineRoot I get a list of functions in the package >b. According to you what are the best references to study the theme >of packages in Mathematica? Maeder has written a couple of texts on programming in Mathematica that would make a good starting point. But even without using Maeder's books, simply opening packages that are distributed with Mathematica with a text editor to see how they are written can be quite informative. === Subject: Re: matching misspelled names Look at guide/SequenceAlignmentAndComparison DamerauLevenshteinDistance[u,v] gives the number of one-element deletions, \ insertions, substitutions and transpositions required to transform u to v. EditDistance[u,v] gives the number of one-element deletions, insertions, and \ substitutions required to transform u to v. HammingDistance[u,v] gives the number of elements whose values disagree in u \ and v. LongestCommonSequence[Subscript[s, 1],Subscript[s, 2]] finds the longest sequence of contiguous or disjoint elements common to the \ strings or lists Subscript[s, 1] and Subscript[s, 2]. LongestCommonSubsequence[Subscript[s, 1],Subscript[s, 2]] finds the longest contiguous subsequence of elements common to the strings \ or lists Subscript[s, 1] and Subscript[s, 2]. NeedlemanWunschSimilarity[u,v] finds an optimal global alignment between the \ elements of u and v, and returns the number of one-element matches. SequenceAlignment[Subscript[s, 1],Subscript[s, 2]] finds an optimal alignment of sequences of elements in the strings or lists \ Subscript[s, 1] and Subscript[s, 2], and yields a list of successive matching \ and differing sequences. SmithWatermanSimilarity[u,v] finds an optimal local alignment between the \ elements of u and v, and returns the number of one-element matches. Bob Hanlon I would like to compare 2 very large lists of names to identify a shortlist of possible matches where someone from the list A appears in the list B. However as English is not the local language, the most names have many spelling alternatives. Also in different contexts, the same person is referred to by the full name with one or more middle names and family names or just by a smaller combination of these. I imagine comparing lists with one or few typos is quite simple. But is there a way to do this in Mathematica which can also handle the type of variations I've outlined? I was thinking of arranging the names into clusters, isolating those clusters which include a list A person, and then generating lists of the closest matches for each cluster around a list A person. Is there a simple way to do this or a better way? Jess === Subject: Re: comments on Wolfram Alpha >input: arima >output: Arima,Trinidad and Tobago >Population: >city population | 34997 people >my comment: Nothing about ARIMA time series models, which comes up as >the 3rd link on Google. Wolfram|Alpha is clearly not Google and is clearly not intended as a Google replacement. Since Google is not doing anything to determine the meaning of what you type as a search term, there is no difficulty in returning links to quite different results. All that is needed for Google to do its thing is that others have used the same search term to link to the things you are interested in. But Wolfram|Alpha is trying to parse your input and extract meaning. Obviously, when you input a single term as you did above, there is essentially nothing to give context and provide meaning. And when it could be as either an acronym or a city name, Wolfram|Alpha clearly must make a choice in order to return any result. Additionally, not all possible meanings for a given term will be available to Wolfram|Alpha yet and may never be available. Wolfram|Alpha is dependent on what is in the databases it can access. It is likely impossible for it to associate a term with a meaning not currently in one of the databases it can access. >Wolfram Alpha appears much less useful than the combination of Google >and Mathematica, so I wonder if resources are better spent adding >functionality to Mathematica. The degree to which Wolfram|Alpha is less useful than the combination of Mathematica and Google depends on the type of information you are looking for and the type of questions you pose. And this will certainly change as Wolfram|Alpha evolves. === Subject: Re: Problems with V7 Hello Sergio: I had the same problem described here: /thread/46d138fb22053814?hl=en# Apparently WRI has seen problems like this. The word I got was it cleared after closing Mathematica and restarting. Or restarting the OS. Neither of these worked for me. So I ended up just going to 7.0.1. Not the (a) answer, but.... Roger Williams Franklin Laboratory http://www.meetup.com/The-San-Francisco-Math-Meetup-Group On May 29, 5:58 pm, Sergio Miguel Terrazas Porras > Hi group! > > I installed the in home use Mathematica 7 and have used it for a while. \ S= uddenly, the other day I started it and immediately noticed somethind was \ w= rong, because the fonts used in an input cell looked strange. > > Furthermore, it does not evaluate the input cells. I tried to start the \ l= ocal kernel manualy, to no avail. > Has anybody else experienced this? > > Any suggestions? > > > Sergio Terrazas === Subject: Re: problem Hi Parmida, If you examine your two equations you see that they are actually identical. If you swap z and y you get the same equations. Conclusion:the solutions for z and y must be the same either. y[x]==z [x]. You can therefore replace z in the first equation with y and solve for y only. DSolve[y''[x] == -y[x] Sqrt[(y[x]^2)]*Sqrt[2], y[x], x] It is still a difficult nut to crack though. Mathematica finds a result in the form of an integral equation, which doesn't help you much. > Hi > I'm having trouble solving this set of equations: > > y''[x] =-y[x]*((y[x])^2 + (z[x])^2)^0.5 > z''[x] =-z[x]*((y[x])^2 + (z[x])^2)^0.5 > > > NDSolve[{y''[x] == -y[x]*((y[x])^2 + (z[x])^2)^0.5, > z''[x] == -z[x]*((y[x])^2 + (z[x])^2)^0.5, y'[0] == 0.5, z[0]= == 1, > y[0] == 1, z'[0] == 0.5}, {y, z}, {x, -100, 100}] > > I can plot this answer but what I really need is the parametric solution(a \ set of equations for z and y depending on x). > > Please help me find the answer. > > thanx > parmida === Subject: Re: problem Sometimes, in attempting to use DSolve or Solve, it helps to avoid as follows (but it didn't help any with DSolve): deqns = {y''[x] == -y[x]*((y[x])^2 + (z[x])^2)^(1/2), z''[x] == -z[x]*((y[x])^2 + (z[x])^2)^(1/2), y'[0] == 1, y[0] == 1, z'[0] == 1/2, z[0] == 1}; Clear[y, z]; dsols = First@NDSolve[deqns, {y, z}, {x, -100, 100}] {y[x_], z[x_]} = {y[x], z[x]} /. dsols ParametricPlot[{y[x], z[x]}, {x, -100, 100}, Frame -> True] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hi I'm having trouble solving this set of equations: y''[x] =-y[x]*((y[x])^2 + (z[x])^2)^0.5 z''[x] =-z[x]*((y[x])^2 + (z[x])^2)^0.5 I couldn't write a DSolve order for it but here is the numerical code I NDSolve[{y''[x] == -y[x]*((y[x])^2 + (z[x])^2)^0.5, z''[x] == -z[x]*((y[x])^2 + (z[x])^2)^0.5, y'[0] == 0.5, z[0] == 1, y[0] == 1, z'[0] == 0.5}, {y, z}, {x, -100, 100}] I can plot this answer but what I really need is the parametric solution(a set of equations for z and y depending on x). Please help me find the answer. thanx parmida === Subject: problem with reduce Hi mathematica community, I have to solve this example In[88]:= Reduce[Exists[{C[1], C[2]}, Element[{C[1], C[2]}, Integers] && C[1] >= 0 && C[2] >= 0 && i == 1 + C[1] && N == 1 + C[1] + C[2] && iP == 1 + C[1] + C[2] && jP == j - C[2]], {iP, jP}, Backsubstitution -> True] During evaluation of In[88]:= Reduce::nsmet: This system cannot be solved with the methods available to \\ Reduce. >> I have observed that when I remove Element[{C[1], C[2]}, Integers] && C [1] >= 0 && C[2] >= 0 like that: In[89]:= Reduce[ Exists[{C[1], C[2]}, i == 1 + C[1] && N == 1 + C[1] + C[2] && iP == 1 + C[1] + C[2] && jP == j - C[2]], {iP, jP}, Backsubstitution -> True] it gives me an output which is: Out[89]= iP == N && jP == i + j - N I need to keep the information that Element[{C[1], C[2]}, Integers] && C[1] >= 0 && C[2] >= 0 but reduce tells me that it cannot solve this system. why and how to deal with this problem? thank you. === Subject: Re: problem writing debugging utility function SetAttributes[echo, HoldFirst] echo[x_] := Print[ToString@HoldForm@x, \ = \, x] Bobby > This matter is pretty unimportant, but perhaps of interest in laying > out a persistent source confusion for me with Mathematica: evaluation > control. > > I'm skeptical of the built-in debugger because it seems to crash the > kernel often, so I do most of my debugging by inserting print > statements like > > Print[\variableOne = \,variableOne]. > > Being extraordinarily lazy I soon thought it might be nice to have a > little function, say dbgv, which takes a variable or name of a > variable as an argument, and produces the same result as the print > statement above. > > At first I assumed this would be easy, since almost every programming > problem turns out to be pretty easy with Mathematica. But after an hour > or so I began to wonder whether it would be possible at all. I did > eventually find a solution, a function dbgv such that dbgv[variableOne] > produces exactly the effect of the print statement, but it's really ugly. > I'll post it later. > > Granted this is not an important problem since it's not too much > trouble to just type in the whole print statement. But it's worth > noting that this would trivial to solve with a Lisp macro, and despite > the fantastic expressibility of Mathematica it doesn't seem to have a > good replacement for macros. The closest equivalents are $Pre(Read), > which I used in my solution, but they're not nearly as nice to work with. > > Can anyone think of an elegant solution? > -- DrMajorBob@bigfoot.com === Subject: Re: problem writing debugging utility function On May 31, 1:37 pm, \dabro...@indiana.edu\ > > The Unevaluated[] function had slipped off my radar, probably because > I never fully grokked the distinction between it and Hold[]. In fact > I'm still a bit confused about it. At first I thought it might like > the evaluation inhibitor ` in Lisp, but some examples disabused me of > that. > > In[2]:= f@Unevaluated[5 + 6 + 7 + 8] > > Out[2]= f[Unevaluated[5 + 6 + 7 + 8]] > > In[11]:= ToString@Unevaluated[5 + 6 + 7 + 8] > > Out[11]= \5 + 6 + 7 + 8\ > > I might have expected Out[11]= \Unevaluated[5 + 6 + 7 + 8]\ > > In[13]:= sqr[x_] := x^2 > > In[14]:= sqr@Unevaluated[5 + 6 + 7 + 8] > > Out[14]= 676 > > I might have expected Out[14]= sqr[5 + 6 + 7 + 8] since sqr does not > know what to do with the pattern _+_+_+_ or _+_ for that matter. > Could anyone elucidate this for me? Unevaluated[] is treated in a special way during evaluation. There's a good explanation of what it does in the docs, under 'More information': \f[Unevaluated[expr]] effectively works by temporarily setting attributes so that f holds its argument unevaluated, then evaluating f [expr].\ http://reference.wolfram.com/mathematica/ref/Unevaluated.html There's also a very detailed explanation somewhere in the docs of how exactly expressions are evaluated by the kernel. You can look that up if you're interested. It's no wonder if you're confused about Unevaluated/Hold/etc. and evaluation order. They can be confusing. People are usually pointed to the paper titled 'Working with Unevaluated Expressions' by Robby Villegas. There's a link to it here: http://library.wolfram.com/conferences/devconf99/ === Subject: Re: Perpendicular lines do not appear perpendicular One plausible theory is that your monitor doesn't have perfectly square \ pixels. In looking up the specs of your monitor, I notice that the resolution is 1680/1050, which would make the aspect ratio of the viewable area of your \ screen 1.6 if you have perfectly square pixels. However, the standard aspect ratio \ of a wide-screen monitor is, instead, 1.78 (16:9). I can't tell from the information I can get online, but this raises the \ natural question for me...what is the actual aspect ratio of your screen? Is it a \ ratio which preserves square pixels, or the standard 16:9 ratio used for many \ wide screen monitors and televisions today? Mathematica can not tell the difference. Newer operating systems are \ starting include the ability to report more accurate information about monitors. I'm \ not sure off the top of my head if it would be quite so accurate to pick up the subtle aspect ratio difference I'm suggesting is the problem. But \ Mathematica has a long legacy of working on operating systems which routinely \ lie...yes, they really lie...about the actual size of a monitor pixel (including both \ Mac and Windows, incidentally...and Linux would just be hopeless in this \ regard). The same problem does not exist for printers. Mathematica, and pretty much every other software package out there, has supported non-square pixels on printers forever, since the operating systems gave us the tools to do so \ easily. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > Perpendicular lines do not appear perpendicular > > Hi: > > I have taken the line equation 2*x+4*y-6==0, and rotated it 90 degrees > counterclockwise about {0,0}, > using a 3x3 rotation matrix. > Here's the Mathematica 6.0.1 code that I used: > > rMat = {{Cos[90 Degree], - Sin[90 Degree], 0}, {Sin[90 Degree], > Cos[90 Degree], 0}, {0, 0, 1}} > > l={2, 4, -6} > > rMat.l > > Output: {-4,2,-6} > > Placing these numbers into the general form of the equation of the line > Ax+By+c=0, I get -4*x + 2*y - 6 == 0. > Placing the 2 perpendicular line equations into ContourPlot: > > ContourPlot[{2*x + 4*y - 6 == 0, -4*x + 2*y - 6 == 0}, {x, -4, > 4}, {y, -4, 4}, AspectRatio -> 1] > > and plotting, I notice that on my pc screen that the lines do not look > perpendicular, as does the plot frame. > Perhaps this is just my computer screen, a HP f2105. I can hold up a > square cut piece of paper to the lines > on the screen, and notice the out-of-square condition. I used= AspectRatio- > >1, but still no joy. > > Question: Can someone suggest a remedy for my problem, if one exists? > > > > Bill > > PS. Mathematica 6.0.1 on a pc with Win XP. === Subject: Re: RandomReal gets stuck >I can confirm this bug. >Executing an even simpler version, namely >Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >will also set the random generator to a fixed starting point. The >number 31 is crucial, as lower values do not appear to cause the >bug, while higher values do. Changing Plus to Times appears to >prevent the bug. >In[394]:= Table[ >Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >RandomReal[], {20} >] When I execute the code above, I do get the same result as you report. Clearly, there is a problem here somewhere. But it isn't clear the issue is with RandomReal. The code above uses Maximize in a non-sensical way, particularly when the function y hasn't been defined. This usage asks Mathematica to find the maximize the sum of n things with respect to each of the n things. It appears there is an attempt to use the notation y[n] to mean an array indexed by n rather than a function of n. So, Maximize correctly generates error messages. What is unexpected is poor input to Maximize appears to cause a problem for RandomReal. On my system, changing Plus to Times eliminates the effect on RandomReal even though there is still a non-sensical input to Maximize. Alternatively, defining y then executing the code does In[5]:= y[n_] := n^2 - n In[6]:= Table[ Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; RandomReal[], {20}] During evaluation of In[6]:= Maximize::ivar: 0 is not a valid variable. >> During evaluation of In[6]:= Maximize::ivar: 0 is not a valid variable. >> During evaluation of In[6]:= Maximize::ivar: 0 is not a valid variable. >> During evaluation of In[6]:= General::stop: Further output of Maximize::ivar will be suppressed during this calculation. >> Out[6]= {0.877054,0.833103,0.703786,0.0482118,0.226066,0.230746,0.0738072= ,0.680963,0.53264,0.989333,0.418793,0.951114,0.963168,0.870439,0.926361,0.26\ 7113,0.195084,0.810066,0.875896,0.579076} >This is very nasty, as a lot of people critically depend on random >functions to be random. I would urge you to report this to wolfram >support. I agree many people including myself depend on the random functions to be random. And I would also like Mathematica to fail gracefully when given non-sensical input and provide useful error messages. But I am never surprised when software does something other than fail gracefully given non-sensical input or provides less than useful error messages. Entering Table[ Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; RandomReal[], {20} ] into a new session and expecting useful output simply isn't a reasonable expectation. Note, this in no way says what the original poster was doing is unreasonable or non-sensical. The rest of the information needed to determine whether what the original poster was attempting is sensible hasn't been provided. I would also note, that sending a bug report to Wolfram without the additional information is probably pointless. === Subject: Re: MatrixForm affects values instead of only printing This is normal behaviour and applies also to TableForm and various others. The documentation actually refers to such things as \wrappers\, which \ affect printing but not evaluation. This means they just add a wrapper without affecting the contents (this is why you're able to retrieve the original matrix via test1[[1]]), but it doesn't mean the wrapper is invisible. I think the key is to avoid using MatrixForm in definitions and only call \ it for display purposes. So, where you had something like mat = {{1,2}, {3,4}} // TableForm you should add some parentheses so that the TableForm occurs outside of the Set operation: (mat = {{1,2}, {3,4}}) // TableForm Peter > Here is the example: > > test1={-3, 7, 5} > test1[[3]] > > returns the list and 5 as expected; > > test2={-3, 7, 5}//MatrixForm > test2[[3]] > > returns a column vector and error: \part 3 of blah blah doesn't exist\. \ The > actual list itself is test2[[1]]. To get the right 3rd element I have to \ do: > > test2[[1,3]] > > which returns 5 as expected. > > > The problem is MatrixForm is NOT supposed to change the expression it is > applied on according to the manual. Is that a bug or there's logical > explanation? > === Subject: Re: MatrixForm affects values instead of only printing The issue is that in FullForm[], you have created: MatrixForm[List[-3,7,5]] So now you can see why Part[xxx,3] does not work. You would have to do Part[xxx,1,3] to get your desired result. > Here is the example: > > test1={-3, 7, 5} > test1[[3]] > > returns the list and 5 as expected; > > test2={-3, 7, 5}//MatrixForm > test2[[3]] > > returns a column vector and error: \part 3 of blah blah doesn't exist\. \ The actual list itself is test2[[1]]. To get the right 3rd element I have to \ do: > > test2[[1,3]] > > which returns 5 as expected. > > > The problem is MatrixForm is NOT supposed to change the expression it is \ applied on according to the manual. Is that a bug or there's logical \ explanation? > > === Subject: Re: MatrixForm affects values instead of only printing ????? The documentation is either incorrect or misleading on the effect of MatrixForm. It certainly does affect how subsequent expressions are evaluated. But this is not all bad and one can learn how to use it. test2 = {-3, 7, 5} // MatrixForm test2 // FullForm Now, what about: test2.test2 % /. MatrixForm -> Identity Would you like the first dot product to evaluate, or would you prefer to \ see it in that form? Often, when I only want temporary MatrixForm display I write definitions with an extra pair of brackets: (test2 = {-3, 7, 5}) // MatrixForm test2[[3]] Part does work on the FullForm of the expression and considers any form wrappers as part of the expression. test3 = NumberForm[a + b + N[\\[Pi]], 12] test3 // FullForm test3[[3]] test3[[1, 3]] Part[FullForm[a + b], 1, 2] I admit, this is all somewhat confusing, and the documentation is misleading. But it is manageable. Maybe someone else will give a clearer explanation. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Here is the example: test1={-3, 7, 5} test1[[3]] returns the list and 5 as expected; test2={-3, 7, 5}//MatrixForm test2[[3]] returns a column vector and error: \part 3 of blah blah doesn't exist\. \ The actual list itself is test2[[1]]. To get the right 3rd element I have to \ do: test2[[1,3]] which returns 5 as expected. The problem is MatrixForm is NOT supposed to change the expression it is applied on according to the manual. Is that a bug or there's logical explanation? === Subject: Re: MatrixForm affects values instead of only printing The same holds for TableForm. I have already noticed this. It seems a bit strange, given that \TableForm (MatrixForm) acts as a \wrapper\, which affects printing, but not evaluation.\ In[194]:= list1 = {{1, 2, 3, 4}, {5, 6, 7, 8}} Out[194]= {{1, 2, 3, 4}, {5, 6, 7, 8}} In[195]:= Part[list1, All, 2] Out[195]= {2, 6} And... In[196]:= list1 = {{1, 2, 3, 4}, {5, 6, 7, 8}} // TableForm 1 2 3 4 5 6 7 8 Part[list1, All, 2] 5 6 7 8 A.B. > Here is the example: > > test1={-3, 7, 5} > test1[[3]] > > returns the list and 5 as expected; > > test2={-3, 7, 5}//MatrixForm > test2[[3]] > > returns a column vector and error: \part 3 of blah blah doesn't exist\. \ The > actual list itself is test2[[1]]. To get the right 3rd element I have to \ do: > > test2[[1,3]] > > which returns 5 as expected. > > > The problem is MatrixForm is NOT supposed to change the expression it is > applied on according to the manual. Is that a bug or there's logical > explanation? > === Subject: Re: comments on Wolfram Alpha It is important to remember that Wolfram|Alpha is, at the present, a framework for answering calculationally-oriented questions. And that framework currently has access to only some databases and knowledge areas. In the course of time many more will be added. But users that first approach Wolfram|Alpha--and who see a simple natural language input field--often expect uniform response to questions that query arbitrary fields of knowledge. So, it is currently a question of the Wolfram|Alpha team getting the message out about what are sensible exceptions that users should come to it with. Rolling out a project of this sort is, I suspect, very complex--not the least because most users have their key experiences with a very different conceptual model of how to ask questions (a la Google, largely). As for Wofram Research's resources and how they might direct their energies... I hope that much of what has gone into creating more and more curated data sets for Wolfram|Alpha will end up being accessible directly from Mathematica in time. I imagine the W|A will accelerate aspects of Mathematica's development--as well as its acceptance as a far more general tool than most people realize it is. Just some random thoughts.... > input: arima > output: Arima,Trinidad and Tobago > Population: > city population | 34997 people > my comment: Nothing about ARIMA time series models, which comes up as > the 3rd link on Google. > > input: garch > output: Wolfram|Alpha isn't sure what to do with your input. > * Did you mean:march > my comment: nothing about GARCH time series models, widely used in > finance > > input: united states budget deficit > output: -$347 billion per year (US dollars per year) (2005 estimate) > my comment: Users would want more recent data, such as the 2008 > deficit and the estimated 2009 deficit. > > Wolfram Alpha appears much less useful than the combination of Google > and Mathematica, so I wonder if resources are better spent adding > functionality to Mathematica. === Subject: Re: comments on Wolfram Alpha Good, use Google then. Why should WolframAlpha try to be better on things where Google is good enough? But with this kind of letters the number of messages to MathGroup will soon reach 200,000. I am also very interested in the abilities and inabilities \ of WolframAlpha, but this is not the right place for that discussion. I \ suggest a policy where letters about Wolfram Alpha from now on are let through only in the cases where Mathematica as such also really is involved. Other letters fit better as direct feedback to Wolfram or as letters to the WolframAlpha Community. What is the opinion of the Moderator here? [I am open to comments on this issue - what rules should apply? -- Moderator] IMHO Ingolf Dahl > -----Original Message----- === > Subject: comments on Wolfram Alpha > > input: arima > output: Arima,Trinidad and Tobago > Population: > city population | 34997 people my comment: Nothing > about ARIMA time series models, which comes up as the 3rd > link on Google. > > input: garch > output: Wolfram|Alpha isn't sure what to do with your input. > * Did you mean:march > my comment: nothing about GARCH time series models, widely > used in finance > > input: united states budget deficit > output: -$347 billion per year (US dollars per year) (2005 > estimate) my comment: Users would want more recent data, such > as the 2008 deficit and the estimated 2009 deficit. > > Wolfram Alpha appears much less useful than the combination > of Google and Mathematica, so I wonder if resources are > better spent adding functionality to Mathematica. > === Subject: Re: comments on Wolfram Alpha Alpha is NOT a search engine. The site makes this clear enough (if you take the effort to read some of its documentation, which is something you apparently haven't done). It has a vast supply of data that it can do calutions with. It's not an encyclopedia of computing algorithms either, not does it claim it is. Google cannot give you the distance to the moon in terms of Sears tower heights. Alpha can. What you could do with Google a week after it launched is significantly less than what you can do with it now, 13 years later. Don't you think that Alpha might have some growth potential as well? > input: arima > output: Arima,Trinidad and Tobago > Population: > city population | 34997 people > my comment: Nothing about ARIMA time series models, which comes up as > the 3rd link on Google. > > input: garch > output: Wolfram|Alpha isn't sure what to do with your input. > * Did you mean:march > my comment: nothing about GARCH time series models, widely used in > finance > > input: united states budget deficit > output: -$347 billion per year (US dollars per year) (2005 estimate) > my comment: Users would want more recent data, such as the 2008 > deficit and the estimated 2009 deficit. > > Wolfram Alpha appears much less useful than the combination of Google > and Mathematica, so I wonder if resources are better spent adding > functionality to Mathematica. === Subject: Re: Accessing Dictionary definitions > Select[WordData[All, \Noun\], Not[FreeQ[WordData[#], \VarietyMeat\]] \ &] > > {brain,heart,liver,tongue,tripe} > > Bob Hanlon > > > Can anyone guide whether Mathematica, can return words that have > common elements in their Definitions ? For example, WordData[\liver\, > \Definitions\] shows\ liver\ has been given a definition that \ includes > {\liver\, \Noun\, \VarietyMeat\}. Is there a way to, for example, > return all words that are \VarietyMeat\ ? === Subject: Re: Indexed Slot in a Rule - How to do it?? a) is seems to be better to use x[1], x[2], ... instead of x1,x2,.. b) xvars={x1,x2,x3}; xvars /. sym_ /; StringMatchQ[ToString[sym], \x*\] :> Slot[ToExpression[StringDrop[ToString[sym], 1]]] Jens > Here's the problem. Convert a vector (list) with symbol names into > indexed slots. I'm doing this so that I can turn the vector into > function that takes a list. Here's an example of the desired > behavior: > > eqs = {0, 5*x1, 1, 10*x3, 3*x2}; > > convert this to: > > indexedeqs = {0, 5*#[[1]], 1, 10*#[[3]], 3*#[[2]]}; > > T[q_]:=indexedeqs; > > T[{1,2,3}] = {0,5,1,30,6} > > I can't for the life of me figure out how to do this. I've been > performing meta-Mathematica all week. Here's the closest I've come: > > xvars={x1,x2,x3}; > MapIndexed[Rule[#1, #[[First@#2]]] &, xvars] > > But, this treats the second # literally, and puts in the current item > from xvars. I need a way for the second # to just be # without it > really taking a value. > > So, I tried doing it as a string: > xvars={x1,x2,x3}; > MapIndexed[Rule[#1, \#[[\ <> ToString[First@#2] <> \]]\] &, xvars] > > And this creates a rule that looks correct, but, its right hand side > of the rule is a string instead of an expression. > > I can't figure this out!!! Any help is greatly appreciated. > > All the best, > Alan > === Subject: Re: Indexed Slot in a Rule - How to do it?? Hi again, you got me a bit curious about this... so here's what I've got now: First, a function to find all symbols of the form symb followed by something. This could be streamlined and generalised a bit... In[1]:= findSymbols[symb_String,expr_]:=findSymbols [{symb,CharacterRange[\0\,\9\]},expr] In[2]:= findSymbols[{symb_String,exts:{__String}},expr_]:=Module[{x}, x=Union@Flatten@FixedPoint[Apply[List,#,\\[Infinity]]&,expr]; Symbol/@Select[x,StringMatchQ[#,symb~~exts..]&]] In[3]:= test={x1,x2,x2a+x33,E^x5,Sin[x1 x2+x3 x4]} In[4]:= findSymbols[\x\,test] findSymbols[{\x\,{\2\,\a\}},test] Out[4]= {x1,x2,x3,x33,x4,x5} Out[5]= {x2,x2a} Then a function that takes the expression, extracts the relevant symbols and turns it into the type of function that you wanted In[6]:= T[expr_]:=Apply[Function[Evaluate@findSymbols [\x\,expr],Evaluate@expr],#]& In[7]:= T[test]@{a,b,c,d,e,f} Out[7]= {a,b,d+x2a,E^f,Sin[a b+c e]} Simon === Subject: Re: Indexed Slot in a Rule - How to do it?? > > xvars={x1,x2,x3}; One more thing: here's how to generate the replacement rules from the list of vars: Thread[xvars -> Slot /@ Range@Length[xvars]] === Subject: Re: Indexed Slot in a Rule - How to do it?? > Here's the problem. Convert a vector (list) with symbol names into > indexed slots. I'm doing this so that I can turn the vector into > function that takes a list. Here's an example of the desired > behavior: > > eqs = {0, 5*x1, 1, 10*x3, 3*x2}; > > convert this to: > > indexedeqs = {0, 5*#[[1]], 1, 10*#[[3]], 3*#[[2]]}; > > T[q_]:=indexedeqs; > > T[{1,2,3}] = {0,5,1,30,6} > > I can't for the life of me figure out how to do this. I've been > performing meta-Mathematica all week. Here's the closest I've come: > > xvars={x1,x2,x3}; > MapIndexed[Rule[#1, #[[First@#2]]] &, xvars] > > But, this treats the second # literally, and puts in the current item > from xvars. I need a way for the second # to just be # without it > really taking a value. > > So, I tried doing it as a string: > xvars={x1,x2,x3}; > MapIndexed[Rule[#1, \#[[\ <> ToString[First@#2] <> \]]\] &, xvars] > > And this creates a rule that looks correct, but, its right hand side > of the rule is a string instead of an expression. > > I can't figure this out!!! Any help is greatly appreciated. > It is certainly possible to do this, and I'm sure several people will post a solution. So here's an alternative suggestion: Instead of #[[1]], etc. use #1, #2, ... and then Apply the function with @@ (or apply it at level one with @@@ instead of mapping with /@, etc.) In[1]:= eqs = {0, 5*x1, 1, 10*x3, 3*x2}; In[2]:= f = With[{fun = eqs /. {x1 -> #1, x2 -> #2, x3 -> #3}}, fun &] Out[2]= {0, 5 #1, 1, 10 #3, 3 #2} & In[3]:= f @@ {x, y, z} Out[3]= {0, 5 x, 1, 10 z, 3 y} === Subject: Re: Indexed Slot in a Rule - How to do it?? Hi Alan, You might be trying to make it a bit too complicated. If you use the explicit form of Function I think it becomes easier, eg In[1]:= eqs={0,5*x1,1,10*x3,3*x2}; In[2]:= T1=Function[{x1,x2,x3},{0,5 x1,1,10 x3,3 x2}]; In[2]:= T1@@{1,2,3} Out[2]= {0,5,1,30,6} In[3]:= T[q_List]:=Apply[T1,q] In[4]:= T[{1,2,3}] Out[5]= {0,5,1,30,6} Simon === Subject: The standard deviation of Three fitting parameters is bigger than I try to fit a formula, 0.00138 t + 74.830*(t/a)^3*Integrate[(E^x x^4)/(E^x - 1)^2, {x, 0, a/ t}] + n 3*8.314 (w/ t)^2 E^(w/ t)/(-1 + E^(w/t) )^2 a,w,n are fitting parameters t is indenpendt veriable First, I let a=375.362 to fit w and n. FindFit[dataAl210K, {0.00138 t + 74.830*(t/375.362)^3*Integrate[(E^x x^4)/(E^x - 1)^2, {x, 0, 375.362/t}] + n 3*8.314 (w/ t)^2 E^(w/ t)/(-1 + E^(w/t) )^2}, {n, w},t] I got {n -> 0.152124, w -> 1043.57} and the S.D.=0.150984 (standard deviation) Then, I relax these there fitting parameters and give initial conditions. FindFit[dataAl210K, {0.00138 t + 74.830*(t/a)^3*NIntegrate[(E^x x^4)/ (E^x - 1)^2, {x, 0, a/t}] +n 3*8.314 (w/ t)^2 E^(w/ t)/(-1 + E^(w/t) )^2, {n > 0, a > 0, w > 0}}, {{n, 0.15}, {a, 375}, {w, 1043}}, t] Intuitively, the S.D. of three parameters should be smaller than two. However, the S.D. of {n -> 0.904794, a -> 1921.19, w -> 259.28} is 0.273892. I feel the answer is very close to the first one. I think Mathematica may change the parameters too quickly,so the caculation escape the local minimun of the first condition by only few steps. Q:Can I constraint Mathematica to change the fitting parameters slower? Don't escape the initial conditions I give too quickly. (Can Nonlinearmodelfit do this?) === Subject: Re: two questions a) what may Names[\mypackage`*\] do ? Print all the symbols in that context ? b) is it so much to study ? \Programming in Mathematica\ by Roman Maeder Jens > > a. I made a package and I want to retrieve the functions it has. What I \ would want is: > Command[mypackage] > Output: functions for the user contained in myg package > > How can I do this? Somehow, I have failed to find this in the \ documentation. > > b. According to you what are the best references to study the theme of \ packages in Mathematica? > Francisco > === Subject: Re: two questions On May 31, 1:31 pm, Francisco Gutierrez > > a. I made a package and I want to retrieve the functions it has. What I \ w= ould want is: > Command[mypackage] > Output: functions for the user contained in myg package > > How can I do this? Somehow, I have failed to find this in the \ documentati= on. > > b. According to you what are the best references to study the theme of= packages in Mathematica? If you followed the usual way of constructing the package, then all the public symbols of the package (and *only* the public symbols of the package) will be in a context associated with it. Thus Names[\MyPackagesContext`*\] is going to return a list of the names of the symbols in the package. (?MyPackagesContext`* is probably more convenient for a user of the package.) Take a look at how some of the standard packages are organized. First comes BeginPackage[\MyPackage`\], then all the symbols (and only those symbols) that are to be exported by the package are mentioned (usually in the form of usage message definitions), then comes a Begin [\`Private`\] followed by the actual definitions of the functions. This structure ensures that the symbols that are meant for public use are part of MyPackage` and the rest of the symbols used in the function definitions are private. === Subject: Re: two questions > b. According to you what are the best references to study the theme of= packages in Mathematica? Wolfram Research has Tutorial Collection for free download in PDF (of course, you can buy printed book from same place): http://www.wolfram.com/learningcenter/tutorialcollection/ I beleive that there you can find everything you need. -- == Matemati=E8ko podzemlje == http://www.matematicko-podzemlje.com/ http://matka.forumotion.com/ http://www.travian.com.hr/?uc=hr3_5588 === Subject: Re: MatrixForm affects values instead of only printing ????? your test2 is MatrixForm[{-3,7,5}] and MatrixForm[] must change the expression because it wrap arround the expression. Just read the manual :-) Jens > Here is the example: > > test1={-3, 7, 5} > test1[[3]] > > returns the list and 5 as expected; > > test2={-3, 7, 5}//MatrixForm > test2[[3]] > > returns a column vector and error: \part 3 of blah blah doesn't exist\. \ The actual list itself is test2[[1]]. To get the right 3rd element I have to \ do: > > test2[[1,3]] > > which returns 5 as expected. > > > The problem is MatrixForm is NOT supposed to change the expression it is \ applied on according to the manual. Is that a bug or there's logical \ explanation? > === Subject: Re: MatrixForm affects values instead of only printing ????? You're right about this behaviour, and in fact it holds for any of the *Form \wrappers\. eg test3={-3,7,5}//FullForm test3[[3]] but, for example test2={-3,7,5}//MatrixForm %[[3]] behaves as you'd expect. The wrapper really doesn't affect the evaluation. The \problem\ is that the postfix operation takes precedence over the Set (=) thus these inputs are interpreted as (eg) Set[test2, MatrixForm[List[-3,7,5]]] and in some cases you really do want this, which is why it's the behaviour of Mathematica. So, you just have to be careful and enforce the order of operations by using expressions such as (test2={-3,7,5})//MatrixForm test2[[3]] Simon PS -- I'm interested in seeing if there's a better explanation than this. === Subject: Re: Perpendicular lines do not appear perpendicular work with out a problem with Mathematica 7.0.1, the only way to get a similar effect is to use the PlotRangePadding option with ContourPlot[{2*x + 4*y - 6 == 0, -4*x + 2*y - 6 == 0}, {x, -4, 4}, {y, -4, 4}, AspectRatio -> 1, PlotRangePadding -> {1, 3}] have you in your init.m files an option setting like this ? Jens > Perpendicular lines do not appear perpendicular > > Hi: > > I have taken the line equation 2*x+4*y-6==0, and rotated it 90 degrees \ counterclockwise about {0,0}, > using a 3x3 rotation matrix. > Here's the Mathematica 6.0.1 code that I used: > > rMat = {{Cos[90 Degree], - Sin[90 Degree], 0}, {Sin[90 Degree], > Cos[90 Degree], 0}, {0, 0, 1}} > > l={2, 4, -6} > > rMat.l > > Output: {-4,2,-6} > > Placing these numbers into the general form of the equation of the line \ Ax+By+c=0, I get -4*x + 2*y - 6 == 0. > Placing the 2 perpendicular line equations into ContourPlot: > > ContourPlot[{2*x + 4*y - 6 == 0, -4*x + 2*y - 6 == 0}, {x, -4, > 4}, {y, -4, 4}, AspectRatio -> 1] > > and plotting, I notice that on my pc screen that the lines do not look \ perpendicular, as does the plot frame. > Perhaps this is just my computer screen, a HP f2105. I can hold up a \ square cut piece of paper to the lines > on the screen, and notice the out-of-square condition. I used \ AspectRatio->1, but still no joy. > > Question: Can someone suggest a remedy for my problem, if one exists? > > > > Bill > > PS. Mathematica 6.0.1 on a pc with Win XP. > === Subject: Re: Perpendicular lines do not appear perpendicular Hi Bill, It looks perfectly perpendicular on my screen. Could you check the resolution to which your monitor is set? It might be that you have set it to a non native resolution with an aspect-ratio that's not 16:10 (which would be natural for your screen). > Perpendicular lines do not appear perpendicular > > Hi: > > I have taken the line equation 2*x+4*y-6==0, and rotated it 90 degree= s counterclockwise about {0,0}, > using a 3x3 rotation matrix. > Here's the Mathematica 6.0.1 code that I used: > > rMat = {{Cos[90 Degree], - Sin[90 Degree], 0}, {Sin[90 Degree], > Cos[90 Degree], 0}, {0, 0, 1}} > > l={2, 4, -6} > > rMat.l > > Output: {-4,2,-6} > > Placing these numbers into the general form of the equation of the line \ A= x+By+c=0, I get -4*x + 2*y - 6 == 0. > Placing the 2 perpendicular line equations into ContourPlot: > > ContourPlot[{2*x + 4*y - 6 == 0, -4*x + 2*y - 6 == 0}, {x, -4, > 4}, {y, -4, 4}, AspectRatio -> 1] > > and plotting, I notice that on my pc screen that the lines do not look \ pe= rpendicular, as does the plot frame. > Perhaps this is just my computer screen, a HP f2105. I can hold up a \ squa= re cut piece of paper to the lines > on the screen, and notice the out-of-square condition. I used \ AspectRatio= ->1, but still no joy. > > Question: Can someone suggest a remedy for my problem, if one exists? > > > Bill > > PS. Mathematica 6.0.1 on a pc with Win XP. === Subject: Re: Perpendicular lines do not appear perpendicular > Perpendicular lines do not appear perpendicular > > Hi: > > I have taken the line equation 2*x+4*y-6==0, and rotated it 90 degrees \ counterclockwise about {0,0}, > using a 3x3 rotation matrix. > Here's the Mathematica 6.0.1 code that I used: > > rMat = {{Cos[90 Degree], - Sin[90 Degree], 0}, {Sin[90 Degree], > Cos[90 Degree], 0}, {0, 0, 1}} > > l={2, 4, -6} > > rMat.l > > Output: {-4,2,-6} > > Placing these numbers into the general form of the equation of the line \ Ax+By+c=0, I get -4*x + 2*y - 6 == 0. > Placing the 2 perpendicular line equations into ContourPlot: > > ContourPlot[{2*x + 4*y - 6 == 0, -4*x + 2*y - 6 == 0}, {x, -4, > 4}, {y, -4, 4}, AspectRatio -> 1] > > and plotting, I notice that on my pc screen that the lines do not look \ perpendicular, as does the plot frame. > Perhaps this is just my computer screen, a HP f2105. I can hold up a \ square cut piece of paper to the lines > on the screen, and notice the out-of-square condition. I used \ AspectRatio->1, but still no joy. > > Question: Can someone suggest a remedy for my problem, if one exists? > You need AspectRatio -> Automatic, not AspectRatio -> 1 (the latter just makes the figure a square), but for this particular plot this does not matter (because the x and y ranges are the same). The lines are perpendicular on my screen. Do check if your screen is operating in its native resolution. === Subject: Re: Reading Fortran Data file ImportString[\0.448062494397D-01\, \List\] ? Jens > Have data fortran data file with numbers like 0.447562485933D-01. I > need all the digits, but mathematica seems to only read this as > 0.0448062. > I can read it as a string and get > > \0.448062494397D-01\ > > but when I use ToExpression, I get > > -1 + 0.448062 D > > So how can I read in all the digits. > > === Subject: Re: Reading Fortran Data file > Have data fortran data file with numbers like 0.447562485933D-01. = I > need all the digits, but mathematica seems to only read this as > 0.0448062. > I can read it as a string and get > > \0.448062494397D-01\ > > but when I use ToExpression, I get > > -1 + 0.448062 D > > So how can I read in all the digits. > Fortran's D notation counts as somewhat unusual these days, but the more common E notation should work fine with Mathematica. So just change all Ds to Es with some program before reading the file. For example, filter the file through the common tr utility: Import[\!tr D E < inputfile\, \Table\] (Of course one could read everything as a string, using \Text\ in Import, then do the replacement using StringReplace[textData, \D\ -> \E\], then use StringImport, but this might not be the best solution when the file is big and one is low on memory. A disadvantage of Mathematica's way of processing data is that it needs to hold everything in memory.) === Subject: Re: MatrixForm affects values instead of only printing Nothing wrong or inconsistent there. Look at: FullForm[test2] MatrixForm[List[-3,7,5]] Then, as expected: test2[[1]] {-3,7,5} And so the 3rd element of that is... test2[[1]][[3]] 5 ... which is the same result as from: test2[[1, 3]] The MatrixForm is still lurking there, as you'll see if you evaluate: Head[test2] MatrixForm Nothing has \changed\! > Here is the example: > > test1={-3, 7, 5} > test1[[3]] > > returns the list and 5 as expected; > > test2={-3, 7, 5}//MatrixForm > test2[[3]] > > returns a column vector and error: \part 3 of blah blah doesn't exist\. \ The actual list itself is test2[[1]]. To get the right 3rd element I have to \ do: > > test2[[1,3]] > > which returns 5 as expected. > > > The problem is MatrixForm is NOT supposed to change the expression it is \ applied on according to the manual. Is that a bug or there's logical \ explanation? > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Perpendicular lines do not appear perpendicular The two lines pass the square-piece-of-paper test on my LCD monitor. > Perpendicular lines do not appear perpendicular > > Hi: > > I have taken the line equation 2*x+4*y-6==0, and rotated it 90 degrees \ counterclockwise about {0,0}, > using a 3x3 rotation matrix. > Here's the Mathematica 6.0.1 code that I used: > > rMat = {{Cos[90 Degree], - Sin[90 Degree], 0}, {Sin[90 Degree], > Cos[90 Degree], 0}, {0, 0, 1}} > > l={2, 4, -6} > > rMat.l > > Output: {-4,2,-6} > > Placing these numbers into the general form of the equation of the line \ Ax+By+c=0, I get -4*x + 2*y - 6 == 0. > Placing the 2 perpendicular line equations into ContourPlot: > > ContourPlot[{2*x + 4*y - 6 == 0, -4*x + 2*y - 6 == 0}, {x, -4, > 4}, {y, -4, 4}, AspectRatio -> 1] > > and plotting, I notice that on my pc screen that the lines do not look \ perpendicular, as does the plot frame. > Perhaps this is just my computer screen, a HP f2105. I can hold up a \ square cut piece of paper to the lines > on the screen, and notice the out-of-square condition. I used \ AspectRatio->1, but still no joy. > > Question: Can someone suggest a remedy for my problem, if one exists? > > > > Bill > > PS. Mathematica 6.0.1 on a pc with Win XP. > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: two questions Hi Francisco, Regarding your first question: the following should do what you want, assuming that the package has been loaded. Clear[functionsInPackage]; functionsInPackage[context_String] := With[{funvalues = {DownValues, UpValues, SubValues}}, Select[Names[context <> \*\], Function[sym, Join @@ Map[ToExpression[sym, InputForm, #] &, funvalues] =!= {}]]]; The result is a list of names (strings). Result will depend on what you \ mean by a function - my assumption was that it is any symbol that has one (or more) of the DownValues, UpValues, SubValues defined for it. You may want \ to exclude some of these properties if you need a stricter/different \ definition for what constitutes a function. Regarding the other question: check out \Programming in Mathematica\ by Roman Maeder - this is probably the best source of information on packages. Another good discussion is in the book of David Wagner (\Power \ programming with Mathematica: the kernel\), but it is out of print. There are also \ some recomendations from WRI on writing packages (one by** Todd Gayley if I am not mistaken), they can be found on MathSource (Wolfram library archive). Some other books also discuss them but in less detail (Paul Wellin et al, \Introduction to programming with Mathematica\, for instance). I may also add that I have written a few packages that deal with package construction issues such as package reloading and symbol dependencies - you may want to check them out on my web site < http://www.mathprogramming-intro.org/additional_resources.html> Hope this helps. Leonid > > a. I made a package and I want to retrieve the functions it has. What I > would want is: > Command[mypackage] > Output: functions for the user contained in myg package > > How can I do this? Somehow, I have failed to find this in the > documentation. > > b. According to you what are the best references to study the theme of > packages in Mathematica? > Francisco > > === Subject: Re: Indexed Slot in a Rule - How to do it?? Hi Alan, Using anonymous pure function semantics will probably be not the simplest way to achieve your goal. Assuming that your variables {x1,x2,etc} don't have global values (you must ensure it in your construction anyway) and \ that you know which ones and how many of them you need in advance, here is a possibility: In[1] = convertToFunction[eqs_, vars_List] := Function[Evaluate[vars], eqs]; In[2] = T = convertToFunction[{0, 5*x1, 1, 10*x3, 3*x2},{x1,x2,x3}] Out[2] = Function[{x1, x2, x3}, {0, 5 x1, 1, 10 x3, 3 x2}] In[3] = T[1, 2, 3] Out[3] = {0, 5, 1, 30, 6} This uses your variables x1, ... directly as function variables. The in the code is needed to force the binding to the variables x1,etc. Note that the syntax is slightly different - you pass a sequence \ of arguments rather than a list. If you really need slots for the anonimous function (#...), what is your application - what is it that you want to do with them? Leonid > Here's the problem. Convert a vector (list) with symbol names into > indexed slots. I'm doing this so that I can turn the vector into > function that takes a list. Here's an example of the desired > behavior: > > eqs = {0, 5*x1, 1, 10*x3, 3*x2}; > > convert this to: > > indexedeqs = {0, 5*#[[1]], 1, 10*#[[3]], 3*#[[2]]}; > > T[q_]:=indexedeqs; > > T[{1,2,3}] = {0,5,1,30,6} > > I can't for the life of me figure out how to do this. I've been > performing meta-Mathematica all week. Here's the closest I've come: > > xvars={x1,x2,x3}; > MapIndexed[Rule[#1, #[[First@#2]]] &, xvars] > > But, this treats the second # literally, and puts in the current item > from xvars. I need a way for the second # to just be # without it > really taking a value. > > So, I tried doing it as a string: > xvars={x1,x2,x3}; > MapIndexed[Rule[#1, \#[[\ <> ToString[First@#2] <> \]]\] &, xvars] > > And this creates a rule that looks correct, but, its right hand side > of the rule is a string instead of an expression. > > I can't figure this out!!! Any help is greatly appreciated. > > All the best, > Alan > > === Subject: Dependent dynamic controls I have a set of dynamic controls that should control a complicated program (omitted here). The following code works partially: initialization is not performed correctly, but afterwards everything runs as expected: aSet = {\a1\, \a2\, \a3\}; bSet = {\b1\, \b2\, \b3\}; Module[{sw = True, a, b, c, n, assign}, assign[switch_, x_] := If[switch, a = x; c = f@x; n = Position[aSet, x][[1, 1]];, b = x; c = g@x; n = Position[bSet, x][[1, 1]]]; (* Initialize *) assign[sw, First@If[sw, aSet, bSet]]; Dynamic@Panel@Column@{ (* Output *) Column@{sw, If[sw, a, b], c, n}, (* Controls *) Grid[{ {\a\, RadioButton[Dynamic[sw, (sw = #; assign[#, First@aSet]) &], True], PopupMenu[Dynamic[a, assign[sw, #] &], aSet, Enabled -> sw]}, {\b\, RadioButton[Dynamic[sw, (sw = #; assign[#, First@bSet]) &], False], PopupMenu[Dynamic[b, assign[sw, #] &], bSet, Enabled -> ! sw]} }] } ] The problem is after running the code a and b are not assigned their correct values, while after startup switching between a and b by the radiobutton, and switching values for a and b via the popupmenus work correctly. The code above is almost identical to the method used by David Park (at least three examples were posted: Although with the introduction of the switch variable 'sw', dependencies do not initialize normally. Any idea how to overcome this? Istvan Zachar === Subject: Reverse Geocoding code Periodically I use Mathematica to help with geospatial analysis. Recently, Google Maps added the ability to reverse geocode an address, that is, translate a human readable street address into the corresponding lat-long coordinates (within a reasonable degree of specificity). Here is some Mathematica code to do this: reverseGeoCode[{lat_,long_},outputType_]:= Module[{apiKey,baseURL,qAddress,qAddressFinal,finalURL,geoRes}, apiKey=\PUT YOUR KEY HERE\; qAddressFinal=StringJoin[ToString[lat],\,\,ToString[long]]; finalURL=baseURL<>\q=\<>qAddressFinal<>\&output=\<>outputType<>\&\<= >\key =\<>apiKey; geoRes=ToExpression[\{\<>Import[finalURL]<>\}\]; geoRes ]; This essentially involves converting the lat-long code to a string, then composing the appropriate URL to invoke the Google web service. This is trivial in Mathematica (I'm running v7) and, in my experience, a great way \ to highlight the power of Mathematica to my business colleages (when I'm not rotating a 3-d graphic for them!) Please note that in order to run this code, you need to have a Google-issued API Key (I've removed my key from the above code -- just replace it with yours). The keys are free and give you access to Google's online web services. I've found that performance is generally pretty good, thought Google does place a limit on how many times you can call this service during a 24 hour period (the number is around 5000 per IP Address). So if you have a large number of addresses to reverse geocode, this may not be the most efficient way to do so. Also, this works quite well for U.S. lat-long coordinates. I have not tested it for other countries. As an example: In[72]:= computeLatLong[{\100 Trade Center Drive\, \Champaign\, \IL\ ,\61820-7237\}, \csv\] Out[72]= {200, 8, 40.0971, -88.2456} For information the Google Maps API, please see: Mark S. Coleman Claims Research & Development Personal Market Claims Mark.Coleman@libertymutual.com Boston: (617) 654-4572 SDN: 8-654-4572 Portsmouth: (603) 245-5003 NOTICE: The information contained in this electronic mail transmission is intended by Liberty Mutual for the use of the named individual or entity to which it is directed and may contain information that is privileged or otherwise confidential. If you have received this electronic mail transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply e-mail or by telephone (collect), so that the sender's address records can be corrected. === Subject: Re: Perpendicular lines do not appear perpendicular Hi: I used Jens idea, PlotRangePadding->[ ]. I experimented with the values and \ used: ContourPlot[{2*x + 4*y - 6 == 0, -4*x + 2*y - 6 == 0}, {x, -4,4}, {y, -4, 4}, AspectRatio -> 1, \ PlotRangePadding -> {2.4, 1}]. This did it on my screen. The lines look perpendicular now. Bill === Subject: Re: Perpendicular lines do not appear perpendicular > Hi: > > I used Jens idea, PlotRangePadding->[ ]. I experimented with the values \ and > used: > > ContourPlot[{2*x + 4*y - 6 == 0, > -4*x + 2*y - 6 == 0}, {x, -4,4}, {y, -4, 4}, AspectRatio -> 1, > PlotRangePadding -> {2.4, 1}]. > > This did it on my screen. The lines look perpendicular now. > > > > > Bill I haven't followed this thread. Did anyone try AspectRatio -> Automatic? Cliff Nelson Dry your tears, there's more fun for your ears \Forward Into The Past\ 2 PM to 5 PM, Sundays, California time: http://www.geocities.com/forwardintothepast/ Don't be a square or a blockhead; see: http://mysite.verizon.net/cjnelson9/index.htm http://library.wolfram.com/infocenter/search/?search_results=1;search_per son_id=607 === Subject: Graphics saving nightmare Try the following function: w[\\[Alpha]_, \\[Phi]_] := Exp[\\[Alpha]^2 (I Sin[\\[Phi]/2] Cos[\\[Phi]/2] - Sin[\\[Phi]/2]^2)] Produce a 3D plot as follows: Plot3D[Abs[w[\\[Alpha], \\[Phi]]], {\\[Alpha], -5, 5}, {\\[Phi], -2 \\[Pi], 2 \\[Pi]}, ColorFunction -> \BrownCyanTones\, AxesLabel -> {\\[Alpha], \\[Phi], Abs[Subscript[A, w]]}, Ticks -> {Range[-4, 4, 2], Range[-2 \\[Pi], 2 \\[Pi], \\[Pi]], {0, 1}}] Exporting the image turns out to be much harder than one would think. Right click and Save Graphics As ... has the following effect: - EPS: Mesh polygons become visible, making the image useless - PDF: Same as above - PNG, JPG, etc: The image produced is gibberish of 1x52 pixels in size successfully. However, the polygons in PDF are extremely annoying and the save graphics function should definitely be fixed. Note: The polygons can be successfully removed from contour images with the following package: \ http://library.wolfram.com/infocenter/MathSource/7029/. This only works for contour plots, though... === Subject: Re: Graphics saving nightmare Hi Sebastian, in version 7.0.1 PDF and JPEG and BMP seem to do their job. I have not tried any other formats. Daniel > Try the following function: > w[\\[Alpha]_, \\[Phi]_] := > Exp[\\[Alpha]^2 (I Sin[\\[Phi]/2] Cos[\\[Phi]/2] - Sin[\\[Phi]/2]^2)] > > Produce a 3D plot as follows: > Plot3D[Abs[w[\\[Alpha], \\[Phi]]], {\\[Alpha], -5, 5}, {\\[Phi], -2 \ \\[Pi], > 2 \\[Pi]}, ColorFunction -> \BrownCyanTones\, > AxesLabel -> {\\[Alpha], \\[Phi], Abs[Subscript[A, w]]}, > Ticks -> {Range[-4, 4, 2], Range[-2 \\[Pi], 2 \\[Pi], \\[Pi]], {0, 1}}] > > Exporting the image turns out to be much harder than one would think. > Right click and Save Graphics As ... has the following effect: > - EPS: Mesh polygons become visible, making the image useless > - PDF: Same as above > - PNG, JPG, etc: The image produced is gibberish of 1x52 pixels in > size > > successfully. However, the polygons in PDF are extremely annoying and > the save graphics function should definitely be fixed. > > Note: The polygons can be successfully removed from contour images > with the following package: \ http://library.wolfram.com/infocenter/MathSource/7029/. > This only works for contour plots, though... > === Subject: Re: The standard deviation of Three fitting parameters is bigger \ than FindFit is not guaranteed to find a globally optimal fit, just locally. You can try various Methods for FindFit which are listed in tutorial/ UnconstrainedOptimizationIntroductionLocalMinimization In addition the Method->NMinimize can be used which is supposed to give you more globally optimal fits. Often, I construct a Manipulate function which with I fit the function interactively to my data (the sliders of the Manipulate are the parameters of the model). I use the values I obtain in that way as the starting values for the automatic fit. > I try to fit a formula, > 0.00138 t + 74.830*(t/a)^3*Integrate[(E^x x^4)/(E^x - 1)^2, {x, 0, a/ > t}] + n 3*8.314 (w/ t)^2 E^(w/ t)/(-1 + E^(w/t) )^2 > a,w,n are fitting parameters > t is indenpendt veriable > > First, I let a=375.362 to fit w and n. > FindFit[dataAl210K, {0.00138 t + 74.830*(t/375.362)^3*Integrate[(E^x > x^4)/(E^x - 1)^2, {x, 0, 375.362/t}] + n 3*8.314 (w/ t)^2 E^(w/ t)/(-1 > + E^(w/t) )^2}, {n, w},t] > I got {n -> 0.152124, w -> 1043.57} and the S.D.=0.150984 (standard > deviation) > > Then, I relax these there fitting parameters and give initial > conditions. > FindFit[dataAl210K, {0.00138 t + 74.830*(t/a)^3*NIntegrate[(E^x x^4)/ > (E^x - 1)^2, {x, 0, a/t}] > +n 3*8.314 (w/ t)^2 E^(w/ t)/(-1 + E^(w/t) )^2, {n > 0, a > 0, w > > 0}}, {{n, 0.15}, {a, 375}, {w, 1043}}, t] > Intuitively, the S.D. of three parameters should be smaller than two. > However, the S.D. of {n -> 0.904794, a -> 1921.19, w -> 259.28} is > 0.273892. > > I feel the answer is very close to the first one. > I think Mathematica may change the parameters too quickly,so the > caculation escape the local minimun of the first condition by only few > steps. > > Q:Can I constraint Mathematica to change the fitting parameters > slower? Don't escape the initial conditions I give too quickly. > (Can Nonlinearmodelfit do this?) === Subject: slightly malfunctioning Help I have 7.0 for Linux x86 (32-bit). In the last two weeks or so, when I \ type a question mark and then a command name, the usual Help message doesn't \ pop up, with the short description of the function and a link to follow to \ the full documentation. All that shows is the context and Attributes of the \ function; if I type the function name into the full Help dialogue (Help -> \ Documentation Center), that works fine. For example, ?BesselJ System`BesselJ Attributes[BesselJ]={Listable,NumericFunction,Protected} and ?FilePrint System`FilePrint Attributes[FilePrint]={Protected} However, for my OWN functions, or those of David Park, the \? \ interface\ works fine: ?ListDensityDraw ListDensityDraw[array, opts] generates the primitive graphics of a density \ plot from an array of height values. I'm quite certain that I've munged something up, perhaps in the \ Option Inspector somewhere. Does anyone have suggestions? C.O. -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 === Subject: Re: slightly malfunctioning Help -- a followup Ah. I note that closing and restarting the kernel makes the ? - command \ work again; it seems to time-out after several hours. It might be another \ time-out issue which Wolfram could look at. C.O. > > I have 7.0 for Linux x86 (32-bit). In the last two weeks or so, when I \ type a question mark and then a command name, the usual Help message doesn't \ pop up, with the short description of the function and a link to follow to \ the full documentation. All that shows is the context and Attributes of the \ function; if I type the function name into the full Help dialogue (Help -> \ Documentation Center), that works fine. > For example, > > ?BesselJ > > System`BesselJ > > Attributes[BesselJ]={Listable,NumericFunction,Protected} > > > and > > ?FilePrint > > System`FilePrint > > Attributes[FilePrint]={Protected} > > > > > However, for my OWN functions, or those of David Park, the \? \ interface\ works fine: > > ?ListDensityDraw > > ListDensityDraw[array, opts] generates the primitive graphics of a density \ plot from an array of height values. > > > I'm quite certain that I've munged something up, perhaps in the \ Option Inspector somewhere. Does anyone have suggestions? > > C.O. > -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 === Subject: Re: RandomReal gets stuck > > I agree many people including myself depend on the random > functions to be random. And I would also like Mathematica to > fail gracefully when given non-sensical input and provide useful > error messages. But I am never surprised when software does > something other than fail gracefully given non-sensical input or > provides less than useful error messages. This was perfectly good input. There is nothing wrong with it. It asks the minimum of the sum of 31 variables (which of course does not exist, but this doesn't mean that the question is mathematically incorrect, or that the input is syntactically wrong). However, the validity of this input has absolutely nothing to do with the seriousness of this bug. This is the kind of bug that is very hard to forgive because it's completely unexpected. === Subject: Re: RandomReal gets stuck By the way, Bill, there is nothing wrong with the use of square brackets to index a variable. Check out the array function: In[1]:= Array[y, 3] Out[1]= {y[1], y[2], y[3]} In[2]:= Do[y[i] = 3 - i, {i, 3}] In[3]:= ?y Global`y y[1]=2 y[2]=1 y[3]=0 In[4]:= Head[y] Out[4]= Symbol In[5]:= Head[y[1]] Out[5]= Integer Bas > >> I can confirm this bug. > >> Executing an even simpler version, namely > >> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; > >> will also set the random generator to a fixed starting point. The >> number 31 is crucial, as lower values do not appear to cause the >> bug, while higher values do. Changing Plus to Times appears to >> prevent the bug. > >> In[394]:= Table[ >> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >> RandomReal[], {20} >> ] > > When I execute the code above, I do get the same result as you > report. Clearly, there is a problem here somewhere. But it isn't > clear the issue is with RandomReal. > > The code above uses Maximize in a non-sensical way, particularly > when the function y hasn't been defined. This usage asks > Mathematica to find the maximize the sum of n things with > respect to each of the n things. It appears there is an attempt > to use the notation y[n] to mean an array indexed by n rather > than a function of n. So, Maximize correctly generates error > messages. What is unexpected is poor input to Maximize appears > to cause a problem for RandomReal. > > On my system, changing Plus to Times eliminates the effect on > RandomReal even though there is still a non-sensical input to > Maximize. Alternatively, defining y then executing the code does > > In[5]:= y[n_] := n^2 - n > > In[6]:= Table[ > Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; > RandomReal[], {20}] > > During evaluation of In[6]:= Maximize::ivar: 0 is not a valid > variable. >> > > During evaluation of In[6]:= Maximize::ivar: 0 is not a valid > variable. >> > > During evaluation of In[6]:= Maximize::ivar: 0 is not a valid > variable. >> > > During evaluation of In[6]:= General::stop: Further output of > Maximize::ivar will be suppressed during this calculation. >> > > Out[6]= \ {0.877054,0.833103,0.703786,0.0482118,0.226066,0.230746,0.0738072= > \ ,0.680963,0.53264,0.989333,0.418793,0.951114,0.963168,0.870439,0.926361,0.267\ 113,0.195084,0.810066,0.875896,0.579076} > >> This is very nasty, as a lot of people critically depend on random >> functions to be random. I would urge you to report this to wolfram >> support. > > I agree many people including myself depend on the random > functions to be random. And I would also like Mathematica to > fail gracefully when given non-sensical input and provide useful > error messages. But I am never surprised when software does > something other than fail gracefully given non-sensical input or > provides less than useful error messages. > > Entering > > Table[ > Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; > RandomReal[], > {20} > ] > > into a new session and expecting useful output simply isn't a > reasonable expectation. > > Note, this in no way says what the original poster was doing is > unreasonable or non-sensical. The rest of the information needed > to determine whether what the original poster was attempting is > sensible hasn't been provided. I would also note, that sending a > bug report to Wolfram without the additional information is > probably pointless. > > === Subject: Re: RandomReal gets stuck I know the problem can't be found in the little piece of code that I included in the first posting. For obvious reasons I didn't include all code. But I don't know of any other way to reset the random number generator than by making use of SeedRandom[] and nowhere in the notebook or mathematica session I made use of that function. Therefore, I am pretty sure that the problem is not in my code. It does seem to be related to the use of Maximize. More in particular, as Sjoerd de Vries noticed, it depends somehow on the number of variables that Maximize has to deal with. Initially random reals in my simulations appear to be random, but at some point, when the model grows (I am simulating evolving artificial economies) the random number generator starts to produce the same series of random numbers over and over again. It also doesn't matter whether or not Maximize is used non-sensical or appropriately. Below I use variables y1, ...y32, not indexed by means of square brackets, I even provide proper boundaries such that a solution exist, and still the same issue with RandomReal turns up. In[1]:= $Version Out[1]= \7.0 for Microsoft Windows (32-bit) (November 10, 2008)\ In[2]:= Table[RandomReal[], {5}] Out[2]= {0.289496, 0.40001, 0.634792, 0.389652, 0.528876} In[3]:= size = 30 Out[3]= 30 In[4]:= Maximize[ Plus @@ Table[ToExpression[\y\ <> ToString[i]], {i, size}], Map[# <= 10 &, Table[ToExpression[\y\ <> ToString[i]], {i, size}]], Table[ToExpression[\y\ <> ToString[i]], {i, size}]] Out[4]= {300, {y1 -> 10, y2 -> 10, y3 -> 10, y4 -> 10, y5 -> 10, y6 -> 10, y7 -> 10, y8 -> 10, y9 -> 10, y10 -> 10, y11 -> 10, y12 -> 10, y13 -> 10, y14 -> 10, y15 -> 10, y16 -> 10, y17 -> 10, y18 -> 10, y19 -> 10, y20 -> 10, y21 -> 10, y22 -> 10, y23 -> 10, y24 -> 10, y25 -> 10, y26 -> 10, y27 -> 10, y28 -> 10, y29 -> 10, y30 -> 10}} In[5]:= Table[RandomReal[], {5}] Out[5]= {0.911008, 0.0662658, 0.193939, 0.302682, 0.159269} In[6]:= Maximize[ Plus @@ Table[ToExpression[\y\ <> ToString[i]], {i, size}], Map[# <= 10 &, Table[ToExpression[\y\ <> ToString[i]], {i, size}]], Table[ToExpression[\y\ <> ToString[i]], {i, size}]] ; Table[RandomReal[], {5}] Out[7]= {0.121323, 0.296845, 0.0190161, 0.531837, 0.65849} In[8]:= size = 31 Out[8]= 31 In[9]:= Maximize[ Plus @@ Table[ToExpression[\y\ <> ToString[i]], {i, size}], Map[# <= 10 &, Table[ToExpression[\y\ <> ToString[i]], {i, size}]], Table[ToExpression[\y\ <> ToString[i]], {i, size}]] Out[9]= {310, {y1 -> 10, y2 -> 10, y3 -> 10, y4 -> 10, y5 -> 10, y6 -> 10, y7 -> 10, y8 -> 10, y9 -> 10, y10 -> 10, y11 -> 10, y12 -> 10, y13 -> 10, y14 -> 10, y15 -> 10, y16 -> 10, y17 -> 10, y18 -> 10, y19 -> 10, y20 -> 10, y21 -> 10, y22 -> 10, y23 -> 10, y24 -> 10, y25 -> 10, y26 -> 10, y27 -> 10, y28 -> 10, y29 -> 10, y30 -> 10, y31 -> 10}} In[10]:= Table[RandomReal[], {5}] Out[10]= {0.455719, 0.977826, 0.943215, 0.962216, 0.302348} In[11]:= Maximize[ Plus @@ Table[ToExpression[\y\ <> ToString[i]], {i, size}], Map[# <= 10 &, Table[ToExpression[\y\ <> ToString[i]], {i, size}]], Table[ToExpression[\y\ <> ToString[i]], {i, size}]] ; Table[RandomReal[], {5}] Out[12]= {0.455719, 0.977826, 0.943215, 0.962216, 0.302348} In[13]:= size = 32 Out[13]= 32 In[14]:= Maximize[ Plus @@ Table[ToExpression[\y\ <> ToString[i]], {i, size}], Map[# <= 10 &, Table[ToExpression[\y\ <> ToString[i]], {i, size}]], Table[ToExpression[\y\ <> ToString[i]], {i, size}]] Out[14]= {320, {y1 -> 10, y2 -> 10, y3 -> 10, y4 -> 10, y5 -> 10, y6 -> 10, y7 -> 10, y8 -> 10, y9 -> 10, y10 -> 10, y11 -> 10, y12 -> 10, y13 -> 10, y14 -> 10, y15 -> 10, y16 -> 10, y17 -> 10, y18 -> 10, y19 -> 10, y20 -> 10, y21 -> 10, y22 -> 10, y23 -> 10, y24 -> 10, y25 -> 10, y26 -> 10, y27 -> 10, y28 -> 10, y29 -> 10, y30 -> 10, y31 -> 10, y32 -> 10}} In[15]:= Table[RandomReal[], {5}] Out[15]= {0.455719, 0.977826, 0.943215, 0.962216, 0.302348} In[16]:= Maximize[ Plus @@ Table[ToExpression[\y\ <> ToString[i]], {i, size}], Map[# <= 10 &, Table[ToExpression[\y\ <> ToString[i]], {i, size}]], Table[ToExpression[\y\ <> ToString[i]], {i, size}]] ; Table[RandomReal[], {5}] Out[17]= {0.455719, 0.977826, 0.943215, 0.962216, 0.302348} I received an email from from Daniel Lichtblau (Wolfram Research) that it probably is a bug, I have sent him the above example and hope that it gets sorted out quickly. Bas > >> I can confirm this bug. > >> Executing an even simpler version, namely > >> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; > >> will also set the random generator to a fixed starting point. The >> number 31 is crucial, as lower values do not appear to cause the >> bug, while higher values do. Changing Plus to Times appears to >> prevent the bug. > >> In[394]:= Table[ >> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >> RandomReal[], {20} >> ] > > When I execute the code above, I do get the same result as you > report. Clearly, there is a problem here somewhere. But it isn't > clear the issue is with RandomReal. > > The code above uses Maximize in a non-sensical way, particularly > when the function y hasn't been defined. This usage asks > Mathematica to find the maximize the sum of n things with > respect to each of the n things. It appears there is an attempt > to use the notation y[n] to mean an array indexed by n rather > than a function of n. So, Maximize correctly generates error > messages. What is unexpected is poor input to Maximize appears > to cause a problem for RandomReal. > > On my system, changing Plus to Times eliminates the effect on > RandomReal even though there is still a non-sensical input to > Maximize. Alternatively, defining y then executing the code does > > In[5]:= y[n_] := n^2 - n > > In[6]:= Table[ > Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; > RandomReal[], {20}] > > During evaluation of In[6]:= Maximize::ivar: 0 is not a valid > variable. >> > > During evaluation of In[6]:= Maximize::ivar: 0 is not a valid > variable. >> > > During evaluation of In[6]:= Maximize::ivar: 0 is not a valid > variable. >> > > During evaluation of In[6]:= General::stop: Further output of > Maximize::ivar will be suppressed during this calculation. >> > > Out[6]= \ {0.877054,0.833103,0.703786,0.0482118,0.226066,0.230746,0.0738072= > \ ,0.680963,0.53264,0.989333,0.418793,0.951114,0.963168,0.870439,0.926361,0.267\ 113,0.195084,0.810066,0.875896,0.579076} > >> This is very nasty, as a lot of people critically depend on random >> functions to be random. I would urge you to report this to wolfram >> support. > > I agree many people including myself depend on the random > functions to be random. And I would also like Mathematica to > fail gracefully when given non-sensical input and provide useful > error messages. But I am never surprised when software does > something other than fail gracefully given non-sensical input or > provides less than useful error messages. > > Entering > > Table[ > Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; > RandomReal[], > {20} > ] > > into a new session and expecting useful output simply isn't a > reasonable expectation. > > Note, this in no way says what the original poster was doing is > unreasonable or non-sensical. The rest of the information needed > to determine whether what the original poster was attempting is > sensible hasn't been provided. I would also note, that sending a > bug report to Wolfram without the additional information is > probably pointless. > > === Subject: Re: RandomReal gets stuck On May 31, 1:33 pm, \Sjoerd C. de Vries\ > Hi Bas, > > I can confirm this bug. > > Executing an even simpler version, namely > > Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; > > will also set the random generator to a fixed starting point. The > number 31 is crucial, as lower values do not appear to cause the bug, > while higher values do. Changing Plus to Times appears to prevent the > bug. > > In[394]:= Table[ > Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; > RandomReal[], > {20} > ] > > During evaluation of In[394]:= Maximize::natt: The maximum is not > attained at any point satisfying the given constraints. >> > > Out[394]= {0.455719, 0.455719, 0.455719, 0.455719, 0.455719, \\ > 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, > \\ > 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, > \\ > 0.455719} > > This is very nasty, as a lot of people critically depend on random > functions to be random. I would urge you to report this to wolfram > support. > The problem is present both in version 6.0.3 and version 7.0.1. === Subject: Re: RandomReal gets stuck Not in version 5.2, (it doesn't have RandomReal but it has the old Random). That's what I am using now until a new release comes out. Wolfram Research has confirmed that the new release will have this bug fixed. Bas > On May 31, 1:33 pm, \Sjoerd C. de Vries\ >> Hi Bas, >> >> I can confirm this bug. >> >> Executing an even simpler version, namely >> >> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >> >> will also set the random generator to a fixed starting point. The >> number 31 is crucial, as lower values do not appear to cause the bug, >> while higher values do. Changing Plus to Times appears to prevent the >> bug. >> >> In[394]:= Table[ >> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >> RandomReal[], >> {20} >> ] >> >> During evaluation of In[394]:= Maximize::natt: The maximum is not >> attained at any point satisfying the given constraints. >> >> >> Out[394]= {0.455719, 0.455719, 0.455719, 0.455719, 0.455719, \\ >> 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, >> \\ >> 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, >> \\ >> 0.455719} >> >> This is very nasty, as a lot of people critically depend on random >> functions to be random. I would urge you to report this to wolfram >> support. >> > > The problem is present both in version 6.0.3 and version 7.0.1. > === Subject: Re: How to handle Units of Measure On 29 Mag, 01:33, \Sjoerd C. de Vries\ > May I ask you how you would enter such a calculation on a simple > calculator? You only use the numbers, taking care that they're based > on comparableunits(so not to add grams and kilograms etc.). > > In Mathematica you do the same. > > If you want to do unit conversions there is the Unitspackage that > you read in using > > Needs[\Units`\] > > In this package the function Convert will do unit conversions. > > > > > In this very simple example if I write > > R+iwL > > where R is measured in Ohms, w in s^-1, L in H, I expect that the > > result is given in Ohms. > > Why it doesn't happen in Mathematica ? Ho can I do to handle in a > > simple way those conversions ? It is considered unfair, in this Group, to make comparisons with other products. So I shall avoid doing so ... Anyway: anyone having made some non trivial calculation in Physics appreciates the error checking provided by a suitable dimensional check. Why in Mathematica this is so cumbersome ? Has anyone tried to do my calculation (a very simple example of a much more complicated problem ...): Needs[\Units`\] X = 1 Ohm + 1 Hertz * 1 Henry X I should get 2 Ohm. Why not ? If I write Convert[X, Ohm] I get the correct result, however not always the target U.M. is easy to get. === Subject: Speeding up code Hello all, I need some advise on speeding up code. Here is a section that is executed \ more than 100000 times during my simulations. Currently it takes about 0.06s per execution which is about 80% of the total time for the simulation. The subsection MITime itself takes 0.03s out of those 0.06s. All variables not defined in this section are predefined. Anyone have suggestions? MDTime = First[ Timing[ yps = Table[(ys[[i]] + ys[[i - 1]])/2, {i, 2, ngrid}]; yms = Table[(ys[[i]] - ys[[i - 1]]), {i, 2, ngrid}]; ups = Table[(us[[i]] + us[[i - 1]])/2, {i, 2, ngrid}]; ums = Table[(us[[i]] - us[[i - 1]]), {i, 2, ngrid}]; Etus = Table[rrms[[i]]*Exp[-ups[[i]]], {i, 1, ngrid - 1}]; (*Etu2s=Table[Exp[-ups[[i]]/2],{i,1,ngrid-1}];*) SqEts = Table[ rrpms[[i]]*sqrrs[[i]]*Exp[-ups[[i]]/2]*acubed*rba, {i, 1, ngrid - 1}]; ElemEIEI = Table[N[SqEts[[i]]/4, Precis], {i, ngrid - 1}]; ElemOIOI = Table[N[-Etus[[i]]/2, Precis], {i, ngrid - 1}]; ElemOIOI1 = Table[N[yps[[i]]*Etus[[i]]/2, Precis], {i, ngrid - 1}]; Es[[ngrid*nvar]] = N[Exp[us[[ngrid]]] - rrs[[ngrid]], Precis]; Es[[1]] = Exp[us[[1]]] - rrs[[1]]*ys[[1]]; For[i = 1, i <= ngrid - 1, i++, Es[[nvar*i]] = N[yms[[i]] + Yds[[i]] - SqEts[[i]], Precis]; Es[[nvar*i + 1]] = N[ums[[i]] - yps[[i]]*Etus[[i]], Precis]; ]; (* Table of rules used to create the Sms matrix*) MITime = First[ Timing[ DataSAP = Join[ Table[{nvar*i, nvar*(i - 1) + 1} -> N[-1., Precis], {i, ngrid - 1}], Table[{nvar*i, nvar*(i - 1) + 2} -> ElemEIEI[[i]], {i, ngrid - 1}], Table[{nvar*i, nvar*(i - 1) + 3} -> N[1., Precis], {i, ngrid - 1}], Table[{nvar*i, nvar*(i - 1) + 4} -> ElemEIEI[[i]], {i, ngrid - 1}], Table[{nvar*i + 1, nvar*(i - 1) + 1} -> ElemOIOI[[i]], {i, ngrid - 1}], Table[{nvar*i + 1, nvar*(i - 1) + 2} -> ElemOIOI1[[i]] - 1., {i, ngrid - 1}], Table[{nvar*i + 1, nvar*(i - 1) + 3} -> ElemOIOI[[i]], {i, ngrid - 1}], Table[{nvar*i + 1, nvar*(i - 1) + 4} -> ElemOIOI1[[i]] + 1., {i, ngrid - 1}]] ] ]; DataSA = Prepend[DataSAP, {1, 2} -> N[Exp[us[[1]]], Precis]]; DataSA = Prepend[DataSA, {nvg, nvg} -> N[Exp[us[[ngrid]]], Precis]]; DataSA = Prepend[DataSA, {1, 1} -> N[-rrs[[1]], Precis]]; Sms = SparseArray[DataSA]; ] ]; Alexander === Subject: Re: Speeding up code Hi Alexander, see below, Daniel > Hello all, > > > I need some advise on speeding up code. Here is a section that is executed \ more > than 100000 times during my simulations. Currently it takes about 0.06s \ per > execution which is about 80% of the total time for the simulation. The > subsection MITime itself takes 0.03s out of those 0.06s. All variables \ not > defined in this section are predefined. Anyone have suggestions? > > MDTime = First[ > Timing[ > yps = Table[(ys[[i]] + ys[[i - 1]])/2, {i, 2, ngrid}]; this can be written: yps= Differences[ys]/2 > yms = Table[(ys[[i]] - ys[[i - 1]]), {i, 2, ngrid}]; > ups = Table[(us[[i]] + us[[i - 1]])/2, {i, 2, ngrid}]; > ums = Table[(us[[i]] - us[[i - 1]]), {i, 2, ngrid}]; > Etus = Table[rrms[[i]]*Exp[-ups[[i]]], {i, 1, ngrid - 1}]; > (*Etu2s=Table[Exp[-ups[[i]]/2],{i,1,ngrid-1}];*) > > SqEts = Table[ > rrpms[[i]]*sqrrs[[i]]*Exp[-ups[[i]]/2]*acubed*rba, {i, 1, > ngrid - 1}]; this can be written: SqEts= rrpms sqrrs Exp[-ups/2] acubed rba > ElemEIEI = Table[N[SqEts[[i]]/4, Precis], {i, ngrid - 1}]; > ElemOIOI = Table[N[-Etus[[i]]/2, Precis], {i, ngrid - 1}]; > ElemOIOI1 = > Table[N[yps[[i]]*Etus[[i]]/2, Precis], {i, ngrid - 1}]; > Es[[ngrid*nvar]] = N[Exp[us[[ngrid]]] - rrs[[ngrid]], Precis]; > Es[[1]] = Exp[us[[1]]] - rrs[[1]]*ys[[1]]; > For[i = 1, i <= ngrid - 1, i++, > Es[[nvar*i]] = N[yms[[i]] + Yds[[i]] - SqEts[[i]], Precis]; > Es[[nvar*i + 1]] = N[ums[[i]] - yps[[i]]*Etus[[i]], Precis]; > ]; the loop can be written: Es[[nvar Range[ngrid-1]]]= N[yms + Yds - SqEts, Precis] Es[[nvar Range[ngrid-1]+1]]= N[ums - yps Etus, Precis] > (* Table of rules used to create the Sms matrix*) > > MITime = First[ > Timing[ > DataSAP = Join[ > Table[{nvar*i, nvar*(i - 1) + 1} -> N[-1., Precis], {i, > ngrid - 1}], this can be written: Thread[Transpose[{nvar*Range[ngrid-1], nvar*(Range[ngrid-1] - 1) + 1}] -> N[-1., Precis]] > Table[{nvar*i, nvar*(i - 1) + 2} -> ElemEIEI[[i]], {i, > ngrid - 1}], this can be written: Thread[Transpose[{nvar*Range[ngrid-1], nvar*(Range[ngrid-1] - 1) + 1}] -> ElemEIEI] > Table[{nvar*i, nvar*(i - 1) + 3} -> N[1., Precis], {i, > ngrid - 1}], > Table[{nvar*i, nvar*(i - 1) + 4} -> ElemEIEI[[i]], {i, > ngrid - 1}], > Table[{nvar*i + 1, nvar*(i - 1) + 1} -> ElemOIOI[[i]], {i, > ngrid - 1}], > Table[{nvar*i + 1, nvar*(i - 1) + 2} -> > ElemOIOI1[[i]] - 1., {i, ngrid - 1}], > Table[{nvar*i + 1, nvar*(i - 1) + 3} -> ElemOIOI[[i]], {i, > ngrid - 1}], > Table[{nvar*i + 1, nvar*(i - 1) + 4} -> > ElemOIOI1[[i]] + 1., {i, ngrid - 1}]] > ] > ]; > DataSA = Prepend[DataSAP, {1, 2} -> N[Exp[us[[1]]], Precis]]; > DataSA = > Prepend[DataSA, {nvg, nvg} -> N[Exp[us[[ngrid]]], Precis]]; > DataSA = Prepend[DataSA, {1, 1} -> N[-rrs[[1]], Precis]]; > Sms = SparseArray[DataSA]; > ] > ]; > > > > Alexander > === Subject: Re: Speeding up code > Hello all, > > I need some advise on speeding up code. Here is a section that is executed \ more > than 100000 times during my simulations. Currently it takes about 0.06s \ per > execution which is about 80% of the total time for the simulation. The > subsection MITime itself takes 0.03s out of those 0.06s. All variables \ not > defined in this section are predefined. Anyone have suggestions? > > MDTime = First[ > Timing[ > yps = Table[(ys[[i]] + ys[[i - 1]])/2, {i, 2, ngrid}]; > yms = Table[(ys[[i]] - ys[[i - 1]]), {i, 2, ngrid}]; > ups = Table[(us[[i]] + us[[i - 1]])/2, {i, 2, ngrid}]; > ums = Table[(us[[i]] - us[[i - 1]]), {i, 2, ngrid}]; > Etus = Table[rrms[[i]]*Exp[-ups[[i]]], {i, 1, ngrid - 1}]; > (*Etu2s=Table[Exp[-ups[[i]]/2],{i,1,ngrid-1}];*) > > SqEts = Table[ > rrpms[[i]]*sqrrs[[i]]*Exp[-ups[[i]]/2]*acubed*rba, {i, 1, > ngrid - 1}]; > ElemEIEI = Table[N[SqEts[[i]]/4, Precis], {i, ngrid - 1}]; > ElemOIOI = Table[N[-Etus[[i]]/2, Precis], {i, ngrid - 1}]; > ElemOIOI1 = > Table[N[yps[[i]]*Etus[[i]]/2, Precis], {i, ngrid - 1}]; > Es[[ngrid*nvar]] = N[Exp[us[[ngrid]]] - rrs[[ngrid]], Precis]; > Es[[1]] = Exp[us[[1]]] - rrs[[1]]*ys[[1]]; > For[i = 1, i <= ngrid - 1, i++, > Es[[nvar*i]] = N[yms[[i]] + Yds[[i]] - SqEts[[i]], Precis]; > Es[[nvar*i + 1]] = N[ums[[i]] - yps[[i]]*Etus[[i]], Precis]; > ]; > (* Table of rules used to create the Sms matrix*) > > MITime = First[ > Timing[ > DataSAP = Join[ > Table[{nvar*i, nvar*(i - 1) + 1} -> N[-1., Precis], {i, > ngrid - 1}], > Table[{nvar*i, nvar*(i - 1) + 2} -> ElemEIEI[[i]], {i, > ngrid - 1}], > Table[{nvar*i, nvar*(i - 1) + 3} -> N[1., Precis], {i, > ngrid - 1}], > Table[{nvar*i, nvar*(i - 1) + 4} -> ElemEIEI[[i]], {i, > ngrid - 1}], > Table[{nvar*i + 1, nvar*(i - 1) + 1} -> ElemOIOI[[i]], {i, > ngrid - 1}], > Table[{nvar*i + 1, nvar*(i - 1) + 2} -> > ElemOIOI1[[i]] - 1., {i, ngrid - 1}], > Table[{nvar*i + 1, nvar*(i - 1) + 3} -> ElemOIOI[[i]], {i, > ngrid - 1}], > Table[{nvar*i + 1, nvar*(i - 1) + 4} -> > ElemOIOI1[[i]] + 1., {i, ngrid - 1}]] > ] > ]; > DataSA = Prepend[DataSAP, {1, 2} -> N[Exp[us[[1]]], Precis]]; > DataSA = > Prepend[DataSA, {nvg, nvg} -> N[Exp[us[[ngrid]]], Precis]]; > DataSA = Prepend[DataSA, {1, 1} -> N[-rrs[[1]], Precis]]; > Sms = SparseArray[DataSA]; > ] > ]; > > Alexander 1. Avoid \growing\ the DataSA list using Prepend: this is in general a bad way to do it. It looks like you could just bring those last couple of operations inside the Join. 2. Try using Compile: this is useful for cases where you are doing many simple operations. 3. (Possibly the most important but requires a bit more thought): it helps a lot if you vectorize your code. That is, instead of something like (the following is a trivial example): x = Table[y[[i]] + z[[i]], {i, n}] use x = y + z Depending on how many elements of the arrays you are accessing, you may need to use functions like Take, Drop, Most, Rest, Cases, Select, etc. If you can formulate your calculation in vector form it is likely to be close to optimal since Mathematica's built-in list operations are highly optimized. === Subject: Re: Speeding up code >> Hello all, >> >> I need some advise on speeding up code. Here is a section that is \ executed more >> than 100000 times during my simulations. Currently it takes about 0.06s \ per >> execution which is about 80% of the total time for the simulation. The >> subsection MITime itself takes 0.03s out of those 0.06s. All variables \ not >> defined in this section are predefined. Anyone have suggestions? >> >> MDTime = First[ >> Timing[ >> yps = Table[(ys[[i]] + ys[[i - 1]])/2, {i, 2, ngrid}]; >> yms = Table[(ys[[i]] - ys[[i - 1]]), {i, 2, ngrid}]; >> ups = Table[(us[[i]] + us[[i - 1]])/2, {i, 2, ngrid}]; >> ums = Table[(us[[i]] - us[[i - 1]]), {i, 2, ngrid}]; >> Etus = Table[rrms[[i]]*Exp[-ups[[i]]], {i, 1, ngrid - 1}]; >> (*Etu2s=Table[Exp[-ups[[i]]/2],{i,1,ngrid-1}];*) >> >> SqEts = Table[ >> rrpms[[i]]*sqrrs[[i]]*Exp[-ups[[i]]/2]*acubed*rba, {i, 1, >> ngrid - 1}]; >> ElemEIEI = Table[N[SqEts[[i]]/4, Precis], {i, ngrid - 1}]; >> ElemOIOI = Table[N[-Etus[[i]]/2, Precis], {i, ngrid - 1}]; >> ElemOIOI1 = >> Table[N[yps[[i]]*Etus[[i]]/2, Precis], {i, ngrid - 1}]; >> Es[[ngrid*nvar]] = N[Exp[us[[ngrid]]] - rrs[[ngrid]], Precis]; >> Es[[1]] = Exp[us[[1]]] - rrs[[1]]*ys[[1]]; >> For[i = 1, i <= ngrid - 1, i++, >> Es[[nvar*i]] = N[yms[[i]] + Yds[[i]] - SqEts[[i]], Precis]; >> Es[[nvar*i + 1]] = N[ums[[i]] - yps[[i]]*Etus[[i]], Precis]; >> ]; >> (* Table of rules used to create the Sms matrix*) >> >> MITime = First[ >> Timing[ >> DataSAP = Join[ >> Table[{nvar*i, nvar*(i - 1) + 1} -> N[-1., Precis], {i, >> ngrid - 1}], >> Table[{nvar*i, nvar*(i - 1) + 2} -> ElemEIEI[[i]], {i, >> ngrid - 1}], >> Table[{nvar*i, nvar*(i - 1) + 3} -> N[1., Precis], {i, >> ngrid - 1}], >> Table[{nvar*i, nvar*(i - 1) + 4} -> ElemEIEI[[i]], {i, >> ngrid - 1}], >> Table[{nvar*i + 1, nvar*(i - 1) + 1} -> ElemOIOI[[i]], {i, >> ngrid - 1}], >> Table[{nvar*i + 1, nvar*(i - 1) + 2} -> >> ElemOIOI1[[i]] - 1., {i, ngrid - 1}], >> Table[{nvar*i + 1, nvar*(i - 1) + 3} -> ElemOIOI[[i]], {i, >> ngrid - 1}], >> Table[{nvar*i + 1, nvar*(i - 1) + 4} -> >> ElemOIOI1[[i]] + 1., {i, ngrid - 1}]] >> ] >> ]; >> DataSA = Prepend[DataSAP, {1, 2} -> N[Exp[us[[1]]], Precis]]; >> DataSA = >> Prepend[DataSA, {nvg, nvg} -> N[Exp[us[[ngrid]]], Precis]]; >> DataSA = Prepend[DataSA, {1, 1} -> N[-rrs[[1]], Precis]]; >> Sms = SparseArray[DataSA]; >> ] >> ]; >> >> Alexander > > > 1. Avoid \growing\ the DataSA list using Prepend: this is in general a > bad way to do it. It looks like you could just bring those last couple > of operations inside the Join. > > 2. Try using Compile: this is useful for cases where you are doing > many simple operations. > > 3. (Possibly the most important but requires a bit more thought): it > helps a lot if you vectorize your code. That is, instead of something > like (the following is a trivial example): > > x = Table[y[[i]] + z[[i]], {i, n}] > > use > > x = y + z > > Depending on how many elements of the arrays you are accessing, you > may need to use functions like Take, Drop, Most, Rest, Cases, Select, > etc. > > If you can formulate your calculation in vector form it is likely to > be close to optimal since Mathematica's built-in list operations are > highly optimized. > Adding to those suggestions, we never got to see the original data that this code operates on. If at all possible, arrays should be of just one type - e.g. Real - and if this is appropriate, it might help to apply N to these arrays to make sure this is so. This will be particularly relevant if you are able to follow Pfalloon's suggestion to vectorise your code. Unfortunately, optimising code is a fairly tricky process, because it is all too easy to optimise the wrong part of the code - so even though you sped it up, it only ever accounted for 1% of the total run time, and you don't see any improvement... David Bailey http://www.dbaileyconsultancy.co.uk === Subject: proper way of posing a non-autonomous ode in mathematica? Hello group, I was trying to solve a simple ODE system that has parameters that are functions of time. Then I thought about it and I'm not sure if I'm doing it right. Let's say your system is a = -k1 (t^-h) -k2 (t^-h) b b = k1 (t) a Then in mathematica, a'[t] == - k1 (t ^-h) a[t] - k2 (t ^-h) b[t], b'[t] == k1 (t ^-h) a[t] which is solvable. but if I pose the k1 and k2 as a function of t, like k1[t^-h] and k2 [t^-h] Then the system becomes under-determined with 4 unknowns and 2 eqns... So my question is how do you pose/solve a non-autonomous ode in mathematica? Sean === Subject: Re: proper way of posing a non-autonomous ode in mathematica? Hi Sean, see below, Daniel > Hello group, > > I was trying to solve a simple ODE system that has parameters that are > functions of time. Then I thought about it and I'm not sure if I'm > doing it right. > > Let's say your system is > > a = -k1 (t^-h) -k2 (t^-h) b > b = k1 (t) a > > Then in mathematica, > > a'[t] == - k1 (t ^-h) a[t] - k2 (t ^-h) b[t], > b'[t] == k1 (t ^-h) a[t] here k1 and k2 seem to be known > > which is solvable. > > but if I pose the k1 and k2 as a function of t, like k1[t^-h] and k2 > [t^-h] > > Then the system becomes under-determined with 4 unknowns and 2 > eqns... now, k1 and k2 seem to be unknown functions. Therefore, you need 2 more equations. > > So my question is how do you pose/solve a non-autonomous ode in > mathematica? > > > Sean > > > > > === Subject: Re: String as a variable name > the only way around this is using the third argument of ToExpression just for completeness, there is another way: assignToNameStr[name_String, value_] := ToExpression[\Set[\ <> name <> \,\ <> ToString[FullForm[value]] <> \ \]\]; However, the solution of Szabolcs is preferable in several ways. My \ feeling is that while the string representation is sometimes a useful trick, generally the ToString-ToExpression cycles should be avoided whenever possible. Leonid > This is not going to work if variable1 already has a value. Because > of how Mathematica evaluates expressions, the only way around this is > using the third argument of ToExpression: > > assignToName[name_String, value_] := > ToExpression[name, InputForm, Function[var, var = value, HoldAll]] > > Assign 1 to variable1 > > assignToName[\variable\ <> \1\, 1] > > However, whenever one feels the need to use something like this, it's > worth thinking over if variable[1] = 1 would work in its stead. It's > simpler and safer. > > === Subject: Re: Min function returns Min[2.05875,] instead of just 2.05875 >I have an matrix \data\ with 17x248 real numbers. >When I enter Min[data], I get Min[2.05875, ] as a result, instead >of just the number 2.05875. >This is Mathematica 7.0.1 on Mac OS X. >Why? There is at least one entry in your matrix that does not have a numeric value. Quite likely, this is a Null. This can happen when you read data in from a CSV file using Import and there is an extra comma somewhere. You can verify this to be the case by doing Union[Head/@Flatten[data]] >How can I get just the number from the result? Obviously, the best choice would be to fix the problem of a non-numeric entry. However, the numeric value can be extracted in a number of ways such as In[2]:= Cases[List @@ Min[2.05875,], _?NumericQ][[1]] Out[2]= 2.05875 === Subject: Re: How can I get the previous Fibonacci calculated Fibonacci number is not restricted to Integer arguments Fibonacci[Pi] // N 2.11703 Fibonacci[Pi] == Fibonacci[Pi - 1] + Fibonacci[Pi - 2] // FullSimplify True prevFib[x_] := Module[{m, n, x2}, x2 = SetPrecision[x, 120]; If[x > 10^15, N[x/GoldenRatio], m = (n /. FindRoot[Fibonacci[n] - x2 == 0, {n, 100}, WorkingPrecision -> 100]) - 1; If[Abs[m - Round[m]] < 10^-10, Fibonacci[Round[m]], N[Fibonacci[m]]]]] Table[x = 10^n*Pi; prevFib[Fibonacci[x]] == Fibonacci[x - 1], {n, 0, 2}] {True,True,True} Fibonacci is not even restricted to real arguments, although prevFib will \ not handle complex arguments. Fibonacci[Pi + E*I] // N -45.13963322822449 - 246.04041318893496*I Fibonacci[Pi + E*I] == Fibonacci[Pi + E*I - 1] + Fibonacci[Pi + E*I - 2] // FullSimplify True Bob Hanlon > prevFib[x_] := Module[{m, n, x2}, > x2 = SetPrecision[x, 100]; > If[x > 10^15, > N[x/GoldenRatio], > m = (n /. FindRoot[Fibonacci[n] - x2 == 0, {n, 100}, > WorkingPrecision -> 100]) - 1; > If[Abs[m - Round[m]] < 10^-10, > Fibonacci[Round[m]], > N[Fibonacci[m]]]]] > > prevFib[13] > > 8 > > prevFib[Fibonacci[50]] == Fibonacci[49] > > True > > prevFib[Fibonacci[10000]] == Fibonacci[9999] > > True > > prevFib[Fibonacci[20000]] == Fibonacci[19999] > > True > > prevFib[234.34*^10] > > 1.4483008492365037*^12 But that's not a Fibonacci number! I suggest In[7]:= n = 234.34*^10; inv = Round[Log[GoldenRatio, Sqrt[(Sqrt[5]*n + Sqrt[5*n^2 - 4])* (Sqrt[5]*n + Sqrt[5*n^2 + 4])]/2]]; Fibonacci[inv - 1] Out[7]= 1548008755920 I am guessing that the OP actually wants to find the Fibonacci number which immediately precedes a given _Fibonacci number_. If that guess is correct, that is, if n is actually supposed to be a Fibonacci number, then my inv will always work correctly for n >= 2. But CAUTION: If n is not a Fibonacci number, then my method may give an incorrect answer. In the example, 234.34*^10 is not a Fibonacci number and so there was no guarantee that my method would give the correct result, although it happened to do so. David W. Cantrell > > > How can I get a previous Fibonacci calculated number in a specific > range. I can calculate the previous number of phi see below > > phi1 =(1+sqrt(5))/2 > > 13/phi1 > > I tested it with 13 and got 8.034441857 .....so that works > > but how can I get only the previous numbers of Fibonacci in a > specified range from 20 to 20000 if I input a large number like > 234.34e10 > > tia sal2 -- Bob Hanlon === Subject: Re: Min function returns Min[2.05875,] instead of just Your data appears to be corrupted. data = RandomReal[{0, 5}, {5, 3}]; Min[data] 0.540688 Corrupting the data by deleting a few values data = {{1.5733129712493588, , 4.207662286059996}, {2.65404709124369, 1.533889203301964, 3.8413829848717214}, {1.3250162293559766, 2.3368229647740275, 1.1694572447354092}, {4.292811846441872, , 1.498928361724178}, {0.5406878915086155, 3.971746766033478, 1.0284392955190462}}; Min[data] min(0.540688,Null) Eliminate Nulls Min[(data // Flatten) /. Null :> Sequence[]] 0.540688 Or more generally, use only numeric values Min[Cases[data // Flatten, _?NumericQ]] 0.540688 Try this latter method with your data Bob Hanlon I have an matrix \data\ with 17x248 real numbers. When I enter Min[data], I get Min[2.05875, ] as a result, instead of just the number 2.05875. This is Mathematica 7.0.1 on Mac OS X. Why? How can I get just the number from the result? TIA === Subject: Re: 100,000 posts! Coming to the party somewhat late... Congrats Steve! As for John's Fultz's comments, I am very grateful for the time on and off list he has helped me to fully enjoy using and learning Mathematica. In my past experience, being disabled often means people first consider me rather negatively both in my body and mind; hence, getting the chance and tools to empower me to explore and develop my talents/skills/dreams are usually withheld or denied. John (and others on the list) has shown a deeper truth about Math: its about trying to solve a problem -- sometimes together -- not about the person. I was respected for my quest to solve Gui problems not anything else personally and be trusted to handle clues as much a newbie could (and am still studying)!. And finally, it is a testament of the hard work done for version 7 that allows me to do math after 25 years and 8 the > benefits of his work that may not be obvious to a lot of people. Steve= has > provided a unique area where Wolfram staffers and Mathematica users can \ c= ommune. > This not only pushes more information out of the company and into the \ han= ds of > users, it also directly impacts the development directions the company \ an= d its > developers choose to take Mathematica in. > > I've talked to several people from Wolfram who post here. Most have ve= ry > little time. They read this forum and post to it in their free time, n= ot as a > requirement (or even recommendation) of their job description. Without= an > environment which promotes the kind of civil and almost uniquely > Mathematica-focused discourse that goes on here, most would have found \ be= tter > uses for their time. > > Here, people with questions can feel safe to ask them without being \ haras= sed or > insulted by so-called experts. Experts (both in and outside of Wolfram= ) can > feel safe to answer questions without the need to defend themselves from \ = the > typical partisanship, brinksmanship, and general childishness which \ resul= ts in > something like Godwin's Law being accepted as an inevitable part of \ Inter= net > discourse. Occasionally, people have expressed concern that moderation= has > stifled conversation. On the contrary, I claim; it enables conversatio= ns which > would never, ever happen in the presence of your typical Internet > rabble-rousers. > > Speaking as a developer, I have two primary ways to interact directly \ wit= h > users. One is the annual Wolfram conference, which only lets me talk w= ith > a very narrow slice of users and for only four days a year. The other = is this > forum. I've learned a lot here about how people use Mathematica, and t= hat > knowledge feeds back into the product. Wolfram has a fine crew of tech= nical > support and sales people who are on the front line with customers, but \ th= ings > inevitably get muffled by the time they reach developers...just as in the > child's game of Telephone. Here, we hear you loud and clear. > > > > John Fultz > jfu...@wolfram.com > User Interface Group > Wolfram Research, Inc. === Subject: Re: Indexed Slot in a Rule - How to do it?? Here's the problem. Convert a vector (list) with symbol names into indexed slots. I'm doing this so that I can turn the vector into function that takes a list. Here's an example of the desired behavior: eqs = {0, 5*x1, 1, 10*x3, 3*x2}; convert this to: indexedeqs = {0, 5*#[[1]], 1, 10*#[[3]], 3*#[[2]]}; T[q_]:=indexedeqs; T[{1,2,3}] = {0,5,1,30,6} I can't for the life of me figure out how to do this. I've been performing meta-Mathematica all week. Here's the closest I've come: xvars={x1,x2,x3}; MapIndexed[Rule[#1, #[[First@#2]]] &, xvars] But, this treats the second # literally, and puts in the current item from xvars. I need a way for the second # to just be # without it really taking a value. So, I tried doing it as a string: xvars={x1,x2,x3}; MapIndexed[Rule[#1, \#[[\ <> ToString[First@#2] <> \]]\] &, xvars] And this creates a rule that looks correct, but, its right hand side of the rule is a string instead of an expression. I can't figure this out!!! Any help is greatly appreciated. All the best, Alan try one of these two ways: In[10]:= T1[q_List] := {0, 5*q[[1]], 1, 10*q[[3]], 3*q[[2]]}; T1[{1, 2, 3}] Out[4]= {0, 5, 1, 30, 6} In[7]:= T2 := {0, 5*#[[1]], 1, 10*#[[3]], 3*#[[2]]} &; In[9]:= T2[{1, 2, 3}] Out[9]= {0, 5, 1, 30, 6} Best, Alexei -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Re: comments on Wolfram Alpha > letters fit better as direct feedback to Wolfram or as letters to the > WolframAlpha Community. What is the opinion of the Moderator here? > > [I am open to comments on this issue - what rules should > apply? -- Moderator] > No strong opinion on the question of splitting Mathematica and Alpha into separate forums (can see arguments either way) ---but as someone who finds newsgroups immensely better than email lists for this (or any similar) type of public discussion, I hope that whatever you do will end up with all such forums existing as (or mirrored to) plain old Usenet newsgroups. === Subject: Re: comments on Wolfram Alpha Hello Beliavsky: Just give this string to both \engines\ and you will see what we mean: \stopping power air, 0.731MeV electron\. Then change the same query to .371 MeV and re-submit to both. The intersection of the greatest part of their domain and range is disjoint. Roger Williams Franklin Laboratory > input: arima > output: Arima,Trinidad and Tobago > Population: > city population | 34997 people > my comment: Nothing about ARIMA time series models, which comes up as > the 3rd link on Google. > > input: garch > output: Wolfram|Alpha isn't sure what to do with your input. > * Did you mean:march > my comment: nothing about GARCH time series models, widely used in > finance > > input: united states budget deficit > output: -$347 billion per year (US dollars per year) (2005 estimate) > my comment: Users would want more recent data, such as the 2008 > deficit and the estimated 2009 deficit. > > Wolfram Alpha appears much less useful than the combination of Google > and Mathematica, so I wonder if resources are better spent adding > functionality to Mathematica. === Subject: Re: comments on Wolfram Alpha Steven & Ingolf, The policy probably has to evolve along with Wolfram Alpha. As I see it there will be an API release soon that will inevitably tie Mathematica and Alpha tightly together. Questions related to Mathematica interaction with Alpha would be valid topics for this forum in my opinion. Syd Geraghty B.Sc, M.Sc. sydgeraghty@mac.com Mathematica 7.0.1 for Mac OS X x86 (64 - bit) (18th February 2009) MacOS X V 10.5.6 ********************************************************************** I suggest a policy where letters about Wolfram Alpha from now on are let through only in the cases where Mathematica as such also really is involved. Other letters fit better as direct feedback to Wolfram or as letters to the WolframAlpha Community. What is the opinion of the Moderator here? [I am open to comments on this issue - what rules should apply? -- Moderator] IMHO ************************************************************************ === Subject: Re: comments on Wolfram Alpha True, but then it loses any synergy from the Internet. It is just a natural language connection between Mathematica and WRI curated sets of data. It's good as a supercalculator, at questions about scientific data, and recent stock prices, but poor at most other things until they fill in more data. \ In my view it is not a true Internet application. The web just provides a portal to a self-contained application. At least, that is the way I see it. Does W|A ever access the Internet for information between the time a user types a question and the time it provides a response? Perhaps it accesses data on the web, but only sites that WRI has curated and pre-linked to. This would only amount to other people storing the data for them. And \curated\ probably means they have created a driver interface to get the data into Mathematica form and W|A. The data is the weak link and it will probably involve A LOT OF WORK to get a really good set of data \about the world\ into usable form such that \ users would be surprised and delighted with the response. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Alpha is NOT a search engine. === Subject: Re: comments on Wolfram Alpha > Good, use Google then. Why should WolframAlpha try to be better on > things > where Google is good enough? > But with this kind of letters the number of messages to MathGroup > will soon > reach 200,000. I am also very interested in the abilities and > inabilities of > WolframAlpha, but this is not the right place for that discussion. I > suggest > a policy where letters about Wolfram Alpha from now on are let > through only > in the cases where Mathematica as such also really is involved. Other > letters fit better as direct feedback to Wolfram or as letters to the > WolframAlpha Community. What is the opinion of the Moderator here? > > [I am open to comments on this issue - what rules should > apply? -- Moderator] My *personal* opinion is that general Wolfram|Alpha comments should be directed to http://community.wolframalpha.com/ which seems to be the MathGroup equivalent. Of course comments like: * how do I get something in Mathematica to look like it does in Wolfram|Alpha? * I get different results for in Mathematica and Wolfram|Alpha. Why? * Wolfram|Alpha knows how to calculate ; how do I do it in Mathematica? * How do I create a docked cell in Mathematica with a search field for Wolfram|Alpha? * etc... that also pertain to Mathematica should be allowed on MathGroup. Brett === Subject: Re: Bug in analytical sum > > Consider the following sum > > > f[k_] := Sum[n! (-I \\[Alpha])^n Cos[\\[Phi]/2]^n \\[Alpha]^n \ Sin[\\[Phi]= / > > 2]^n, {n, > > 0, k}]/Sum[n! \\[Alpha]^(2 n) Cos[\\[Phi]/2]^(2 n), {n, 0, k}] > > > I am interested in taking alpha and k to infinity. Now clearly for > > finite k this is just a rational function in alpha. So if we want to > > take alpha to infinity we should get > > > (-i Tan[\\[Phi]/2])^k. > > > But try this in Mathematica Limit[f[k], \\[Alpha] -> \\[Infinity]] and > > you will get I Cot[\\[Phi]/2]. This is Mathematica 7.0.0. > > > The reason seems to be that Mathematica evaluates the sum first and > > obtains a fraction consisting of the incomplete gamma functions and Ei > > integrals. It seems that the limits of those functions are not taken > > properly. > > Offhand I do not know what is the correct result. But I can say that \ Limi= t > will have trouble managing branch cuts, if not given suitable assumptions > (and it may have trouble anyway...). So you might instead do: > > In[18]:= Limit[f[k], \\[Alpha] -> Infinity, Assumptions -> > {k > 0, Element[\\[Phi], Reals]}] > > Out[18]= (-(1/2))^k/(Cos[\\[Phi]/2]^(2*k)*((-I)*Csc[\\[Phi]])^k) > > Daniel Lichtblau > Wolfram Research Yes, this seems to be the problem. Looks like Mathematica is taking === Subject: Re: Image[], Graphics[Raster[]] what do you want ? a solution to the problem or a pointer to the documentation ? And it is easy to write a similar function by your self because Graphics[Raster[]] is still working, one of the design errors in Image[] is that it has no dimension/size/position. But for the new line integral convolution one needs to place a bitmap in a coordinate system. So Mathematica *must* support Raster[] because otherwise, the line integral convolution would not work. In fact my own image processing package has a function ImageToGraphicsObject[] that make a raster from the Image[] and add a ImageRectangle option to Image[] because otherwise I would not be able to use Mathematica for my research work for image registration. So here is the one, that is documented by its source DigitalImageQ[_Image]:=True DigitalImageQ[Graphics[Raster[__],___]]:=True DigitalImageQ[img_]:=Image`PossibleImageQ[img] Unprotect[Image]; Options[Image] = Append[Options[Image], ImageRectangle -> Automatic]; Protect[Image]; ] ImageRectangle[img_?DigitalImageQ]:= Module[{pos}, pos=ImageRectangle /. Options[img] /. (ImageRectangle->Automatic); Return[{{0,0},ImageDimensions[img]}]; ]; pos ] ImageColorFunction[img_?DigitalImageQ]:= Block[{cs,cf}, cs=ColorSpace /. AbsoluteOptions[img]; Which[ True,cf=GrayLevel ]; cf ] Options[ImageToGraphicsObject]={ColorFunction->Automatic,ImageRectangle->Aut\ omatic,ColorFunctionScaling->True} ImageToGraphicsObject[img_?DigitalImageQ,opts:OptionsPattern[ImageToGraphics\ Object]]:= Module[{typ,rect,raster,range,cfun,cfs}, typ=ImageType[img]; rect=OptionValue[ImageRectangle]; If[Automatic==rect, rect=ImageRectangle[img] ]; range={Min[#],Max[#]} & [Flatten[ImageData[img,typ]]]; cfun=OptionValue[ColorFunction]; cfun=ImageColorFunction[img] ]; cfs=OptionValue[ColorFunctionScaling]; Raster[Reverse[ImageData[img,typ]],rect,range,ColorFunction->cfun,ColorFunct\ ionScaling->cfs] ] Hopefully I have not forgotten anything ... mail me if yes, You can have the package for Windows/MacOS X Jens > On May 31, 2:32 pm, Jens-Peer Kuska >> Oh mixing is easy: >> >> img = Import[\http://www.stephenwolfram.com/img/home/sw-portrait.jpg\] >> Graphics[ >> {Image`ToGraphicsRaster[img][[1]], >> Circle[{110.5, 110.5}, 10]}] >> >> draw a circle on the image. > > function \Image`ToGraphicsRaster\ is documented? I have not found > anything in the Documentation about this. > === Subject: Re: matching misspelled names Hi Jess, You will really need some metric that will determine you how close any 2 names are to each other. In this metric you will have to encode the specifics related to middle names etc. Then, for each of the names in the list A you can sort the names in the list B according to this metric, and take some number of the \closest\ ones. The complexity of this algorithm will be MN Log N where M is a length of the first list and N the length of the second. The complexity may be improved if you do it a little differently: hash the names in the first list, merge both lists together, sort according to the metric as above (just once), then traverse the sorted list and pick some neighbor elements around each one which is originally from the first list (this you check with the above-mentioned hash table), and then from each found sublist of names remove the names from the first list that were mistakingly included in the results by this algorithm. In this case, the complexity will be something of the order of C1*(M+N)Log(M+N) +C2*M, I think. Alternatively you could construct a matrix of \name distances\ and use clustering (via FindClusters, it has a form that accepts the distance matrix), but I don't think this will be easier, since this is a somewhat different problem and you may have a hard time disentangling and ordering the clustering results. Another alternative would be to use one of the training algorithms and \ train it on a large body of valid names of the type found in list A, and then apply the \spelling corrector\ to a list B. A really simple but effective example of this approach was given by Peter Norvig: < http://norvig.com/spell-correct.html> (a good read for your problem in any case, I think). I have translated his code into Mathematica some while ago, so if you are interested let me know and I will send you the code. Leonid > > I would like to compare 2 very large lists of names to identify a > shortlist of possible matches where someone from the list A appears in > the list B. > > However as English is not the local language, the most names have many > spelling alternatives. Also in different contexts, the same person is > referred to by the full name with one or more middle names and family > names or just by a smaller combination of these. I imagine comparing > lists with one or few typos is quite simple. But is there a way to do > this in Mathematica which can also handle the type of variations I've > outlined? > > I was thinking of arranging the names into clusters, isolating those > clusters which include a list A person, and then generating lists of > the closest matches for each cluster around a list A person. Is there > a simple way to do this or a better way? > > Jess > > === Subject: Re: Reading Fortran Data file CSV format can deal with Fortran numbers. Import[\file.dat\,\CSV\] > Have data fortran data file with numbers like 0.447562485933D-01. I > need all the digits, but mathematica seems to only read this as > 0.0448062. > I can read it as a string and get > > \0.448062494397D-01\ > > but when I use ToExpression, I get > > -1 + 0.448062 D > > So how can I read in all the digits. > > === Subject: Re: Reading Fortran Data file > > Import[\!tr D E < inputfile\, \Table\] > Looks like I was wrong here. As others pointed out, Mathematica *can* read numbers of the form 1.2d3. === Subject: Re: Reading Fortran Data file By default, Mathematica only DISPLAYS reals to 6 decimal digits, but the remaining digits are there. To see more displayed, use NumberForm. > Have data fortran data file with numbers like 0.447562485933D-01. I > need all the digits, but mathematica seems to only read this as > 0.0448062. > I can read it as a string and get > > \0.448062494397D-01\ > > but when I use ToExpression, I get > > -1 + 0.448062 D > > So how can I read in all the digits. > > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: RandomReal gets stuck By the way, is the use of \indexed\ variable names in the form x[i] encouraged in Mathematica ? It doesn't make sense in mathematical notation (as far as I am aware) and is not coherent with the use of brackets in Mathematica. A.B. >> The code above uses Maximize in a non-sensical way, particularly >> when the function y hasn't been defined. This usage asks >> Mathematica to find the maximize the sum of n things with >> respect to each of the n things. It appears there is an attempt >> to use the notation y[n] to mean an array indexed by n rather >> than a function of n. So, Maximize correctly generates error >> messages. What is unexpected is poor input to Maximize appears >> to cause a problem for RandomReal. > > Bill, > > I don't think you understood what I was trying to do. I merely > simplified Bas' code to something that had the same effects on random > number generation. The use of y[i] was taken from Bas' example. I > don't think he meant to index an array. You can use y[1], y[2] etc. > just as any other variable. > > The error message in Maximize is not material to the problem. I ask > Mathematica to maximize an unbounded sum of variables. It's a > perfectly legal (though unsolvable) problem. That it responds with an > error message doesn't matter (I can -and have- come up with more > elaborate functions that have the same problem with random numbers but > don't cause Maximize to generate a warning). The problem is that > Maximize with 31 or more variables resets the random number generator. > In the mean time, Wolfram has confirmed this is indeed the case and it > will be fixed in a new realease. > > > > >> >>> I can confirm this bug. >>> Executing an even simpler version, namely >>> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >>> will also set the random generator to a fixed starting point. The >>> number 31 is crucial, as lower values do not appear to cause the >>> bug, while higher values do. Changing Plus to Times appears to >>> prevent the bug. >>> In[394]:= Table[ >>> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >>> RandomReal[], {20} >>> ] >> >> When I execute the code above, I do get the same result as you >> report. Clearly, there is a problem here somewhere. But it isn't >> clear the issue is with RandomReal. >> >> The code above uses Maximize in a non-sensical way, particularly >> when the function y hasn't been defined. This usage asks >> Mathematica to find the maximize the sum of n things with >> respect to each of the n things. It appears there is an attempt >> to use the notation y[n] to mean an array indexed by n rather >> than a function of n. So, Maximize correctly generates error >> messages. What is unexpected is poor input to Maximize appears >> to cause a problem for RandomReal. >> >> On my system, changing Plus to Times eliminates the effect on >> RandomReal even though there is still a non-sensical input to >> Maximize. Alternatively, defining y then executing the code does >> >> In[5]:= y[n_] := n^2 - n >> >> In[6]:= Table[ >> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >> RandomReal[], {20}] >> >> During evaluation of In[6]:= Maximize::ivar: 0 is not a valid >> variable. >> >> >> During evaluation of In[6]:= Maximize::ivar: 0 is not a valid >> variable. >> >> >> During evaluation of In[6]:= Maximize::ivar: 0 is not a valid >> variable. >> >> >> During evaluation of In[6]:= General::stop: Further output of >> Maximize::ivar will be suppressed during this calculation. >> >> >> Out[6]= {0.877054,0.833103,0.703786,0.0482118,0.226066,0.230746,0.07380= > 72= >> \ ,0.680963,0.53264,0.989333,0.418793,0.951114,0.963168,0.870439,0.926361,0= > .267113,0.195084,0.810066,0.875896,0.579076} >> >>> This is very nasty, as a lot of people critically depend on random >>> functions to be random. I would urge you to report this to wolfram >>> support. >> >> I agree many people including myself depend on the random >> functions to be random. And I would also like Mathematica to >> fail gracefully when given non-sensical input and provide useful >> error messages. But I am never surprised when software does >> something other than fail gracefully given non-sensical input or >> provides less than useful error messages. >> >> Entering >> >> Table[ >> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >> RandomReal[], >> {20} >> ] >> >> into a new session and expecting useful output simply isn't a >> reasonable expectation. >> >> Note, this in no way says what the original poster was doing is >> unreasonable or non-sensical. The rest of the information needed >> to determine whether what the original poster was attempting is >> sensible hasn't been provided. I would also note, that sending a >> bug report to Wolfram without the additional information is >> probably pointless. > > === Subject: Re: RandomReal gets stuck Sorry, in the meantime I found the entry for this in the documentation \ which explains precisely when and how this kind of notation can be useful. A.B. > > By the way, is the use of \indexed\ variable names in the form x[i] \ encouraged > in Mathematica ? It doesn't make sense in mathematical notation (as far as \ I > am aware) and is not coherent with the use of brackets in Mathematica. > > A.B. > > > >>> The code above uses Maximize in a non-sensical way, particularly >>> when the function y hasn't been defined. This usage asks >>> Mathematica to find the maximize the sum of n things with >>> respect to each of the n things. It appears there is an attempt >>> to use the notation y[n] to mean an array indexed by n rather >>> than a function of n. So, Maximize correctly generates error >>> messages. What is unexpected is poor input to Maximize appears >>> to cause a problem for RandomReal. >> >> Bill, >> >> I don't think you understood what I was trying to do. I merely >> simplified Bas' code to something that had the same effects on random >> number generation. The use of y[i] was taken from Bas' example. I >> don't think he meant to index an array. You can use y[1], y[2] etc. >> just as any other variable. >> >> The error message in Maximize is not material to the problem. I ask >> Mathematica to maximize an unbounded sum of variables. It's a >> perfectly legal (though unsolvable) problem. That it responds with an >> error message doesn't matter (I can -and have- come up with more >> elaborate functions that have the same problem with random numbers but >> don't cause Maximize to generate a warning). The problem is that >> Maximize with 31 or more variables resets the random number generator. >> In the mean time, Wolfram has confirmed this is indeed the case and it >> will be fixed in a new realease. >> >> >> >> >>> >>>> I can confirm this bug. >>>> Executing an even simpler version, namely >>>> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >>>> will also set the random generator to a fixed starting point. The >>>> number 31 is crucial, as lower values do not appear to cause the >>>> bug, while higher values do. Changing Plus to Times appears to >>>> prevent the bug. >>>> In[394]:= Table[ >>>> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >>>> RandomReal[], {20} >>>> ] >>> >>> When I execute the code above, I do get the same result as you >>> report. Clearly, there is a problem here somewhere. But it isn't >>> clear the issue is with RandomReal. >>> >>> The code above uses Maximize in a non-sensical way, particularly >>> when the function y hasn't been defined. This usage asks >>> Mathematica to find the maximize the sum of n things with >>> respect to each of the n things. It appears there is an attempt >>> to use the notation y[n] to mean an array indexed by n rather >>> than a function of n. So, Maximize correctly generates error >>> messages. What is unexpected is poor input to Maximize appears >>> to cause a problem for RandomReal. >>> >>> On my system, changing Plus to Times eliminates the effect on >>> RandomReal even though there is still a non-sensical input to >>> Maximize. Alternatively, defining y then executing the code does >>> >>> In[5]:= y[n_] := n^2 - n >>> >>> In[6]:= Table[ >>> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >>> RandomReal[], {20}] >>> >>> During evaluation of In[6]:= Maximize::ivar: 0 is not a valid >>> variable. >> >>> >>> During evaluation of In[6]:= Maximize::ivar: 0 is not a valid >>> variable. >> >>> >>> During evaluation of In[6]:= Maximize::ivar: 0 is not a valid >>> variable. >> >>> >>> During evaluation of In[6]:= General::stop: Further output of >>> Maximize::ivar will be suppressed during this calculation. >> >>> >>> Out[6]= \ {0.877054,0.833103,0.703786,0.0482118,0.226066,0.230746,0.07380= >> 72= >>> \ ,0.680963,0.53264,0.989333,0.418793,0.951114,0.963168,0.870439,0.926361,0= >> .267113,0.195084,0.810066,0.875896,0.579076} >>> >>>> This is very nasty, as a lot of people critically depend on random >>>> functions to be random. I would urge you to report this to wolfram >>>> support. >>> >>> I agree many people including myself depend on the random >>> functions to be random. And I would also like Mathematica to >>> fail gracefully when given non-sensical input and provide useful >>> error messages. But I am never surprised when software does >>> something other than fail gracefully given non-sensical input or >>> provides less than useful error messages. >>> >>> Entering >>> >>> Table[ >>> Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]]; >>> RandomReal[], >>> {20} >>> ] >>> >>> into a new session and expecting useful output simply isn't a >>> reasonable expectation. >>> >>> Note, this in no way says what the original poster was doing is >>> unreasonable or non-sensical. The rest of the information needed >>> to determine whether what the original poster was attempting is >>> sensible hasn't been provided. I would also note, that sending a >>> bug report to Wolfram without the additional information is >>> probably pointless. >> >> === Subject: Re: problem writing debugging utility -- David P.S. Now please write a description of the entire Mathematica REPL with \ the same clarity and level of detail! Self-publish it on Amazon or Lulu - I'll buy a copy and I bet most of the mathgroup list would too! > > Just to add some more to the reply of Szabolcs: > <... lots of GOOD STUFF omitted ...> === Subject: Re: problem writing debugging utility function Just to add some more to the reply of Szabolcs: The evaluation process in Mathematica is recursive, going first \down\ to leaves, then evaluating it \up\, starting from leaves and going to larger sub-expressions, checking for the global rules to match. Unevaluated is treated in a special way in that it suppresses the evaluation of expression \on the way down\, allowing the rules attached to the head (say ) surrounding it to apply \on the way up\ on the original expression. The original expression may or may not evaluate later, depending on what does with its argument. In the following example: In[1] = g[x_ + y_] := x*y; g[Unevaluated[5 + 5]] Out[1] = 25, the rule attached to did apply since the expression 5+5 was preserved \ in its unevaluated form. In this case, the original expression (Plus operator) never evaluated, but in some other cases it may evaluate - it all depends on now. But without Unevaluated, would never have a chance to see the original expression, since by the time evaluation goes \up\ to g, 5+5 would have evaluated to 10 already. This situation indeed is precisely as \ if we would give Hold attribute \on the way down\ and remove it \on the \ way up\. There are several differences between Hold and Unevaluated. Technically, Hold is just a wrapper with a HoldAll attribute which is not particularly different from any user-defined HoldAll wrapper, and is special just \ because it is the \official\ holding wrapper and there are commands such as ReleaseHold that work with it together. Most of the functionality of Hold can pretty much be duplicated/reproduced by any HoldAll wrapper. OTOH, Unevaluated is one of the \magic symbols\, along with Evaluate and \ Sequence. It is more deeply \wired in\, into the main evaluation loop algorithm, \ and its functionality can not be removed, blocked or duplicated. In particular, we may block Hold with a Block trick Block[{Hold},...], but we can not \ block Unevaluated in the same way. Another difference is that (one level of wrapping with) Unevaluated does \ not by itself represent extra level of wrapping - it is automatically stripped off when the evaluator comes to apply the rules to expression inside it. \ Not so with Hold - it is a normal wrapper. different. Hold is often used to preserve the internal expression unevaluated for more than one successive evaluation (or in between such evaluations). For example, if one function (say ) produces the result \ as an expression which wil normally evaluate but whose evaluation we want to prevent, and another function (say ) needs to consume this result in \ this unevaluated form, but the result is not passed directly from to , then may wrap the result in Hold and will then have to unwrap it. Unevaluated would not help us here since it is normally used in a single evaluation. Here is a simple example: In[2] = Clear[f,h]; f[x_] := Module[{y}, y = Hold[x^2]]; h[x_Hold] := x /. Hold[a_^b_] :> {a, b} In[3] = odd = Select[f /@ Range[10], Not[FreeQ[#, _?OddQ]] &] Out[3] = {Hold[1^2], Hold[3^2], Hold[5^2], Hold[7^2], Hold[9^2]} In[4] = h /@ odd Out[4] = {{1, 2}, {3, 2}, {5, 2}, {7, 2}, {9, 2}} What happens here is that constructs some power (square) while deconstructs it to base-power pair. But is not called directly on the result of , so we need to prevent expressions from evaluation in between evaluations involving and . Unevaluated would not be helpful here. Another thing worth mentioning (and more directly relevant to your example) is the mechanics of argument - passing. Consider this function: In[5] = Clear[f]; f[x_] := {Hold[x],Head[x]}; It is supposed to return the held input together with its head . Let us try In[6] = (Print[\Just before calling f\]; f[#]) &[Print[\*\]] * Just before calling f Out[6]= {Hold[Null],Symbol} If we attempt to force it to not evaluate the argument (Printing), in this way: In[7] = Function[y, (Print[\Just before calling f\]; f[y]), HoldAll][Print[\*\]] Just before calling f * Out[7]= {Hold[Null],Symbol} We see that the result was indeed not evaluated before having been passed \ to , but it was evaluated in , and the r.h.s of uses an already evaluated result. Now, it is to prevent also this evaluation of the argument that we need Unevaluated: In[8] = Function[y, (Print[\Just before calling f\]; f[Unevaluated[y]]), HoldAll][Print[\*\]] Just before calling f * Out[8] = {Hold[Print[\*\]], Symbol} We see that the printing still takes place, and while the held part is ok, the head part still computes the Head of the evaluated argument (that's where the printing happens). This is because this time, Head needs Unevaluated - we redefine : In[9] = Clear[f]; f[x_] := {Hold[x],Head[Unevaluated[x]]}; In[10] = Function[y, (Print[\Just before calling f\]; f[Unevaluated[y]]), HoldAll][Print[\*\]] Just before calling f Out[10]= {Hold[Print[*]],Print} Now we get what we want. Hopefully by this moment the pattern started to emerge. Note that Unevaluated is unnecessary if the function itself holds its argument, possessing one of the hold attributes: In[11]= ClearAll[f]; Attributes[f] = {HoldAll}; f[x_] := {Hold[x], Head[Unevaluated[x]]}; In[12] = Function[y, (Print[\Just before calling f\]; f[y]), \ HoldAll][Print[\*\]] Just before calling f Out[12]= {Hold[Print[*]],Print} It is slightly off the main line of the argument, but another common pitfall associated with this sort of things is something like this: In[13] = {Hold[#] &[5^2],Hold[5^2]} Out[13] = {Hold[25],Hold[5^2]} The #-& notation is so routinely used that one often forgets that it does introduce an additional parameter-passing stage. This is what one should \ use to avoid evaluation during that stage: In[14] = {Function[Null, Hold[#], HoldAll][5^2], Hold[5^2]} Out[14] = {Hold[5^2], Hold[5^2]} Sometimes the opposite is needed however: In[15]:= i = 0; Function[x, {x, x, x}, HoldAll][i++] Out[15]= {0, 1, 2} In[16] = i Out[16] = 3 In[17]:= i = 0; Function[x, {x, x, x][i++] Out[17]= {0, 0, 0} In[18] = i Out[18] = 1 In this case, chances are that the first behavior is not what was intended. So, to summarize: Hold is mostly useful to prevent evaluation of some results, in between some other evaluations. Unevaluated in useful to force some function use - just once, in this particular evaluation (for its r.h.s.) - its original (unevaluated) argument if that function does not have a corresponding hold attribute. Hold attributes are useful for the \ same thing, but 1) They are permanent, not just one-time use 2) Unevaluated wrappers are stripped off when evaluator meets them \on the way up\, so subsequent evaluation uses already normal version of the argument - not so with attributes 3) You may need to work with functions written by others \ (or system functions), for which changing attributes even temporarily may have undesired/unpredictable consequences - in this case Unevaluated is more appropriate, to make up for the lacking hold attribute just once. Perhaps, another way to put is is that attributes belong to the function, while Unevaluated \belongs\ to a particular argument (though affecting the execution of the function on that argument as if that function had a hold attribute). This is probably a very long-winded way to explain these things, but I hope it will still clarify some issues. Leonid > liked Leonid's the best, being both much simpler and more general than > mine. > > SetAttributes[ShowIt, HoldAll]; > ShowIt[code_] := > Module[{y}, > Print[ToString[Unevaluated[code]], \ = \, y = code]; > y]; > > My own solution was the hideous > > \ $PreRead=ReplaceAll[#,{{\dbgv\,\[\,var_,\]\}:>{\Print\,\[\,RowBox > [{\\\\\<>var<>\ = \<>\\\\\,\,\,var}],\]\}}]&; > > which makes dbgv work like a macro. The grotesqueness is because what > $PreRead sees is a very raw input form, with expressions broken down > into RowBox's. In a sense this is the most direct analog to Lisp's > macros, but ... yechh. > > The Unevaluated[] function had slipped off my radar, probably because > I never fully grokked the distinction between it and Hold[]. In fact > I'm still a bit confused about it. At first I thought it might like > the evaluation inhibitor ` in Lisp, but some examples disabused me of > that. > > In[2]:= f@Unevaluated[5 + 6 + 7 + 8] > > Out[2]= f[Unevaluated[5 + 6 + 7 + 8]] > > In[11]:= ToString@Unevaluated[5 + 6 + 7 + 8] > > Out[11]= \5 + 6 + 7 + 8\ > > > I might have expected Out[11]= \Unevaluated[5 + 6 + 7 + 8]\ > > > In[13]:= sqr[x_] := x^2 > > In[14]:= sqr@Unevaluated[5 + 6 + 7 + 8] > > Out[14]= 676 > > > I might have expected Out[14]= sqr[5 + 6 + 7 + 8] since sqr does not > know what to do with the pattern _+_+_+_ or _+_ for that matter. > Could anyone elucidate this for me? > === Subject: Re: Min function returns Min[2.05875,] instead of Min flattens lists! > > can you explain what the minimum of a set of > vectors with dimension 248 is ? > > Or do you mean Min[Flatten[data]] ? > > Jens > >> I have an matrix \data\ with 17x248 real numbers. >> >> When I enter Min[data], I get >> Min[2.05875, ] as a result, instead of just the number 2.05875. >> >> This is Mathematica 7.0.1 on Mac OS X. >> >> Why? >> >> How can I get just the number from the result? >> >> TIA >> > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Min function returns Min[2.05875,] instead of just 2.05875 > I have an matrix \data\ with 17x248 real numbers. > > When I enter Min[data], I get > Min[2.05875, ] as a result, instead of just the number 2.05875. > > This is Mathematica 7.0.1 on Mac OS X. > > Why? > > How can I get just the number from the result? > > TIA It's hard to see exactly what's going wrong because you have not included the exact code, but at a guess I'd say there may some invisible wrapper around the list of numbers, which is preventing Min evaluating properly. In general, the behaviour should be as follows: In[290]:= data = RandomReal[10, {17, 248}]; Min[data] Out[291]= 0.00017248 Peter. === Subject: Re: Min function returns Min[2.05875,] instead of just 2.05875 > I have an matrix \data\ with 17x248 real numbers. > > When I enter Min[data], I get > Min[2.05875, ] as a result, instead of just the number 2.05875. > > This is Mathematica 7.0.1 on Mac OS X. > > Why? > > How can I get just the number from the result? > > TIA I think you have a non-printing character in your matrix. Min[2,3,4,5,x] reduces to Min[2,x]. But if the \x\ was something so strange that Mathematica did not have a way of printing it, then I think we would see Min[2,]. If \data\ is stored as a list of 17 row, each of which should contain 248 numbers, then look for a row with Length[row] = 249. -- Christopher J. Henrich chenrich@monmouth.com http://www.mathinteract.com \A bad analogy is like a leaky screwdriver.\ -- Boon === Subject: Re: Min function returns Min[2.05875,] instead of just 2.05875 > I have an matrix \data\ with 17x248 real numbers. > > When I enter Min[data], I get > Min[2.05875, ] as a result, instead of just the number 2.05875. > > This is Mathematica 7.0.1 on Mac OS X. > > Why? > You typed Min[data,] instead of Min[data]. > How can I get just the number from the result? > Remove the comma. === Subject: Re: Min function returns Min[2.05875,] instead of just 2.05875 can you explain what the minimum of a set of vectors with dimension 248 is ? Or do you mean Min[Flatten[data]] ? Jens > I have an matrix \data\ with 17x248 real numbers. > > When I enter Min[data], I get > Min[2.05875, ] as a result, instead of just the number 2.05875. > > This is Mathematica 7.0.1 on Mac OS X. > > Why? > > How can I get just the number from the result? > > TIA > === Subject: Re: Min function returns Min[2.05875,] instead of just 2.05875 Non numerical entry after the comma. -Francesco > I have an matrix \data\ with 17x248 real numbers. > > When I enter Min[data], I get > Min[2.05875, ] as a result, instead of just the number 2.05875. > > This is Mathematica 7.0.1 on Mac OS X. > > Why? > > How can I get just the number from the result? > > TIA > === Subject: Re: Min function returns Min[2.05875,] instead of just 2.05875 This is precisely the result you get if one of the matrix entries contains an empty string (\\). I'd check my data for this if I were you. > I have an matrix \data\ with 17x248 real numbers. > > When I enter Min[data], I get > Min[2.05875, ] as a result, instead of just the number 2.05875. > > This is Mathematica 7.0.1 on Mac OS X. > > Why? > > How can I get just the number from the result? > > TIA === Subject: Re: Min function returns Min[2.05875,] instead of just 2.05875 This is just a guess, but you may have an invisible character as an element in your matrix that is being interpreted as a symbol. The second argument of the Min is in your matrix somewhere. Do a FullForm on the output to see what the second argument to Min is, then eliminate it from your matrix. === Subject: Re: Sidebar Tools I have just checked the version I have put on web. The is no problem with the configuration on my PC with OS Windows. I am not sure but it seems that Mathematica loads the configuration file \ twice. May be this is because of $BaseDirectory and $UserBaseDirectory are the \ same. Can you put the autoloading files into the Mathematica installation \ directory? 2009/6/2, Murray Eisenberg : > Something's wrong with the Sidebar configuration: After I extract the > Sidebar subdirectory of the Sidebar main directory to Applications and > then extract the SidebarAutoload subdirectory to the Autoload > directory, I now get each Sidebar menu entry appearing twice: > > - in the Help menu, the three entries Sidebar, Inform, TOC > - in the Edit menu, Copy to Stack > - in Evaluation menu, Kernel Quit Command > > This is with Mathematica 7.0.1. > > The extracted Sidebar directories are in $UserBaseDirectory, as > instructed in Installation.nb. However, $UserBaseDirectory has the > same value as $BaseDirectory. (This is on a single-user Windows > system, where I utterly refuse to store user-specific Mathematica > files under C:\\Documents and Settings, since the latter is on the same > partition as the OS (a madness that only Bill Gates can explain). > > How can this be fixed? > > Palettes, and even the legacy HelpBrower, where duplicate entries > would appear. The bug with StyleSheets and Palettes seems to have > been fixed as of Mathematica 6.x or 7.x, but the corresponding bug > with the legacy HelpBrowser persists.) > > > > > > I have updated the package Sidebar`. > > It includes several interactive tools to control, to navigate, and to > > trace notebook changes. > > Main properties of Sidebar` palettes include: > > - Navigation between the arbitrary selected places in the notebooks > > - Automatic preserving of the notebook modified cells > > - Notebook clearing, backuping etc. > > - Generation of the active table of contents (TOC) > > - Work with the group of choosen sections/subsections of the notebook > > (selection, evaluation, hiding, revealing) > > - Clipboard stack > > - Symbol information window > > - Tracing graphics coordinates and the evaluation time > > - Easy access to special notebooks (ToDo, Memo, Code) > > - Few more functions, like comparing of two cells of the notebook, > > locking/unlocking etc > > > > It works OK for me but it is still experimental. > > Please be careful when you start to use it! > > > > The package link > > > > Yuri Kandrashkin > > > > > > -- > Murray Eisenberg Internet: murray@math.umass.edu > Mathematics & Statistics Dept. Voice: 413-545-2859 (W) > University of Massachusetts 413-549-1020 (H) > Amherst, MA 01003 Fax: 413-545-1801 > -- Yuri Kandrashkin, PhD http://spinalgebra.com - Mathematica based applications: - Magnetic Resonance with SpinAlgebra - Work with systems of Units - Interactive tools: ViewPoint selector, Options explorer, etc === Subject: Re: Sidebar Tools I moved the SidebarAutoload from the Autoload subdirectory of $UserBaseDirectory (= $BaseDirectory) into the Autoload directory of $InstallationDirectory\\SystemFiles and restarted Mathematica 7.0.1 with a clean cache. Now NONE of the Sidebar menu additions appear! > I have just checked the version I have put on web. > The is no problem with the configuration on my PC with OS Windows. > I am not sure but it seems that Mathematica loads the configuration file \ twice. > May be this is because of $BaseDirectory and $UserBaseDirectory are the \ same. > Can you put the autoloading files into the Mathematica installation \ directory? > > 2009/6/2, Murray Eisenberg : >> Something's wrong with the Sidebar configuration: After I extract the >> Sidebar subdirectory of the Sidebar main directory to Applications and >> then extract the SidebarAutoload subdirectory to the Autoload >> directory, I now get each Sidebar menu entry appearing twice: >> >> - in the Help menu, the three entries Sidebar, Inform, TOC >> - in the Edit menu, Copy to Stack >> - in Evaluation menu, Kernel Quit Command >> >> This is with Mathematica 7.0.1. >> >> The extracted Sidebar directories are in $UserBaseDirectory, as >> instructed in Installation.nb. However, $UserBaseDirectory has the >> same value as $BaseDirectory. (This is on a single-user Windows >> system, where I utterly refuse to store user-specific Mathematica >> files under C:\\Documents and Settings, since the latter is on the same >> partition as the OS (a madness that only Bill Gates can explain). >> >> How can this be fixed? >> >> Palettes, and even the legacy HelpBrower, where duplicate entries >> would appear. The bug with StyleSheets and Palettes seems to have >> been fixed as of Mathematica 6.x or 7.x, but the corresponding bug >> with the legacy HelpBrowser persists.) >> >> >> > >> > I have updated the package Sidebar`. >> > It includes several interactive tools to control, to navigate, and to >> > trace notebook changes. >> > Main properties of Sidebar` palettes include: >> > - Navigation between the arbitrary selected places in the notebooks >> > - Automatic preserving of the notebook modified cells >> > - Notebook clearing, backuping etc. >> > - Generation of the active table of contents (TOC) >> > - Work with the group of choosen sections/subsections of the notebook >> > (selection, evaluation, hiding, revealing) >> > - Clipboard stack >> > - Symbol information window >> > - Tracing graphics coordinates and the evaluation time >> > - Easy access to special notebooks (ToDo, Memo, Code) >> > - Few more functions, like comparing of two cells of the notebook, >> > locking/unlocking etc >> > >> > It works OK for me but it is still experimental. >> > Please be careful when you start to use it! >> > >> > The package link >> > >> > Yuri Kandrashkin >> > >> >> >> >> -- >> Murray Eisenberg Internet: \ murray@math.umass.edu >> Mathematics & Statistics Dept. Voice: 413-545-2859 (W) >> University of Massachusetts 413-549-1020 (H) >> Amherst, MA 01003 Fax: 413-545-1801 >> > > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Sidebar Tools Something's wrong with the Sidebar configuration: After I extract the Sidebar subdirectory of the Sidebar main directory to Applications and then extract the SidebarAutoload subdirectory to the Autoload directory, I now get each Sidebar menu entry appearing twice: - in the Help menu, the three entries Sidebar, Inform, TOC - in the Edit menu, Copy to Stack - in Evaluation menu, Kernel Quit Command This is with Mathematica 7.0.1. The extracted Sidebar directories are in $UserBaseDirectory, as instructed in Installation.nb. However, $UserBaseDirectory has the same value as $BaseDirectory. (This is on a single-user Windows system, where I utterly refuse to store user-specific Mathematica files under C:\\Documents and Settings, since the latter is on the same partition as the OS (a madness that only Bill Gates can explain). How can this be fixed? Palettes, and even the legacy HelpBrower, where duplicate entries would appear. The bug with StyleSheets and Palettes seems to have been fixed as of Mathematica 6.x or 7.x, but the corresponding bug with the legacy HelpBrowser persists.) > > I have updated the package Sidebar`. > It includes several interactive tools to control, to navigate, and to > trace notebook changes. > Main properties of Sidebar` palettes include: > - Navigation between the arbitrary selected places in the notebooks > - Automatic preserving of the notebook modified cells > - Notebook clearing, backuping etc. > - Generation of the active table of contents (TOC) > - Work with the group of choosen sections/subsections of the notebook > (selection, evaluation, hiding, revealing) > - Clipboard stack > - Symbol information window > - Tracing graphics coordinates and the evaluation time > - Easy access to special notebooks (ToDo, Memo, Code) > - Few more functions, like comparing of two cells of the notebook, > locking/unlocking etc > > It works OK for me but it is still experimental. > Please be careful when you start to use it! > > The package link > > Yuri Kandrashkin > -- Murray Eisenberg Internet: murray@math.umass.edu Mathematics & Statistics Dept. Voice: 413-545-2859 (W) University of Massachusetts 413-549-1020 (H) Amherst, MA 01003 Fax: 413-545-1801 === Subject: setting selection via char positions and setting its background \ color Ok, I can found out this works nicely: SetOptions[NotebookSelection[InputNotebook[]], Background -> LightBlue] but what I really want is a way to set the selection of via position of chars: charpos= {12, 23} ; SetOptions[NotebookSelection[charpos], Background -> LightBlue] Is there a way to do this kind of action? I want to set the background === Subject: Re: Print numbers to ASCII file with precise column widths Hi Chonny, I think PaddedForm mainly deals with real numbers. Therefore, the decimal separator is accounted for by \number of digits\. Therefore, for integers, you get one place more than indicated. To obtain an e-representation with a given fileswidth you may e.g. try: dat = Pi 1. 10^-10; fieldwidth = 8; t = ToString@ NumberForm[dat, {4, 2}, ExponentFunction -> (# &)]; While[StringLength[t] < fieldwidth, t = \ \ <> t]; t Daniel > I want to generate some \simple\ ASCII files suitable for reading > by old Fortran programs, which expect numbers in precise formatted > columns, e.g., \FORMAT(I5,F10.3,E10.5)\. I've been trying all sorts > of variations of PaddedForm, FortranForm, OutputForm, ..... > > Here's an example with a simple negative integer: > > strm = OpenWrite[\testout.txt\]; > WriteString[strm, ToString[ PaddedForm[-11, 5] ] <> \\\n\]; > WriteString[strm, \1234567890\]; > Close[strm]; > FilePrint[\testout.txt\]; > > -11 > 1234567890 > > The font in this post doesn't show it, but the \-11\ ends in the 6th > column, not the 5th. And then I need to tackle floats with > exponents!! I obviously don't understand the underlying Mathematica > V7 output functionality. > === Subject: Re: Compositing, 3D graphics, and KDE 4.2 > > I have version 7.0.0 running on a 32-bit linux system, in KDE 4.2 > > (radeonhd driver). Now, most of the stuff is esoteric, and I'm quite > > happy to have gotten everything running fast and stably and \ prettily, > > including Mathematica looking great. However, I've just noticed \ today > > that if I produce any 3D graphics (using Plot3D, or > > Graphics3D[Cylinder[{{0, 0, 0}, {0, 1, 0}}]], for example) that the \ 3D > > object shows up only if I'm actively rotating it or resizing it with > > the mouse. Otherwise, it disappears and looks like just a big blank > > space on the screen. I might try updating to 7.0.2 just in case that > > fixes things. > > I have tested this on 64bit KDE 4.2.2 with kwin compositing and \ Mathematica > 7.0.1 on two different machines, one using the proprietary Nvidia \ drivers, > the other the Intel graphics drivers. In either case, 3D graphs worked > without actively manipulating them. > > Therefore this might be an issue with you ATI drivers. I have no idea > whether this will help, but you might try different drivers, e.g. the > proprietary ATI driver (Catalyst 9.4 for Linux has been released \ recently, > IIRC). I have the same issue with the intel driver, no matter if compiz is enabled or not. So it seems that this problem is not specific to the ATI driver. Richard, were you able to find a solution to this? Best, Nikolaus === Subject: FindRoot inside FindMinimum I would like some help with a problem I'm facing using mathematica to model chemical kinetics. The specific question is about the use of FindRoot and FindMinimum. In the code attached I am trying to solve an non linear equation (blue) using FindRoot inside a FindMinimum loop (to fit 3 differents constant). As I am not successuful with the implementaion I wondering if FindRoot can be used insde FindMinimum. Is that possible? Can anyone can help. Mixed control - kinetics.pdf -- Professor Versiane Albis Le=E3o Laborat=F3rio de Hidrometalurgia/ Hydrometallurgy laboratory Departamento de Engenharia Metal=FArgica e de Materiais / Metallurgical \ and= Materials Engineering Address: Campus Morro do Cruzeiro, s.n.- 35400-000, Ouro Preto, MG, Brazil Tel/Phone: +55.31.3559.1102 Fax: +55.31.3559.1561 Email alternativo: va.leao@uol.com.br skype:versiane.albis.leao === Subject: Re: FindRoot inside FindMinimum here is a simple example for FindRoot inside FindMinimum. Note that we eunsure that f is only called with a numeric argument. f[a_?NumericQ] := Abs[x /. FindRoot[x + a, {x, 1}]]; FindMinimum[ f[a] , {a, 2}] Daniel > I would like some help with a problem I'm facing using mathematica to > model chemical kinetics. The specific question is about the use of > FindRoot and FindMinimum. In the code attached I am trying to solve an > non linear equation (blue) using FindRoot inside a FindMinimum loop (to > fit 3 differents constant). As I am not successuful with the > implementaion I wondering if FindRoot can be used insde FindMinimum. Is > that possible? Can anyone can help. > > > Mixed control - kinetics.pdf > > > > -- > Professor Versiane Albis Le=E3o > Laborat=F3rio de Hidrometalurgia/ Hydrometallurgy laboratory > Departamento de Engenharia Metal=FArgica e de Materiais / Metallurgical \ and= > Materials Engineering > Address: Campus Morro do Cruzeiro, s.n.- 35400-000, Ouro Preto, MG, \ Brazil > Tel/Phone: +55.31.3559.1102 > Fax: +55.31.3559.1561 > Email alternativo: va.leao@uol.com.br > skype:versiane.albis.leao > === Subject: Re: difference between HeavisidePi and UnitBox It depends on your purpose. For some simple purposes they are equivalent but there is a huge difference when you try to do calculus with them. You can perform most natural operations such as differentiation or integration on generalized functions: D[HeavisidePi[x], x] 2*DiracDelta[2*x + 1] - 2*DiracDelta[2*x - 1] which is a well behaved generalized function while D[UnitBox[x], x] Piecewise[{{Indeterminate, x == 1/2 || x == -(1/2)}}, 0] is the zero function with two undefined values at 1/2 and -1/2, basically a useless object. So, for example: Integrate[D[HeavisidePi[x], x], {x, -Infinity, 0}] 1 while naturally Integrate[D[UnitBox[x], x], {x, -Infinity, 0}] 0 I came up with these examples just off hand so they may look a bit artificial but it is easy to find ones that arise in serious problems. Andrzej Kozlowski > I understand that it doesn't matter. There's even some discussion > here about it http://mathworld.wolfram.com/RectangleFunction.html > > My question is regarding \The piecewise version of the rectangle > function is implemented in Mathematica as UnitBox[x], while the > generalized function version is implemented as HeavisidePi[x].\ > > why do we need both? I find the integral transforms (I use mostly > FourierTransform) actually work much better with the piecewise UnitBox > for 5-bar patterns that I like to use. > > Does anyone have a thorough explanation of when generalized functions > are better than piecewise and vice versa? > > -Anatoly > > On May 31, 6:33 pm, Jens-Peer Kuska >> >> what happens at x->1/2 and x->-1/2 with HeavisidePi[] and >> UnitBox[] ? >> >> For distributions like HeavisidePi[] that are used >> inside of an integral the single >> point does not matter. For functions like UnitBox[] it may be >> important. >> >> Jens >> >> >> >>> I am a very new user, and am not quite clear on the difference >>> between >>> general (HeavisidePi) and numerical (UnitBox, or piecewise) >>> functions. >> >>> When I try to create a 5-bar pattern using one of these and apply a >>> FourierTransform, I have varying degrees of success... >> >>> With HeavisidePi I can create an infinite series of them and >>> FourierTransform has no problems, but it doesn't like modifying the >>> argument as in HeavisidePi(x/w) >> >>> With UnitBox I have the opposite issue. >> >>> Is there a clear explanation on the difference between the two >>> groups >>> of functions, and when I should use which? > > === Subject: Re: difference between HeavisidePi and UnitBox I understand that it doesn't matter. There's even some discussion here about it http://mathworld.wolfram.com/RectangleFunction.html My question is regarding \The piecewise version of the rectangle function is implemented in Mathematica as UnitBox[x], while the generalized function version is implemented as HeavisidePi[x].\ why do we need both? I find the integral transforms (I use mostly FourierTransform) actually work much better with the piecewise UnitBox for 5-bar patterns that I like to use. Does anyone have a thorough explanation of when generalized functions are better than piecewise and vice versa? -Anatoly On May 31, 6:33 pm, Jens-Peer Kuska > > what happens at x->1/2 and x->-1/2 with HeavisidePi[] and UnitBox[] ? > > For distributions like HeavisidePi[] that are used > inside of an integral the single > point does not matter. For functions like UnitBox[] it may be important. > > Jens > > > > > I am a very new user, and am not quite clear on the difference between > > general (HeavisidePi) and numerical (UnitBox, or piecewise) functions. > > > When I try to create a 5-bar pattern using one of these and apply a > > FourierTransform, I have varying degrees of success... > > > With HeavisidePi I can create an infinite series of them and > > FourierTransform has no problems, but it doesn't like modifying the > > argument as in HeavisidePi(x/w) > > > With UnitBox I have the opposite issue. > > > Is there a clear explanation on the difference between the two groups > > of functions, and when I should use which? === Subject: Re: RandomReal gets stuck >By the way, Bill, there is nothing wrong with the use of square >brackets to index a variable. Check out the array function: >In[1]:= Array[y, 3] >Out[1]= {y[1], y[2], y[3]} >In[2]:= Do[y[i] = 3 - i, {i, 3}] >In[3]:= ?y >Global`y >y[1]=2 >y[2]=1 >y[3]=0 >In[4]:= Head[y] >Out[4]= Symbol >In[5]:= Head[y[1]] >Out[5]= Integer My comments about y[1] were not that this is invalid syntax or that it cannot be used in *some* cases like an indexed array or subscripted variable. The point is it cannot be used as an indexed array or subscripted variable in *all* cases. The syntax y[1] is for a function named y evaluated at 1. The is not the same as an indexed array nor the same as a subscripted variable. In fact, the it does not even behave like an ordinary variable in all ways. Specifically, for a ordinary symbol assignments cause that symbol to have an OwnValue not a DownValue. Assignments to a function cause the function to have a DownValue not an OwnValue. These are different and the difference as consequences in some evaluations. If you have a clear understanding of the differences between DownValues and OwnValues and know what you are doing, you undoubtedly will get the result you want when treating y[1] as a subscripted variable. On the other hand, if you lack a clear understanding of the differences sooner or later you will encounter unexpected issues (not bugs) when using y[1] as a subscripted variable. === Subject: Re: Min function returns Min[2.05875,] instead of Min[{{a, b, c}, {d, e, f}, {g, h, i}}] min(a,b,c,d,e,f,g,h,i) Min[{{a, {b, j}, c}, {d, e, f}, {g, h, {i, k}}}] min(a,b,c,d,e,f,g,h,i,j,k) Min will flatten its argument. Attributes[Min] {Flat,NumericFunction,OneIdentity,Orderless,Protected,ReadProtected} Bob Hanlon can you explain what the minimum of a set of vectors with dimension 248 is ? Or do you mean Min[Flatten[data]] ? Jens > I have an matrix \data\ with 17x248 real numbers. > > When I enter Min[data], I get > Min[2.05875, ] as a result, instead of just the number 2.05875. > > This is Mathematica 7.0.1 on Mac OS X. > > Why? > > How can I get just the number from the result? > > TIA > === Subject: Psychrometric chart Hi for all, Please could someone help me to plot the Mollier (i-x) psychrometric chart. Bob === Subject: Re: proper way of posing a non-autonomous ode in mathematica? in Mathematics, rather than in Mathematica. Let us see: 1. If you want to solve your system with respect to four unknown functions: \ a(t), b(t), k1(t) and k2(t), you MUST fix two other equations. No way around. Information \ contained in two equations is not enough, as you know. 2. If you want to get solution with two unknown functions a(t) and b(t), \ while k1(t) and k2(t) are some functions that are known, it may be possible. 3. For some functions k1(t)and k2(t) it may be even easy (as you mentioned \ it for t^-h), and for some functions it may happen that the system admits an analytical \ solution. For others it may not admit it, but numerical solution can be looked for. In general however,it is whatever you want, but not trivial. This point \ becomes clear, if one pays attention that your equations look pretty like a 1D Schroedinger equation (though it is not \ exactly Schroedinger in at least two aspects and that does not make it more simple). And it is well known \ that Schroedinger equation is solved analytically only in a very limited number of cases. Therefore, it is \ unreasonable to expect that Mathematica will return exact analytical solution of your equations for general \ functions k1(t) and k2(t). So, it is probably not the output you expect. Then what? Have a success, Alexei Hello group, I was trying to solve a simple ODE system that has parameters that are functions of time. Then I thought about it and I'm not sure if I'm doing it right. Let's say your system is a = -k1 (t^-h) -k2 (t^-h) b b = k1 (t) a Then in mathematica, a'[t] == - k1 (t ^-h) a[t] - k2 (t ^-h) b[t], b'[t] == k1 (t ^-h) a[t] which is solvable. but if I pose the k1 and k2 as a function of t, like k1[t^-h] and k2 [t^-h] Then the system becomes under-determined with 4 unknowns and 2 eqns... So my question is how do you pose/solve a non-autonomous ode in mathematica? Sean -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Re: problem with reduce consider the equation: jP == j - C[2]]. As j does not appear anywhere else j and jp are completely undetermined. Now consider: i == 1 + C[1] && N == 1 + C[1] + C[2]. As i and N do not appear anywhere else, these equation do not add any info. Finally: iP == 1 + C[1] + C[2] simply says that ip is an integer >=1. Therefore, the solution is: ip is an integer >=1 and jP an arbitrary \ number. Daniel > Hi mathematica community, > I have to solve this example > In[88]:= Reduce[Exists[{C[1], C[2]}, > Element[{C[1], C[2]}, Integers] && C[1] >= 0 && C[2] >= 0 && > i == 1 + C[1] && N == 1 + C[1] + C[2] && iP == 1 + C[1] + C[2] && > jP == j - C[2]], {iP, jP}, Backsubstitution -> True] > > During evaluation of In[88]:= Reduce::nsmet: This system cannot be > solved with the methods available to \\ > Reduce. >> > > I have observed that when I remove Element[{C[1], C[2]}, Integers] && C > [1] >= 0 && C[2] >= 0 like that: > In[89]:= Reduce[ > Exists[{C[1], C[2]}, > i == 1 + C[1] && N == 1 + C[1] + C[2] && iP == 1 + C[1] + C[2] && > jP == j - C[2]], {iP, jP}, Backsubstitution -> True] > > it gives me an output which is: > > Out[89]= iP == N && jP == i + j - N > > > I need to keep the information that Element[{C[1], C[2]}, Integers] && > C[1] >= 0 && C[2] >= 0 but reduce tells me that it cannot solve this > system. why and how to deal with this problem? > thank you. > === Subject: Re: problem with reduce After posting the message below I noticed that there is also another way (requiring, perhaps, a bit less less user intervention). Reduce[C[1] >= 0 && C[2] >= 0 && i == 1 + C[1] && N == 1 + C[1] + C[2] && iP == 1 + C[1] + C[2] && jP == j - C[2], {iP, jP}, Integers] Element[C[3] | C[4] | C[5] | C[6] | C[7], Integers] && C[3] >= 0 && C[4] >= 0 && C[5] >= 0 && C[6] >= 0 && C[7] >= 0 && i == C[3] + 1 && N == C[3] + C[4] + C[5] + 1 && C[1] == C[3] && C[2] == C[4] + C[5] && iP == C[3] + C[4] + C[5] + 1 && j == C[5] + C[6] - C[7] && jP == -C[4] + C[6] - C[7] This tells you that all solutions over the integers can be found by choosing any non-negative C[3],C[4]...C[7] and defining the values of the variables in terms of them. You can now find the relationship between the variables eliminating the C[i]: Eliminate[i == C[3] + 1 && N == C[3] + C[4] + C[5] + 1 && C[1] == C[3] && C[2] == C[4] + C[5] && iP == C[3] + C[4] + C[5] + 1 && j == C[5] + C[6] - C[7] && jP == -C[4] + C[6] - C[7], Table[C[i], {i, 1, 7}]] i == iP - j + jP && iP == N Andrzej Kozlowski > First the reason. This is an example of what is called \quantifier > elimination\ (in this case one eliminates the quantifier Exists). > Algorithms for quantifier elimination exist only for polynomial > formulas with real number coefficients (or more generally with > coefficients in real closed fields). This was first shown by the > Polish logician Alfred Tarski, although modern algorithms are much > faster. However, there is no algorithm for quantifier elimination > over the integers. It's not just that one is now known, we know that > there cannot be any general algorithm. Mathematica can, however, do > this in certain special cases by using heuristic methods. > > However, since everything in your system is linear, you can simply > eliminate quantifiers over the reals and then add Simplify using the > assumption that everything is an integer: > > > sols=Simplify[Reduce[ > Exists[{C[1], C[2]}, > Element[{C[1], C[2]}, Reals] && C[1] >= 0 && C[2] >= 0 && i == 1 + > C[1] && > N == 1 + C[1] + C[2] && > iP == 1 + C[1] + C[2] && jP == j - C[2]], {iP, jP}, > Backsubstitution -> True], > Element[C[1] | C[2] | i | j | N | iP | jP, Integers]] > > (N == 1 && i == 1 && iP == 1 && j == jP) || (N > 1 && 1 <= i <= N && > iP == N && > i + j == jP + N) > > > Lets now try to check if these really satisfy the original > conditions. First, the original conditions (over the Integers) were: > > cond = Exists[{C[1], C[2]}, > Element[{C[1], C[2]}, Integers] && C[1] >= 0 && C[2] >= 0 && > i == 1 + C[1] && N == 1 + C[1] + C[2] && iP == 1 + C[1] + C[2] && > jP == j - C[2]]; > > It is easy to verify that the first solution N == 1 && i == 1 && iP > == 1 && j == jP is a solution because now quantifier elimination > over the integers has become trivial: > > Reduce[cond /. ToRules[sols[[1]]]] > True > > In fact, you can simply what C[1] and C[2] must be, treating the > condition as a linear system of equations and inequalities: > > Reduce[C[1] >= 0 && C[2] >= 0 && i == 1 + C[1] && N == 1 + C[1] + > C[2] && > iP == 1 + C[1] + C[2] && jP == j - C[2] && sols[[1]], {C[1], C[2], > iP, > jP}, Reals, > Backsubstitution -> True] > > N == 1 && i == 1 && C[1] == 0 && C[2] == 0 && iP == 1 && jP == j > > is, of course, an integer. So we are sure we have one solution: > > N == 1 && i == 1 && iP == 1 && jP==j > > > In the other case, Reduce still cannot prove that a solution exists > if we try quantifier eleimination, but you can simply again consider > everything as a linear system and find C[1] and C[2]: > > Reduce[C[1] >= 0 && C[2] >= 0 && i == 1 + C[1] && N == 1 + C[1] + > C[2] && > iP == 1 + C[1] + C[2] && jP == j - C[2] && sols[[2]], {C[1], C[2], > iP, > jP}, Reals, > Backsubstitution -> True] > > N > 1 && 1 <= i <= N && C[1] == i - 1 && C[2] == N - i && iP == N && > jP == i + j - N > > > This again shows you that provided both N and i are integers, C[1] > and C[2] will also be integers, so the system has actually been > solved over the integers. So the second solution you want can be > written > > > Element[N, Integers] && Element[i, Integers] && N > 1 && 1 <= i <= > N && iP == N && jP == i + j - N > > > Andrzej Kozlowski > > >> Hi mathematica community, >> I have to solve this example >> In[88]:= Reduce[Exists[{C[1], C[2]}, >> Element[{C[1], C[2]}, Integers] && C[1] >= 0 && C[2] >= 0 && >> i == 1 + C[1] && N == 1 + C[1] + C[2] && iP == 1 + C[1] + C[2] && >> jP == j - C[2]], {iP, jP}, Backsubstitution -> True] >> >> During evaluation of In[88]:= Reduce::nsmet: This system cannot be >> solved with the methods available to \\ >> Reduce. >> >> >> I have observed that when I remove Element[{C[1], C[2]}, Integers] >> && C >> [1] >= 0 && C[2] >= 0 like that: >> In[89]:= Reduce[ >> Exists[{C[1], C[2]}, >> i == 1 + C[1] && N == 1 + C[1] + C[2] && iP == 1 + C[1] + C[2] && >> jP == j - C[2]], {iP, jP}, Backsubstitution -> True] >> >> it gives me an output which is: >> >> Out[89]= iP == N && jP == i + j - N >> >> >> I need to keep the information that Element[{C[1], C[2]}, Integers] >> && >> C[1] >= 0 && C[2] >= 0 but reduce tells me that it cannot solve this >> system. why and how to deal with this problem? >> thank you. >> > === Subject: Re: Keep Slider Consistent With a Slow Graph You cannot plot without a numeric value for xMax so definition sholud be \ restricted to numeric input plotSlowGraph[xMax_?NumericQ] := Module[{x, t}, Plot[ NIntegrate[1/((t^2 - 1)*t*Log[t]), {t, x, Infinity}], {x, 2, xMax}]]; To ensure that they are synched, set option SynchronousUpdating to True Manipulate[plotSlowGraph[xMax], {{xMax, 10, \x Max\}, 10, 400, 10, Appearance -> \Labeled\}, SynchronousUpdating -> True, ContinuousAction -> False, SaveDefinitions -> True] Bob Hanlon The graph displayed by the Manipulate below takes a while to display. While the calculation is taking place, if you click on some other value on the slider, the slider moves and displays its new value. However, the graph will plot using the original value. The result is that the graph and the slider are now out of sync. This is bad user interface design. In the real example I am working with, there is no way to make the calculations go fast enough to keep up with clicks on the slider. For the same reason, I cannot allow the user to slide the slider, so ContinuousAction must be False. Nevertheless, is there some way to make sure the slider and the graph stay consistent with each other? Robert Baillie plotSlowGraph[xMax_] := Module[ { x, t }, Plot[ NIntegrate[1/((t^2 - 1)*t*Log[t]), {t, x, Infinity}], {x, 2, xMax} ] ]; Manipulate[ Graphics[ plotSlowGraph[xMax] ], { {xMax, 10, \x Max\}, 10, 400, 10, Appearance -> \Labeled\ }, ContinuousAction -> False, SaveDefinitions->True ] === Subject: Re: Accessing Dictionary definitions Select[WordData[All, \Noun\], Not[FreeQ[WordData[#], \VarietyMeat\]] &] {brain,heart,liver,tongue,tripe} Bob Hanlon Can anyone guide whether Mathematica, can return words that have common elements in their Definitions ? For example, WordData[\liver\, \Definitions\] shows\ liver\ has been given a definition that includes {\liver\, \Noun\, \VarietyMeat\}. Is there a way to, for example, return all words that are \VarietyMeat\ ? === Subject: Mathematica Hi! I have a little question about Mathematica. I have defined a lattice using \ the adjacency matrix, and I want to determine all the possible paths on my \ lattice from site i to site j (i may be equal to j) that have a given \ Manhattan length. I have found the function \NumberOfKPaths\ that counts these paths, but I \ don't know how to ask Mathematica not only to count them, but also to print \ them... Julien. === Subject: uncomplete NDSOlve results I numerically simulated an ODE systems with NDSOlve. I tried all kinds of methods and I always get a solution back, seemingly over the whole integration interval, i.e. 100: sol={{A->InterpolatingFunction[{{0.,100.}},<>]}}. However, when I plot A (Plot[A[t]/.sol,{t,0,100},PlotRange->All]) the curve just stops after a fraction of the simulation time. So, there seems to be no solution after a certain time. But upon integration I get no errors. jordi === Subject: How to handle Units of Measure In this very simple example if I write R+iwL where R is measured in Ohms, w in s^-1, L in H, I expect that the result is given in Ohms. Why it doesn't happen in Mathematica ? Ho can I do to handle in a simple way those conversions ? === Subject: DebugTrace version 1.02 I have just uploaded version 1.02 of my DebugTrace package to my website. The new version contains some extra facilities to help in debugging dynamic constructions (including, but not limited to Manipulate). please feel free to contribute new ideas, bugs (perhaps these should be called meta-bugs) or whatever. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: seems I broke the FE of V7 Hello John: Nope. I reboot-ed Mathematica and the OS several times. When I tried to \ backup all my files since V7 was installed, some .nb files could not be \ copied. XP xcopy complained that they were \invalid directories\ and that I \ should \run chkdsk\. So something bad happened at some point. No evidence \ Mathematica caused this, but the usual suspects are *not* installed (i.e. \ VisStudio, Office, VPN S/W etc.). Also, I found out the V7.0.1 link they sent to me [some weeks ago] was stale \ so I requested a refresh. Roger Williams Franklin Laboratory === Subject: Re: seems I broke the FE of V7 Cc: mathgroup@smc.vnet.net I'd definitely recommend upgrading to 7.0.1 regardless. Did the problem go \ away when you restart Mathematica? A difficult-to-reproduce problem similar \ to this was reported in 7.0.0 which only lasted until you restarted the \ session. I don't recall the same problem having been reported against 7.0.1, \ although I wouldn't swear to it. I wouldn't expect the loading of a Demonstrations notebook to cause any \ problems. John Fultz User Interface Group jfultz@wolfram.com > Hello UG: > > I was using my XP based V7 system just fine until an hour ago or so. > Now all notebooks are unformatted. When I give a simple string \2+2\, > then Ctrl-Enter does not evaluate it. The interface and the menus look > OK, but then I noticed that Format>>Style shows no styles, only a menu > separator and then \Other\. > > I can guess that no cells are input cells, so they cannot be > evaluated. But how could I have blown all my styles away. > > The only \suspicious\ thing that happened is that I downloaded a > Demostrations source package (about Planck's constant I think). It > evaluated and ran OK. I used help and ran some simple evals after the > Demonstration. > > Any helpful thoughts? Maybe I have to go to 7.0.1 now. > > TIA. > > > Roger Williams > Franklin Laboratory > === Subject: Shade area between two polar curves Hi All I have plotted two graphs using PolarPlot, namely the limacon r=1+2 cos(t) and the circle r = 2 from t = 0 to t = 2 Pi. and I wish to shade the area inside the limacon but outside the circle. Can anyone suggest a way to do it? Chee === Subject: Re: Shade area between two polar curves Hi Chee, try RegionPlot. Remember that Cos[t]=1/Sqrt[1+Tan[t]^2]: f[x_, y_] := 1 + 2/Sqrt[1 + y^2/x^2] > Sqrt[x^2 + y^2] && Sqrt[x^2 + y^2] > 2 RegionPlot[f[x, y], {x, 0, 3}, {y, -2, 2}] Daniel > Hi All > > I have plotted two graphs using PolarPlot, namely the limacon r=1+2 \ cos(t) > and the circle r = 2 from t = 0 to t = 2 Pi. and I wish to shade the area > inside the limacon but outside the circle. Can anyone suggest a way to do > it? > > Chee > === Subject: Re: Shade area between two polar curves > Hi All > > I have plotted two graphs using PolarPlot, namely the limacon r=1+2 \ cos(t) > and the circle r = 2 from t = 0 to t = 2 Pi. and I wish to shade the area > inside the limacon but outside the circle. Can anyone suggest a way to do > it? Something like this? r[t_] = 1 + 2 Cos[t]; s[t_] = 2; plot1 = PolarPlot[{r[t], s[t]}, {t, 0, 2 \\[Pi]}, PlotStyle -> Thick]; plot2 = ParametricPlot[{u r[t] Cos[t], u r[t] Sin[t]}, {u, 0, 1}, {t, -\\[Pi]/3, \\[Pi]/3}, RegionFunction -> Function[{x, y, u, t}, u r[t] > s[t]], Mesh -> None]; Show[{plot1, plot2}, PlotRange -> Automatic] -- Helen Read University of Vermont === Subject: Re: list manipulation data = { {element11, element12, element1N, target11, target12, element1N3, element1N4}, {element21, element22, element2N, target21, target22, element2N3, element2N4} }; data //. { {s___, target11, target12, e___} :> {s, f[target11, target12], e}, {s___, target21, target22, e___} :> {s, f[target21, target22], e} } {{element11, element12, element1N, f[target11, target12], element1N3, element1N4}, {element21, element22, element2N, f[target21, target22], element2N3, element2N4}} data //. ( {s___, Sequence @@ #, e___} :> {s, f @@ #, e} & /@ {{target11, target12}, {target21, target22}} ) {{element11, element12, element1N, f[target11, target12], element1N3, element1N4}, {element21, element22, element2N, f[target21, target22], element2N3, element2N4}} % == %% True Bob Hanlon I'm wondering if anyone has bright ideas on the puzzle below. I'm trying to take a very large list of the following form: {{.., .., a, b, ..},{.., .., c, d, ..},..} into the form {{.., .., f[a, b], ..},{.., .., f[c, d], ..},..} It seems to me that there must be some clever and beautiful way to do this that I haven't thought of. My code is below with two clumsy solutions. Suggestions on how to do better? My code: In[1]:= (*shown here as minimal to define problem but actual list has \\ large N and many entries*) data = {{element11, element12, element1N, target11, target12, element1N3, element1N4}, {element21, element22, element2N, target21, target22, element2N3, element2N4}}; In[2]:= (* first clumsy approach *) Replace[data, list : _List :> {Sequence @@ list[[1 ;; 3]], Sequence[f[list[[4 ;; 5]]]], Sequence @@ list[[6 ;;]]}, {1}] Out[2]= {{element11, element12, element1N, f[{target11, target12}], element1N3, element1N4}, {element21, element22, element2N, f[{target21, target22}], element2N3, element2N4}} In[3]:= (* second clumsy approach *) data /. {a : Repeated[_, {3}], b : Repeated[_, {2}], c : __} -> {a, f[b], c} Out[3]= {{element11, element12, element1N, f[target11, target12], element1N3, element1N4}, {element21, element22, element2N, f[target21, target22], element2N3, element2N4}} === Subject: Re: Accessing Dictionary definitions Select[WordData[All, \Noun\], Not[FreeQ[WordData[#], \VarietyMeat\]] &] {brain,heart,liver,tongue,tripe} Bob Hanlon Can anyone guide whether Mathematica, can return words that have common elements in their Definitions ? For example, WordData[\liver\, \Definitions\] shows\ liver\ has been given a definition that includes {\liver\, \Noun\, \VarietyMeat\}. Is there a way to, for example, return all words that are \VarietyMeat\ ? === Subject: uncomplete NDSOlve results I numerically simulated an ODE systems with NDSOlve. I tried all kinds of methods and I always get a solution back, seemingly over the whole integration interval, i.e. 100: sol={{A->InterpolatingFunction[{{0.,100.}},<>]}}. However, when I plot A (Plot[A[t]/.sol,{t,0,100},PlotRange->All]) the curve just stops after a fraction of the simulation time. So, there seems to be no solution after a certain time. But upon integration I get no errors. jordi === Subject: Mathematica Hi! I have a little question about Mathematica. I have defined a lattice using \ the adjacency matrix, and I want to determine all the possible paths on my \ lattice from site i to site j (i may be equal to j) that have a given \ Manhattan length. I have found the function \NumberOfKPaths\ that counts these paths, but I \ don't know how to ask Mathematica not only to count them, but also to print \ them... Julien. === Subject: Re: seems I broke the FE of V7 Hello John: Nope. I reboot-ed Mathematica and the OS several times. When I tried to \ backup all my files since V7 was installed, some .nb files could not be \ copied. XP xcopy complained that they were \invalid directories\ and that I \ should \run chkdsk\. So something bad happened at some point. No evidence \ Mathematica caused this, but the usual suspects are *not* installed (i.e. \ VisStudio, Office, VPN S/W etc.). Also, I found out the V7.0.1 link they sent to me [some weeks ago] was stale \ so I requested a refresh. Roger Williams Franklin Laboratory === Subject: Re: seems I broke the FE of V7 Cc: mathgroup@smc.vnet.net I'd definitely recommend upgrading to 7.0.1 regardless. Did the problem go \ away when you restart Mathematica? A difficult-to-reproduce problem similar \ to this was reported in 7.0.0 which only lasted until you restarted the \ session. I don't recall the same problem having been reported against 7.0.1, \ although I wouldn't swear to it. I wouldn't expect the loading of a Demonstrations notebook to cause any \ problems. John Fultz User Interface Group jfultz@wolfram.com > Hello UG: > > I was using my XP based V7 system just fine until an hour ago or so. > Now all notebooks are unformatted. When I give a simple string \2+2\, > then Ctrl-Enter does not evaluate it. The interface and the menus look > OK, but then I noticed that Format>>Style shows no styles, only a menu > separator and then \Other\. > > I can guess that no cells are input cells, so they cannot be > evaluated. But how could I have blown all my styles away. > > The only \suspicious\ thing that happened is that I downloaded a > Demostrations source package (about Planck's constant I think). It > evaluated and ran OK. I used help and ran some simple evals after the > Demonstration. > > Any helpful thoughts? Maybe I have to go to 7.0.1 now. > > TIA. > > > Roger Williams > Franklin Laboratory > === Subject: How to handle Units of Measure In this very simple example if I write R+iwL where R is measured in Ohms, w in s^-1, L in H, I expect that the result is given in Ohms. Why it doesn't happen in Mathematica ? Ho can I do to handle in a simple way those conversions ? === Subject: Correlating two lists Hi all. I have the following problem: Two lists: \x\ and \y\; and a boolean relation R[a,b] with a in x and b in y, and for each \a\ there is at most one \b\ in \y\ such that R[xi,yj]is true. R is also \expensive\ to calculate. I would like to group each xi in \x\ with its partner in \y\ (if there is one) and create a merged list: {{x1,y1},{x2},{x3},{x4,y4},...} such that R[xi,yi] is true I'm looking for the adequate Mathematica function to do this as efficiently as possible. by the way, I'm using now this straightforward-naive approach: merged={}; Do[Do[If[R[xi,yj],merged=Append[merged,{xi,yj}]],{yj,y}];If[MemberQ[merge[[A\ ll,1]],xi],merged=Append[merged,{xi}]],{xi,x}] but I'm sure there must be a better one (without the Do's would be \ beautiful). Any thoughts will be greatly appreciated. Atte. Andres Guzman ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. === Subject: Correlating two lists Hi all. I have the following problem: Two lists: \x\ and \y\; and a boolean relation R[a,b] with a in x and b in y, and for each \a\ there is at most one \b\ in \y\ such that R[xi,yj]is true. R is also \expensive\ to calculate. I would like to group each xi in \x\ with its partner in \y\ (if there is one) and create a merged list: {{x1,y1},{x2},{x3},{x4,y4},...} such that R[xi,yi] is true I'm looking for the adequate Mathematica function to do this as efficiently as possible. by the way, I'm using now this straightforward-naive approach: merged={}; Do[Do[If[R[xi,yj],merged=Append[merged,{xi,yj}]],{yj,y}];If[MemberQ[merge[[A\ ll,1]],xi],merged=Append[merged,{xi}]],{xi,x}] but I'm sure there must be a better one (without the Do's would be \ beautiful). Any thoughts will be greatly appreciated. Atte. Andres Guzman ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. === Subject: Re: Correlating two lists Function[xi,{xi,Sequence@@Select[y,R[xi,#]&,1]}] /@ x > Hi all. > I have the following problem: > Two lists: \x\ and \y\; and a boolean relation R[a,b] with a in x \ and > b in y, and for each \a\ there is at most one \b\ in \y\ such that > R[xi,yj]is true. > R is also \expensive\ to calculate. I would like to group each xi in > \x\ with its partner in \y\ (if there is one) and create a merged \ list: > {{x1,y1},{x2},{x3},{x4,y4},...} > such that R[xi,yi] is true > I'm looking for the adequate Mathematica function to do this as > efficiently as possible. by the way, I'm using now this > straightforward-naive approach: > > merged={}; > \ Do[Do[If[R[xi,yj],merged=Append[merged,{xi,yj}]],{yj,y}];If[MemberQ[merge[[Al\ l,1]],xi],merged=Append[merged,{xi}]],{xi,x}] > > but I'm sure there must be a better one > (without the Do's would be beautiful). > Any thoughts will be greatly appreciated. > > Atte. Andres Guzman > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. === Subject: DebugTrace version 1.02 I have just uploaded version 1.02 of my DebugTrace package to my website. The new version contains some extra facilities to help in debugging dynamic constructions (including, but not limited to Manipulate). please feel free to contribute new ideas, bugs (perhaps these should be called meta-bugs) or whatever. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: evaluating functions within Findminimum write a function, i.e., myfunction[l1_?NumericQ,l2_?NumericQ,l3_?NumericQ,ps1_?NumericQ,ps2_?Numeric\ Q,ps3_?NumericQ]:= ... and FindMinimum[myfunction[l1,l2,l3,ps1,ps2,ps3], Evaluate[Sequence @@ startval]] Jens > > I'm using > > FindMinimum[Evaluate[e . Inverse[NormalAcov[sigma]]. e], Evaluate[Sequence \ @@ startval]] > > NormalAcov[sigma] is a symbolic function. FindMinimum evaluates \ Inverse[NormalAcov[sigma]] symbolically then plugs in the numeric starting \ values and proceeds. This is obviously very slow for large problems. > > How can I get FindMinimum to first plug in the numeric starting values and \ perform Inverse[NormalAcov[sigma]] numerically as opposed to symbolically? > > In case my question is unclear, here's a toy example > > sigma = {{l1^2 + ps1, l1* l2, l1*l3}, {l1* l2, l2^2 + ps2, l2 l3}, {l1 l3, \ l2 l3, l3^2 + ps3}}; > startval = {{l1, .8}, {l2, .7}, {l3, .6}, {ps1, 1}, {ps2, 1}, {ps3, 1}}; > e = {1.7 - l1^2 - ps1, .5 - l1*l2, 1.6 - l2 - ps2, 1.5 - l1^2 - l3, .8 - \ l2*l3, 1.8 - l3^2 - ps3}; > FindMinimum[Evaluate[e . Inverse[NormalAcov[sigma]]. e], Evaluate[Sequence \ @@ startval]] > > with > > NormalAcov[matrix_List] := Module[{l1, l, c}, > l1 = Length[matrix]; > l = Binomial[l1 + 1, 2]; > c = Join @@ Table[{i, j}, {i, l1}, {j, 1, i }]; > Table[matrix[[c[[i, 1]], c[[j, 1]]]]*matrix[[c[[i, 2]], c[[j, 2]]]] + \ matrix[[c[[i, 1]], c[[j, 2]]]]*matrix[[c[[i, 2]], c[[j, 1]]]] > , {i, l}, {j, l}]]; > > > Alberto > === Subject: Re: evaluating functions within Findminimum write a function, i.e., myfunction[l1_?NumericQ,l2_?NumericQ,l3_?NumericQ,ps1_?NumericQ,ps2_?Numeric\ Q,ps3_?NumericQ]:= ... and FindMinimum[myfunction[l1,l2,l3,ps1,ps2,ps3], Evaluate[Sequence @@ startval]] Jens > > I'm using > > FindMinimum[Evaluate[e . Inverse[NormalAcov[sigma]]. e], Evaluate[Sequence \ @@ startval]] > > NormalAcov[sigma] is a symbolic function. FindMinimum evaluates \ Inverse[NormalAcov[sigma]] symbolically then plugs in the numeric starting \ values and proceeds. This is obviously very slow for large problems. > > How can I get FindMinimum to first plug in the numeric starting values and \ perform Inverse[NormalAcov[sigma]] numerically as opposed to symbolically? > > In case my question is unclear, here's a toy example > > sigma = {{l1^2 + ps1, l1* l2, l1*l3}, {l1* l2, l2^2 + ps2, l2 l3}, {l1 l3, \ l2 l3, l3^2 + ps3}}; > startval = {{l1, .8}, {l2, .7}, {l3, .6}, {ps1, 1}, {ps2, 1}, {ps3, 1}}; > e = {1.7 - l1^2 - ps1, .5 - l1*l2, 1.6 - l2 - ps2, 1.5 - l1^2 - l3, .8 - \ l2*l3, 1.8 - l3^2 - ps3}; > FindMinimum[Evaluate[e . Inverse[NormalAcov[sigma]]. e], Evaluate[Sequence \ @@ startval]] > > with > > NormalAcov[matrix_List] := Module[{l1, l, c}, > l1 = Length[matrix]; > l = Binomial[l1 + 1, 2]; > c = Join @@ Table[{i, j}, {i, l1}, {j, 1, i }]; > Table[matrix[[c[[i, 1]], c[[j, 1]]]]*matrix[[c[[i, 2]], c[[j, 2]]]] + \ matrix[[c[[i, 1]], c[[j, 2]]]]*matrix[[c[[i, 2]], c[[j, 1]]]] > , {i, l}, {j, l}]]; > > > Alberto > === Subject: Re: Accessing Dictionary definitions here is a bruto force solution: In[37]:= words = Flatten[WordData[#] & /@ WordData[], 1]; In[38]:= Select[words, Length[#] == 3 && #[[3]] == \VarietyMeat\ &] Out[38]= {{\brain\, \Noun\, \VarietyMeat\}, {\heart\, \Noun\, \VarietyMeat\}, {\liver\, \Noun\, \VarietyMeat\}, {\tongue\, \ \Noun\, \VarietyMeat\}, {\tripe\, \Noun\, \VarietyMeat\}} Greeting from Croatia, Drago > Can anyone guide whether Mathematica, can return words that have > common elements in their Definitions ? For example, WordData[\liver\, > \Definitions\] shows\ liver\ has been given a definition that \ includes > {\liver\, \Noun\, \VarietyMeat\}. Is there a way to, for example, > return all words that are \VarietyMeat\ ? > > > === Subject: Re: Accessing Dictionary definitions getKind[word_] := {word, Last /@ First /@ WordData[word, \Definitions\]} selectKind[{w_, lst_List}, what_] := MemberQ[lst, what] and (If[selectKind[getKind[#], \VarietyMeat\], #, {}] & /@ WordData[]) /. {} :> Sequence[] Jens > Can anyone guide whether Mathematica, can return words that have > common elements in their Definitions ? For example, WordData[\liver\, > \Definitions\] shows\ liver\ has been given a definition that \ includes > {\liver\, \Noun\, \VarietyMeat\}. Is there a way to, for example, > return all words that are \VarietyMeat\ ? > > > === Subject: Re: Accessing Dictionary definitions here is a bruto force solution: In[37]:= words = Flatten[WordData[#] & /@ WordData[], 1]; In[38]:= Select[words, Length[#] == 3 && #[[3]] == \VarietyMeat\ &] Out[38]= {{\brain\, \Noun\, \VarietyMeat\}, {\heart\, \Noun\, \VarietyMeat\}, {\liver\, \Noun\, \VarietyMeat\}, {\tongue\, \ \Noun\, \VarietyMeat\}, {\tripe\, \Noun\, \VarietyMeat\}} Greeting from Croatia, Drago > Can anyone guide whether Mathematica, can return words that have > common elements in their Definitions ? For example, WordData[\liver\, > \Definitions\] shows\ liver\ has been given a definition that \ includes > {\liver\, \Noun\, \VarietyMeat\}. Is there a way to, for example, > return all words that are \VarietyMeat\ ? > > > === Subject: Re: Accessing Dictionary definitions getKind[word_] := {word, Last /@ First /@ WordData[word, \Definitions\]} selectKind[{w_, lst_List}, what_] := MemberQ[lst, what] and (If[selectKind[getKind[#], \VarietyMeat\], #, {}] & /@ WordData[]) /. {} :> Sequence[] Jens > Can anyone guide whether Mathematica, can return words that have > common elements in their Definitions ? For example, WordData[\liver\, > \Definitions\] shows\ liver\ has been given a definition that \ includes > {\liver\, \Noun\, \VarietyMeat\}. Is there a way to, for example, > return all words that are \VarietyMeat\ ? > > > === Subject: Re: NIntegrate & Integrate In[1]:= {a,b}={8.76,4.56}; NIntegrate[2*Cos[x],{x,a,b}] Out[2]= -3.21059 In[3]:= Integrate[2*Cos[x],{x,a,b}] Out[3]= -3.21059 In[4]:= $Version Out[4]= 7.0 for Mac OS X x86 (32-bit) (February 18, 2009) 2009/5/22 Konstantin : > Hello everybody, > > Easy question for Mathematica. Evaluate definite integral: 2*Cos[x] from \ = 8.76 to 4.56. > > I have evaluated it three different ways: Integrate, NIntegrate and \ Integ= ral sign from basic math input palette. > > Here is the code(without Integral sign from basic math input palette): > > Clear[x] > {a, b} = {8.76, 4.56}; > NIntegrate[2*Cos[x], {x, a, b}] > Clear[x] > Integrate[2*Cos[x], {x, a, b}] > > My output is: > > 3.21059(NIntegrate) > -3.21059(Integrate) > > The right answer is -3.21059. > > > Konstantin > > -- Peter Lindsay === Subject: Re: NIntegrate & Integrate In[1]:= {a,b}={8.76,4.56}; NIntegrate[2*Cos[x],{x,a,b}] Out[2]= -3.21059 In[3]:= Integrate[2*Cos[x],{x,a,b}] Out[3]= -3.21059 In[4]:= $Version Out[4]= 7.0 for Mac OS X x86 (32-bit) (February 18, 2009) 2009/5/22 Konstantin : > Hello everybody, > > Easy question for Mathematica. Evaluate definite integral: 2*Cos[x] from \ = 8.76 to 4.56. > > I have evaluated it three different ways: Integrate, NIntegrate and \ Integ= ral sign from basic math input palette. > > Here is the code(without Integral sign from basic math input palette): > > Clear[x] > {a, b} = {8.76, 4.56}; > NIntegrate[2*Cos[x], {x, a, b}] > Clear[x] > Integrate[2*Cos[x], {x, a, b}] > > My output is: > > 3.21059(NIntegrate) > -3.21059(Integrate) > > The right answer is -3.21059. > > > Konstantin > > -- Peter Lindsay === Subject: Re: Basic question about Mathematica Interface > Hi Bob > lution is too complex. I looked at the Options Inspector, but there were \ to= o many things that could be edited there, and I couldn't figure out which \ o= ne would make all notebooks (new as well as saved) open at a prescribed \ spo= t on my screen, with a prescribed window size. I didn't want to make any \ ch= anges that might break something. > > As I understand it, even if I had been successful, this would only fix \ th= e notebook window position. The help browser window requires a different \ fi= x, and the menu bar position/size is currently not fixable. So I would \ stil= l have to fiddle around with that stuff no matter what. > > Again, I appreciate your help. > > I am a new user of Mathematica (having used another system through my \ sch= ool years), and I must confess to being disappointed. I tried Mathematica \ o= nce before (I think it was at version 6 then, perhaps), only to find that \ i= ts HTML rendering engine was broken, and notebook files outputted as HTML \ g= ot truncated. That was a make-or-break feature for me, since I needed to \ be= able to post notebooks as HTML on web pages. I believe they never did get \ = around to fixing that for version 6. > > Now we have version 7, in this day and age, acting as if people are \ still= using 800x600 screens with one application open at a time, and it needs \ to= plaster its menu bar way across the whole screen. No application frame, \ no= convenient way to tell windows where to open and how big they should be. > > I will try it a bit longer, but I am wondering if this lack of polish \ ext= ends deeper into the program. > > Dave M. One BIG difference in the user interface in the Options Inspector on Windows and Macs is that on the Mac, as you type in a string to search for, the list of items shown gets shorter and shorter very quickly, while on the Windows version the list stays the same length and items with the string in question get highlighted which helps some, but you are right about the list being so long. I wish that Wolfram would change the functionality of the Windows version to duplicate the way that this winnowing occurs on the Mac. The actual parameters to change are WindowSize and WindowMargins (palettes don't usually use WindowSize since the windowsize is not really changeable like a notebook window is as the layout would be really ugly if you did change it I am guessing). For example, in my init.m file I have the following (only a portion): PalettesMenuSettings->{ \ClassroomAssistant.nb\ -> { WindowMargins -> {{Automatic, -93}, {Automatic, 0}}, TaggingRules -> { \ShowCalculator\ -> True, \ShowNavigation\ -> False, \ShowBasicCommands\ -> False, \ShowWritingTools\ -> False, \ShowBasicTypesetting\ -> True, \ShowAbcKeyboard\ -> True, \ShowHelpLinks\ -> False, \PaletteMode\ -> 1, \OptionsInsertionMode\ -> 1, \ShowNavigationTools\ -> False}}, \SpecialCharacters.nb\ -> { WindowMargins -> {{Automatic, 83}, {101, Automatic}}}} So this puts up the \ClassroomAssistant\ and \SpecialCharacters\ palettes at the indicated margin settings (which is the way to set the position). You should read about what these numbers really mean in the Documentation Center (look up WindowMargins) and realize that the size of the window in combination with the margin settings need to both be taken into account to understand where the window or palette really gets located on your screen. In the case where there are more than one screen or monitors, sometimes the values to WindowMargins are negative, as there is no concept of multiple monitors in Mathematica, so depending on how the second monitor is located relative to the first monitor (on my Mac you can easily setup the second monitor to be to the left, right, above or below the primary monitor - and I think the same is true on Windows), will dictate which of the left/right/bottom/top values to set (usually only two of these have values and the other two are set to Automatic according to the DC). Keep in mind that these WindowMargins[] and WindowSize[] values are dynamically settable even after the window or palette are created using either the Option Inspector or by just moving or resizing them. If you don't quite see how to set the values, play around with moving them to different parts of your screen(s) and see what the resulting values are in the init.m file (this file usually gets written to when you exit Mathematica). If you change the position or size of a notebook window, these values get written to the file when it's saved. I empathize with your frustration with the user interface inconsistancies and difficulties, but the pluses of Mathematica far outweigh the minuses IMO, so try and keep an open mind about how things work and do the best you can, and play around with different features and read the documentation and ask lots of questions. This group is fantastically helpful and as you use Mathematica more and more you will get better and better at dealing with and understanding the software. It really is a worthwhile investment in time and effort if your future involves any sort of a technical aspect. Good luck... -Bob === Subject: Re: Basic question about Mathematica Interface > Hi Bob > lution is too complex. I looked at the Options Inspector, but there were \ to= o many things that could be edited there, and I couldn't figure out which \ o= ne would make all notebooks (new as well as saved) open at a prescribed \ spo= t on my screen, with a prescribed window size. I didn't want to make any \ ch= anges that might break something. > > As I understand it, even if I had been successful, this would only fix \ th= e notebook window position. The help browser window requires a different \ fi= x, and the menu bar position/size is currently not fixable. So I would \ stil= l have to fiddle around with that stuff no matter what. > > Again, I appreciate your help. > > I am a new user of Mathematica (having used another system through my \ sch= ool years), and I must confess to being disappointed. I tried Mathematica \ o= nce before (I think it was at version 6 then, perhaps), only to find that \ i= ts HTML rendering engine was broken, and notebook files outputted as HTML \ g= ot truncated. That was a make-or-break feature for me, since I needed to \ be= able to post notebooks as HTML on web pages. I believe they never did get \ = around to fixing that for version 6. > > Now we have version 7, in this day and age, acting as if people are \ still= using 800x600 screens with one application open at a time, and it needs \ to= plaster its menu bar way across the whole screen. No application frame, \ no= convenient way to tell windows where to open and how big they should be. > > I will try it a bit longer, but I am wondering if this lack of polish \ ext= ends deeper into the program. > > Dave M. One BIG difference in the user interface in the Options Inspector on Windows and Macs is that on the Mac, as you type in a string to search for, the list of items shown gets shorter and shorter very quickly, while on the Windows version the list stays the same length and items with the string in question get highlighted which helps some, but you are right about the list being so long. I wish that Wolfram would change the functionality of the Windows version to duplicate the way that this winnowing occurs on the Mac. The actual parameters to change are WindowSize and WindowMargins (palettes don't usually use WindowSize since the windowsize is not really changeable like a notebook window is as the layout would be really ugly if you did change it I am guessing). For example, in my init.m file I have the following (only a portion): PalettesMenuSettings->{ \ClassroomAssistant.nb\ -> { WindowMargins -> {{Automatic, -93}, {Automatic, 0}}, TaggingRules -> { \ShowCalculator\ -> True, \ShowNavigation\ -> False, \ShowBasicCommands\ -> False, \ShowWritingTools\ -> False, \ShowBasicTypesetting\ -> True, \ShowAbcKeyboard\ -> True, \ShowHelpLinks\ -> False, \PaletteMode\ -> 1, \OptionsInsertionMode\ -> 1, \ShowNavigationTools\ -> False}}, \SpecialCharacters.nb\ -> { WindowMargins -> {{Automatic, 83}, {101, Automatic}}}} So this puts up the \ClassroomAssistant\ and \SpecialCharacters\ palettes at the indicated margin settings (which is the way to set the position). You should read about what these numbers really mean in the Documentation Center (look up WindowMargins) and realize that the size of the window in combination with the margin settings need to both be taken into account to understand where the window or palette really gets located on your screen. In the case where there are more than one screen or monitors, sometimes the values to WindowMargins are negative, as there is no concept of multiple monitors in Mathematica, so depending on how the second monitor is located relative to the first monitor (on my Mac you can easily setup the second monitor to be to the left, right, above or below the primary monitor - and I think the same is true on Windows), will dictate which of the left/right/bottom/top values to set (usually only two of these have values and the other two are set to Automatic according to the DC). Keep in mind that these WindowMargins[] and WindowSize[] values are dynamically settable even after the window or palette are created using either the Option Inspector or by just moving or resizing them. If you don't quite see how to set the values, play around with moving them to different parts of your screen(s) and see what the resulting values are in the init.m file (this file usually gets written to when you exit Mathematica). If you change the position or size of a notebook window, these values get written to the file when it's saved. I empathize with your frustration with the user interface inconsistancies and difficulties, but the pluses of Mathematica far outweigh the minuses IMO, so try and keep an open mind about how things work and do the best you can, and play around with different features and read the documentation and ask lots of questions. This group is fantastically helpful and as you use Mathematica more and more you will get better and better at dealing with and understanding the software. It really is a worthwhile investment in time and effort if your future involves any sort of a technical aspect. Good luck... -Bob === Subject: Re: Wolfram|Alpha Lookup Tool for Mathematica > > > > > > I also signal the Wolfram toolbar for your favourite browser is > > > > > available in the w/a site. > > > > > It has links to all major Wolfram sites and a query box. > > > > > Nice touch WRI! > > > Also worth mentioning in this context may be the \official\ Wolfram > > Alpha Box for web sites:http://www.wolframalpha.com/addtoyoursite.html > > > I've added this box to the web site of my department, and it seems t= o > > work smoothly. > > Jens > > the W|A output, but with the two digits appended to \www\ by W|A for > load balancing purposes. I wonder if this automated \assimilation\ of > W|A by Google has been anticipated by the W|A team. Probably they > would at least want search queries to come towww.wolframalphaand not > www39.wolframalpha... and of course one may debate if Google is > sufficiently human to be allowed to use W|A at all, even if it does so > indirectly and on my behalf. > > In the end Google and others like it could end up benefiting greatly > from the new content W|A and its users are creating with computable > facts. > > Jens I agree and I sent a note to the W|A team about this... --David === Subject: Re: Wolfram|Alpha Lookup Tool for Mathematica > > > > > > I also signal the Wolfram toolbar for your favourite browser is > > > > > available in the w/a site. > > > > > It has links to all major Wolfram sites and a query box. > > > > > Nice touch WRI! > > > Also worth mentioning in this context may be the \official\ Wolfram > > Alpha Box for web sites:http://www.wolframalpha.com/addtoyoursite.html > > > I've added this box to the web site of my department, and it seems t= o > > work smoothly. > > Jens > > the W|A output, but with the two digits appended to \www\ by W|A for > load balancing purposes. I wonder if this automated \assimilation\ of > W|A by Google has been anticipated by the W|A team. Probably they > would at least want search queries to come towww.wolframalphaand not > www39.wolframalpha... and of course one may debate if Google is > sufficiently human to be allowed to use W|A at all, even if it does so > indirectly and on my behalf. > > In the end Google and others like it could end up benefiting greatly > from the new content W|A and its users are creating with computable > facts. > > Jens I agree and I sent a note to the W|A team about this... --David === Subject: Re: Animated Bubble Chart you should basically parametrize your data with a year parameter: data[year_] := {#1, Log@#2, #3} & @@@ Table[CountryData[c, {{p}, year}], {c, countries}, {p, properties}] and then Animate/Manipulate the graph Animate[ Quiet[ BubbleChart[ data[year], ChartStyle -> 24, LabelingFunction -> labeler, FrameLabel -> {\PopulationGrowth\, \Log GDP Per Capita\}, PlotRange -> {{-0.02, 0.04}, {5, 12}}, Prolog -> {Text[Style[year, FontSize -> Scaled[0.4], FontColor -> LightGray], Scaled[{1/2, 1/2}]]}] ], {year, 2000, 2006, 1}] Unfortunately, you can not use the property \Poverty Fraction\ because it \ does not have historical values, e.g. the function form: CountryData[c, {{\Poverty Fraction\}, year}] does not work. Use \PopulationGrowth\ or something from the list: {\AgriculturalValueAdded\, \ConstructionValueAdded\, \ExchangeRate\, \ \\ \ExpenditureFractions\, \ExportValue\, \FixedInvestment\, \GDP\, \\ \GDPPerCapita\, \GDPRealGrowth\, \GDPSectorFractions\, \\ \GovernmentConsumption\, \GrossInvestment\, \HouseholdConsumption\, \ \\ \ImportValue\, \IndustrialValueAdded\, \InflationRate\, \\ \InventoryChange\, \ManufacturingValueAdded\, \\ \MiscellaneousValueAdded\, \NationalIncome\, \Population\, \\ \PopulationGrowth\, \PriceIndex\, \TotalConsumption\, \\ \TradeValueAdded\, \TransportationValueAdded\, \ValueAdded\} Drago P.S.: Could somebody fix the aspect ratio problem of the bubles? >I am looking to create an animated bubble chart similar to what Hans > Rosling did at TED a few years ago. It seems like Mathematica's > Manipulate function is a perfect tool for doing this. Can anyone > suggest some ideas on how to approach this? I am a newbie user and > have gotten stuck. > > I am pulling in data using the CountryData function and one of the > examples from the built-in documentation. Here is the code from the > online documentation: > > > countries = CountryData[\Europe\]; > > properties = {\PovertyFraction\, \GDPPerCapita\, \Population\}; > > data = {#1, Log@#2, #3} & @@@ > Table[CountryData[c, p], {c, countries}, {p, properties}]; > > labeler[v_, {r_, c_}, ___] := > {\Poverty\, > Row[{Round[100 v[[1]]], \%\}]}, {\GDP Per Capita\, > Row[{\$\, Round[Exp[v[[2]]]]}]}, {\Population\, > Row[{NumberForm[v[[3]] 10^-6, {4, 2}], \ million\}]}}, > Alignment -> Left], Tooltip] > > BubbleChart[data, ChartStyle -> 24, LabelingFunction -> labeler, > FrameLabel -> {\Poverty Fraction\, \Log GDP Per Capita\}] > > > The chart is using poverty on the X-Axis, GDP Per Capita on the Y, and > Population for the bubble size. I would like to animate the bubbles > for a 10-year period, 1990-2000. Any pointers would be appreciated. > > > Jon > > > > PS: Here is a link to Hans' TED presentation: > > \ http://www.ted.com/index.php/talks/hans_rosling_shows_the_best_stats_you_ve_e\ ver_seen.html > === Subject: Re: Animated Bubble Chart you should basically parametrize your data with a year parameter: data[year_] := {#1, Log@#2, #3} & @@@ Table[CountryData[c, {{p}, year}], {c, countries}, {p, properties}] and then Animate/Manipulate the graph Animate[ Quiet[ BubbleChart[ data[year], ChartStyle -> 24, LabelingFunction -> labeler, FrameLabel -> {\PopulationGrowth\, \Log GDP Per Capita\}, PlotRange -> {{-0.02, 0.04}, {5, 12}}, Prolog -> {Text[Style[year, FontSize -> Scaled[0.4], FontColor -> LightGray], Scaled[{1/2, 1/2}]]}] ], {year, 2000, 2006, 1}] Unfortunately, you can not use the property \Poverty Fraction\ because it \ does not have historical values, e.g. the function form: CountryData[c, {{\Poverty Fraction\}, year}] does not work. Use \PopulationGrowth\ or something from the list: {\AgriculturalValueAdded\, \ConstructionValueAdded\, \ExchangeRate\, \ \\ \ExpenditureFractions\, \ExportValue\, \FixedInvestment\, \GDP\, \\ \GDPPerCapita\, \GDPRealGrowth\, \GDPSectorFractions\, \\ \GovernmentConsumption\, \GrossInvestment\, \HouseholdConsumption\, \ \\ \ImportValue\, \IndustrialValueAdded\, \InflationRate\, \\ \InventoryChange\, \ManufacturingValueAdded\, \\ \MiscellaneousValueAdded\, \NationalIncome\, \Population\, \\ \PopulationGrowth\, \PriceIndex\, \TotalConsumption\, \\ \TradeValueAdded\, \TransportationValueAdded\, \ValueAdded\} Drago P.S.: Could somebody fix the aspect ratio problem of the bubles? >I am looking to create an animated bubble chart similar to what Hans > Rosling did at TED a few years ago. It seems like Mathematica's > Manipulate function is a perfect tool for doing this. Can anyone > suggest some ideas on how to approach this? I am a newbie user and > have gotten stuck. > > I am pulling in data using the CountryData function and one of the > examples from the built-in documentation. Here is the code from the > online documentation: > > > countries = CountryData[\Europe\]; > > properties = {\PovertyFraction\, \GDPPerCapita\, \Population\}; > > data = {#1, Log@#2, #3} & @@@ > Table[CountryData[c, p], {c, countries}, {p, properties}]; > > labeler[v_, {r_, c_}, ___] := > {\Poverty\, > Row[{Round[100 v[[1]]], \%\}]}, {\GDP Per Capita\, > Row[{\$\, Round[Exp[v[[2]]]]}]}, {\Population\, > Row[{NumberForm[v[[3]] 10^-6, {4, 2}], \ million\}]}}, > Alignment -> Left], Tooltip] > > BubbleChart[data, ChartStyle -> 24, LabelingFunction -> labeler, > FrameLabel -> {\Poverty Fraction\, \Log GDP Per Capita\}] > > > The chart is using poverty on the X-Axis, GDP Per Capita on the Y, and > Population for the bubble size. I would like to animate the bubbles > for a 10-year period, 1990-2000. Any pointers would be appreciated. > > > Jon > > > > PS: Here is a link to Hans' TED presentation: > > \ http://www.ted.com/index.php/talks/hans_rosling_shows_the_best_stats_you_ve_e\ ver_seen.html > === Subject: Re: Logscale Tick Function oops! Typo on my side. The examples should read: LogLogPlot[x, {x, 10^-3, 10^5}, Ticks -> logtic] LogLogPlot[x, {x, 10^-3, 10^15}, Ticks -> logtic] LogLogPlot[x, {x, 10^-3, 10^35}, Ticks -> logtic] since i named the function logtic :) On side remark: The function is not working well if the min and max values \ are less thansay a few dex apart, e.g. compare: LogLogPlot[x, {x, 100, 700}, Ticks -> logtic] (* with standard tic function *) LogLogPlot[x, {x, 100, 700}, Ticks -> Automatic] My function reasonably places the subticks, but fails in labeling so you get a plot with nice but meaningless ticks. The standard labeling algorithm is better here, but still fails in placing the sub(sub)ticks. I will try to improve it, but feel free to send me your ideas. On the strange uneven tick lengths: >Looks uneven to me as well, but since the ticks are very small, this >may be a pixel rounding problem. Your ticks seem to be a bit uneven as >well. That's true and this is like it is supposed to be, because I use the exact same tick lengths like the standard LogPlot, This seems to be a rendering problem, not a problem of the Graphics Primitives. Markus On May 25, 12:17 pm, \w...@wavebounce.com\ > Sir, this does not work on my WinXP M7.01 -- I get err message \Expected \ = a list of tick specifications\. > Whether it works or not, I sure don't understand your use of Ticks->tic. \ = I can't find that tic is defined anywhere, certainly in the main Module.= === Subject: Re: Logscale Tick Function oops! Typo on my side. The examples should read: LogLogPlot[x, {x, 10^-3, 10^5}, Ticks -> logtic] LogLogPlot[x, {x, 10^-3, 10^15}, Ticks -> logtic] LogLogPlot[x, {x, 10^-3, 10^35}, Ticks -> logtic] since i named the function logtic :) On side remark: The function is not working well if the min and max values \ are less thansay a few dex apart, e.g. compare: LogLogPlot[x, {x, 100, 700}, Ticks -> logtic] (* with standard tic function *) LogLogPlot[x, {x, 100, 700}, Ticks -> Automatic] My function reasonably places the subticks, but fails in labeling so you get a plot with nice but meaningless ticks. The standard labeling algorithm is better here, but still fails in placing the sub(sub)ticks. I will try to improve it, but feel free to send me your ideas. On the strange uneven tick lengths: >Looks uneven to me as well, but since the ticks are very small, this >may be a pixel rounding problem. Your ticks seem to be a bit uneven as >well. That's true and this is like it is supposed to be, because I use the exact same tick lengths like the standard LogPlot, This seems to be a rendering problem, not a problem of the Graphics Primitives. Markus On May 25, 12:17 pm, \w...@wavebounce.com\ > Sir, this does not work on my WinXP M7.01 -- I get err message \Expected \ = a list of tick specifications\. > Whether it works or not, I sure don't understand your use of Ticks->tic. \ = I can't find that tic is defined anywhere, certainly in the main Module.= === Subject: Re: Logscale Tick Function oops! Typo on my side. The examples should read: LogLogPlot[x, {x, 10^-3, 10^5}, Ticks -> logtic] LogLogPlot[x, {x, 10^-3, 10^15}, Ticks -> logtic] LogLogPlot[x, {x, 10^-3, 10^35}, Ticks -> logtic] since i named the function logtic :) On side remark: The function is not working well if the min and max values \ are less thansay a few dex apart, e.g. compare: LogLogPlot[x, {x, 100, 700}, Ticks -> logtic] (* with standard tic function *) LogLogPlot[x, {x, 100, 700}, Ticks -> Automatic] My function reasonably places the subticks, but fails in labeling so you get a plot with nice but meaningless ticks. The standard labeling algorithm is better here, but still fails in placing the sub(sub)ticks. I will try to improve it, but feel free to send me your ideas. On the strange uneven tick lengths: >Looks uneven to me as well, but since the ticks are very small, this >may be a pixel rounding problem. Your ticks seem to be a bit uneven as >well. That's true and this is like it is supposed to be, because I use the exact same tick lengths like the standard LogPlot, This seems to be a rendering problem, not a problem of the Graphics Primitives. Markus On May 25, 12:17 pm, \w...@wavebounce.com\ > Sir, this does not work on my WinXP M7.01 -- I get err message \Expected \ = a list of tick specifications\. > Whether it works or not, I sure don't understand your use of Ticks->tic. \ = I can't find that tic is defined anywhere, certainly in the main Module.= === Subject: Re: Logscale Tick Function oops! Typo on my side. The examples should read: LogLogPlot[x, {x, 10^-3, 10^5}, Ticks -> logtic] LogLogPlot[x, {x, 10^-3, 10^15}, Ticks -> logtic] LogLogPlot[x, {x, 10^-3, 10^35}, Ticks -> logtic] since i named the function logtic :) On side remark: The function is not working well if the min and max values \ are less thansay a few dex apart, e.g. compare: LogLogPlot[x, {x, 100, 700}, Ticks -> logtic] (* with standard tic function *) LogLogPlot[x, {x, 100, 700}, Ticks -> Automatic] My function reasonably places the subticks, but fails in labeling so you get a plot with nice but meaningless ticks. The standard labeling algorithm is better here, but still fails in placing the sub(sub)ticks. I will try to improve it, but feel free to send me your ideas. On the strange uneven tick lengths: >Looks uneven to me as well, but since the ticks are very small, this >may be a pixel rounding problem. Your ticks seem to be a bit uneven as >well. That's true and this is like it is supposed to be, because I use the exact same tick lengths like the standard LogPlot, This seems to be a rendering problem, not a problem of the Graphics Primitives. Markus On May 25, 12:17 pm, \w...@wavebounce.com\ > Sir, this does not work on my WinXP M7.01 -- I get err message \Expected \ = a list of tick specifications\. > Whether it works or not, I sure don't understand your use of Ticks->tic. \ = I can't find that tic is defined anywhere, certainly in the main Module.= === Subject: Re: Logscale Tick Function oops! Typo on my side. The examples should read: LogLogPlot[x, {x, 10^-3, 10^5}, Ticks -> logtic] LogLogPlot[x, {x, 10^-3, 10^15}, Ticks -> logtic] LogLogPlot[x, {x, 10^-3, 10^35}, Ticks -> logtic] since i named the function logtic :) On side remark: The function is not working well if the min and max values \ are less thansay a few dex apart, e.g. compare: LogLogPlot[x, {x, 100, 700}, Ticks -> logtic] (* with standard tic function *) LogLogPlot[x, {x, 100, 700}, Ticks -> Automatic] My function reasonably places the subticks, but fails in labeling so you get a plot with nice but meaningless ticks. The standard labeling algorithm is better here, but still fails in placing the sub(sub)ticks. I will try to improve it, but feel free to send me your ideas. On the strange uneven tick lengths: >Looks uneven to me as well, but since the ticks are very small, this >may be a pixel rounding problem. Your ticks seem to be a bit uneven as >well. That's true and this is like it is supposed to be, because I use the exact same tick lengths like the standard LogPlot, This seems to be a rendering problem, not a problem of the Graphics Primitives. Markus On May 25, 12:17 pm, \w...@wavebounce.com\ > Sir, this does not work on my WinXP M7.01 -- I get err message \Expected \ = a list of tick specifications\. > Whether it works or not, I sure don't understand your use of Ticks->tic. \ = I can't find that tic is defined anywhere, certainly in the main Module.= === Subject: Re: What happened to StandardForm? If I cut and paste it is already in StandardForm In[172]:= $Version Out[172]= \7.0 for Microsoft Windows (32-bit) (February 18, 2009)\ > I used to be able to cut and paste a newsgroup example, do a ctl-shift-N > and turn it into StandardForm. This key stroke sequence seems to have > vanished. Any ideas? > > Kevin === Subject: Re: What happened to StandardForm? > I used to be able to cut and paste a newsgroup example, do a ctl-shift-N > and turn it into StandardForm. This key stroke sequence seems to have > vanished. Any ideas? > > Kevin It should be working in any version of Mathematica (and it does for me under Windows 7.0.1). Does it still show up in the menu? What platform are you on? John Fultz User Interface Group jfultz@wolfram.com === Subject: Re: What happened to StandardForm? > I used to be able to cut and paste a newsgroup example, do a ctl-shift-N > and turn it into StandardForm. This key stroke sequence seems to have > vanished. Any ideas? > > Kevin > It works for me, using Mathematica 7.0 on Windows. I wonder if you are actually encountering this issue with Thunderbird: x circumflex 2 (* where you use the ^ operator! *) prints using normal superscript notation, which looks great until you copy and paste it into Mathematica, when it comes out as x2. If this is your actual problem, a partial solution is to view the message source and copy and paste from that. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: What happened to StandardForm? > I used to be able to cut and paste a newsgroup example, do a ctl-shift-N > and turn it into StandardForm. This key stroke sequence seems to have > vanished. Any ideas? > > Kevin It should be working in any version of Mathematica (and it does for me under Windows 7.0.1). Does it still show up in the menu? What platform are you on? John Fultz User Interface Group jfultz@wolfram.com === Subject: Re: What happened to StandardForm? > I used to be able to cut and paste a newsgroup example, do a ctl-shift-N > and turn it into StandardForm. This key stroke sequence seems to have > vanished. Any ideas? > > Kevin > It works for me, using Mathematica 7.0 on Windows. I wonder if you are actually encountering this issue with Thunderbird: x circumflex 2 (* where you use the ^ operator! *) prints using normal superscript notation, which looks great until you copy and paste it into Mathematica, when it comes out as x2. If this is your actual problem, a partial solution is to view the message source and copy and paste from that. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: seems I broke the FE of V7 Never seen this before. Did you try rebooting your PC? > Hello UG: > > I was using my XP based V7 system just fine until an hour ago or so. > Now all notebooks are unformatted. When I give a simple string \2+2\, > then Ctrl-Enter does not evaluate it. The interface and the menus look > OK, but then I noticed that Format>>Style shows no styles, only a menu > separator and then \Other\. > > I can guess that no cells are input cells, so they cannot be > evaluated. But how could I have blown all my styles away. > > The only \suspicious\ thing that happened is that I downloaded a > Demostrations source package (about Planck's constant I think). It > evaluated and ran OK. I used help and ran some simple evals after the > Demonstration. > > Any helpful thoughts? Maybe I have to go to 7.0.1 now. > > TIA. > > > Roger Williams > Franklin Laboratory === Subject: Re: seems I broke the FE of V7 > Hello UG: > > I was using my XP based V7 system just fine until an hour ago or so. > Now all notebooks are unformatted. When I give a simple string \2+2\, > then Ctrl-Enter does not evaluate it. The interface and the menus look > OK, but then I noticed that Format>>Style shows no styles, only a menu > separator and then \Other\. Ctrl-Enter inserts rows in matrices. Shift-Enter evaluates. > I can guess that no cells are input cells, so they cannot be > evaluated. But how could I have blown all my styles away. > > The only \suspicious\ thing that happened is that I downloaded a > Demostrations source package (about Planck's constant I think). It > evaluated and ran OK. I used help and ran some simple evals after the > Demonstration. > > Any helpful thoughts? Maybe I have to go to 7.0.1 now. You can try resetting the front end by holding down shift, alt, and ctrl while it's starting up. I've no idea if this will help in your case, though. === Subject: Re: seems I broke the FE of V7 > Hello UG: > > I was using my XP based V7 system just fine until an hour ago or so. > Now all notebooks are unformatted. When I give a simple string \2+2\, > then Ctrl-Enter does not evaluate it. The interface and the menus look > OK, but then I noticed that Format>>Style shows no styles, only a menu > separator and then \Other\. > > I can guess that no cells are input cells, so they cannot be > evaluated. But how could I have blown all my styles away. > > The only \suspicious\ thing that happened is that I downloaded a > Demostrations source package (about Planck's constant I think). It > evaluated and ran OK. I used help and ran some simple evals after the > Demonstration. > > Any helpful thoughts? Maybe I have to go to 7.0.1 now. > > TIA. > > > Roger Williams > Franklin Laboratory > Have you looked to see if the directory \C:\\Program Files\\Wolfram Research\\Mathematica\\7.0\\SystemFiles\\FrontEnd\\StyleSheets\ still contains the style sheets! I will leave it to others to try downloading and running the Demonstration you mention to try to reproduce the problem! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: seems I broke the FE of V7 I'd definitely recommend upgrading to 7.0.1 regardless. Did the problem go away when you restart Mathematica? A difficult-to-reproduce problem similar to this was reported in 7.0.0 which only lasted until you restarted the session. I don't recall the same problem having been reported against 7.0.1, although I wouldn't swear to it. I wouldn't expect the loading of a Demonstrations notebook to cause any problems. John Fultz User Interface Group jfultz@wolfram.com > Hello UG: > > I was using my XP based V7 system just fine until an hour ago or so. > Now all notebooks are unformatted. When I give a simple string \2+2\, > then Ctrl-Enter does not evaluate it. The interface and the menus look > OK, but then I noticed that Format>>Style shows no styles, only a menu > separator and then \Other\. > > I can guess that no cells are input cells, so they cannot be > evaluated. But how could I have blown all my styles away. > > The only \suspicious\ thing that happened is that I downloaded a > Demostrations source package (about Planck's constant I think). It > evaluated and ran OK. I used help and ran some simple evals after the > Demonstration. > > Any helpful thoughts? Maybe I have to go to 7.0.1 now. > > TIA. > > > Roger Williams > Franklin Laboratory > === Subject: Re: seems I broke the FE of V7 > Hello UG: > > I was using my XP based V7 system just fine until an hour ago or so. > Now all notebooks are unformatted. When I give a simple string \2+2\, > then Ctrl-Enter does not evaluate it. The interface and the menus look > OK, but then I noticed that Format>>Style shows no styles, only a menu > separator and then \Other\. > > I can guess that no cells are input cells, so they cannot be > evaluated. But how could I have blown all my styles away. > > The only \suspicious\ thing that happened is that I downloaded a > Demostrations source package (about Planck's constant I think). It > evaluated and ran OK. I used help and ran some simple evals after the > Demonstration. > > Any helpful thoughts? Maybe I have to go to 7.0.1 now. > > TIA. > > > Roger Williams > Franklin Laboratory > Just a wild guess: your File $UserBaseDirectory/Frontend/init.m may be corrupted. Drag it to the Desktop (after closing Mathematica) and restart Mathematica -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: seems I broke the FE of V7 > Hello UG: > > I was using my XP based V7 system just fine until an hour ago or so. > Now all notebooks are unformatted. When I give a simple string \2+2\, > then Ctrl-Enter does not evaluate it. The interface and the menus look > OK, but then I noticed that Format>>Style shows no styles, only a menu > separator and then \Other\. Ctrl-Enter inserts rows in matrices. Shift-Enter evaluates. > I can guess that no cells are input cells, so they cannot be > evaluated. But how could I have blown all my styles away. > > The only \suspicious\ thing that happened is that I downloaded a > Demostrations source package (about Planck's constant I think). It > evaluated and ran OK. I used help and ran some simple evals after the > Demonstration. > > Any helpful thoughts? Maybe I have to go to 7.0.1 now. You can try resetting the front end by holding down shift, alt, and ctrl while it's starting up. I've no idea if this will help in your case, though. === Subject: Re: seems I broke the FE of V7 > Hello UG: > > I was using my XP based V7 system just fine until an hour ago or so. > Now all notebooks are unformatted. When I give a simple string \2+2\, > then Ctrl-Enter does not evaluate it. The interface and the menus look > OK, but then I noticed that Format>>Style shows no styles, only a menu > separator and then \Other\. > > I can guess that no cells are input cells, so they cannot be > evaluated. But how could I have blown all my styles away. > > The only \suspicious\ thing that happened is that I downloaded a > Demostrations source package (about Planck's constant I think). It > evaluated and ran OK. I used help and ran some simple evals after the > Demonstration. > > Any helpful thoughts? Maybe I have to go to 7.0.1 now. > > TIA. > > > Roger Williams > Franklin Laboratory > Have you looked to see if the directory \C:\\Program Files\\Wolfram Research\\Mathematica\\7.0\\SystemFiles\\FrontEnd\\StyleSheets\ still contains the style sheets! I will leave it to others to try downloading and running the Demonstration you mention to try to reproduce the problem! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: seems I broke the FE of V7 I'd definitely recommend upgrading to 7.0.1 regardless. Did the problem go away when you restart Mathematica? A difficult-to-reproduce problem similar to this was reported in 7.0.0 which only lasted until you restarted the session. I don't recall the same problem having been reported against 7.0.1, although I wouldn't swear to it. I wouldn't expect the loading of a Demonstrations notebook to cause any problems. John Fultz User Interface Group jfultz@wolfram.com > Hello UG: > > I was using my XP based V7 system just fine until an hour ago or so. > Now all notebooks are unformatted. When I give a simple string \2+2\, > then Ctrl-Enter does not evaluate it. The interface and the menus look > OK, but then I noticed that Format>>Style shows no styles, only a menu > separator and then \Other\. > > I can guess that no cells are input cells, so they cannot be > evaluated. But how could I have blown all my styles away. > > The only \suspicious\ thing that happened is that I downloaded a > Demostrations source package (about Planck's constant I think). It > evaluated and ran OK. I used help and ran some simple evals after the > Demonstration. > > Any helpful thoughts? Maybe I have to go to 7.0.1 now. > > TIA. > > > Roger Williams > Franklin Laboratory > === Subject: Re: seems I broke the FE of V7 > Hello UG: > > I was using my XP based V7 system just fine until an hour ago or so. > Now all notebooks are unformatted. When I give a simple string \2+2\, > then Ctrl-Enter does not evaluate it. The interface and the menus look > OK, but then I noticed that Format>>Style shows no styles, only a menu > separator and then \Other\. > > I can guess that no cells are input cells, so they cannot be > evaluated. But how could I have blown all my styles away. > > The only \suspicious\ thing that happened is that I downloaded a > Demostrations source package (about Planck's constant I think). It > evaluated and ran OK. I used help and ran some simple evals after the > Demonstration. > > Any helpful thoughts? Maybe I have to go to 7.0.1 now. > > TIA. > > > Roger Williams > Franklin Laboratory > Just a wild guess: your File $UserBaseDirectory/Frontend/init.m may be corrupted. Drag it to the Desktop (after closing Mathematica) and restart Mathematica -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Alain, Read the file names in a list and either loop over this list to read in the data files or use Map or Apply to handle the list at once. You keep on asking questions on file names and don't seem to make much progress, do you? It looks like you're missing a bit of Mathematica basics. I'd suggest you read more of the Mathematica introductory texts. > Hi > > I'm doing calculations on several files (C0156.txt ....) which works > well for a given file > > import it as in: > > Needs[\EDA`\] > > HeaderLines -> 0, TrailerLines -> 0, UseVariables -> {1, 2, 3, 4}, > FormatData -> False] > > I would like to do that for all my files transfering the names by > importing them from a file: names.txt > > The names (here only 1) are in the file names.txt which is imported via: > > Import[\Desktop/names.txt\] > C0156 > > I dont succeed to transfer that info to the previous ImportData > command in order to do that automatically > > > Alain Mazure > > Laboratoire d'Astrophysique de Marseille > P=F4le de l'=C9toile Site de Ch=E2teau-Gombert > 38, rue Fr=E9d=E9ric Joliot-Curie > 13388 Marseille cedex 13, France > > http://alain.mazure.free.fr/ > > Mails: > alain.maz...@oamp.fr > alain.maz...@free.fr > > Phones: > Lab: 33(0)491055902 === ImportData[\Desktop/\ <> # <> \.txt\, HeaderLines -> 0, TrailerLines -> 0, UseVariables -> {1, 2, 3, 4}, FormatData -> False] & /@ Import[\Desktop/names.txt\] ?? Jens > Hi > > I'm doing calculations on several files (C0156.txt ....) which works > well for a given file > > import it as in: > > > Needs[\EDA`\] > > HeaderLines -> 0, TrailerLines -> 0, UseVariables -> {1, 2, 3, 4}, > FormatData -> False] > > I would like to do that for all my files transfering the names by > importing them from a file: names.txt > > > The names (here only 1) are in the file names.txt which is imported via: > > Import[\Desktop/names.txt\] > C0156 > > > I dont succeed to transfer that info to the previous ImportData > command in order to do that automatically > > > > > > Alain Mazure > > Laboratoire d'Astrophysique de Marseille > P=F4le de l'=C9toile Site de Ch=E2teau-Gombert > 38, rue Fr=E9d=E9ric Joliot-Curie > 13388 Marseille cedex 13, France > > http://alain.mazure.free.fr/ > > Mails: > alain.mazure@oamp.fr > alain.mazure@free.fr > > Phones: > Lab: 33(0)491055902 > === ImportData[\Desktop/\ <> # <> \.txt\, HeaderLines -> 0, TrailerLines -> 0, UseVariables -> {1, 2, 3, 4}, FormatData -> False] & /@ Import[\Desktop/names.txt\] ?? Jens > Hi > > I'm doing calculations on several files (C0156.txt ....) which works > well for a given file > > import it as in: > > > Needs[\EDA`\] > > HeaderLines -> 0, TrailerLines -> 0, UseVariables -> {1, 2, 3, 4}, > FormatData -> False] > > I would like to do that for all my files transfering the names by > importing them from a file: names.txt > > > The names (here only 1) are in the file names.txt which is imported via: > > Import[\Desktop/names.txt\] > C0156 > > > I dont succeed to transfer that info to the previous ImportData > command in order to do that automatically > > > > > > Alain Mazure > > Laboratoire d'Astrophysique de Marseille > P=F4le de l'=C9toile Site de Ch=E2teau-Gombert > 38, rue Fr=E9d=E9ric Joliot-Curie > 13388 Marseille cedex 13, France > > http://alain.mazure.free.fr/ > > Mails: > alain.mazure@oamp.fr > alain.mazure@free.fr > > Phones: > Lab: 33(0)491055902 > === Subject: Re: Dynamic performance - input fields slow I don't seem to have this problem. Perhaps something you entered that's causing the problem? > > I'm writing a Dynamic module with 3D graphics and several input > fields. Once the 3D plot is rendered, simply typing in the input > fields become extremely slow (even though the graphic is not > changing). > > Here's a simple example: > > DynamicModule[{f, g}, > {InputField[Dynamic[f], FieldSize -> 10], > InputField[Dynamic[g], FieldSize -> 10], > Dynamic[Plot3D[f, {x, -2, 2}, {y, -2, 2}]] > } > ] > > Initially, both input fields respond quickly to typing. If I enter > something in the first, like x, then the plot shows, and the input > fields no longer respond quickly to typing. If I do the same thing > with Manipulate, I don't experience this problem: > > Manipulate[ > Plot3D[f, {x, -2, 2}, {y, -2, 2}], > {f}, {g}] > > I would like to use Dynamic rather than Manipulate because the > eventual UI will be quite a bit more complicated, but I'm not sure > what's causing the slow performance. Does anybody have any tips? > === Subject: Re: Dynamic performance - input fields slow When I copy your DynamicModule example into a fresh notebook, I don't experience any problem with slow response to typing before or after the \ plot is rendered. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm writing a Dynamic module with 3D graphics and several input fields. Once the 3D plot is rendered, simply typing in the input fields become extremely slow (even though the graphic is not changing). Here's a simple example: DynamicModule[{f, g}, {InputField[Dynamic[f], FieldSize -> 10], InputField[Dynamic[g], FieldSize -> 10], Dynamic[Plot3D[f, {x, -2, 2}, {y, -2, 2}]] } ] Initially, both input fields respond quickly to typing. If I enter something in the first, like x, then the plot shows, and the input fields no longer respond quickly to typing. If I do the same thing with Manipulate, I don't experience this problem: Manipulate[ Plot3D[f, {x, -2, 2}, {y, -2, 2}], {f}, {g}] I would like to use Dynamic rather than Manipulate because the eventual UI will be quite a bit more complicated, but I'm not sure what's causing the slow performance. Does anybody have any tips? === Subject: Re: Dynamic performance - input fields slow When I copy your DynamicModule example into a fresh notebook, I don't experience any problem with slow response to typing before or after the \ plot is rendered. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm writing a Dynamic module with 3D graphics and several input fields. Once the 3D plot is rendered, simply typing in the input fields become extremely slow (even though the graphic is not changing). Here's a simple example: DynamicModule[{f, g}, {InputField[Dynamic[f], FieldSize -> 10], InputField[Dynamic[g], FieldSize -> 10], Dynamic[Plot3D[f, {x, -2, 2}, {y, -2, 2}]] } ] Initially, both input fields respond quickly to typing. If I enter something in the first, like x, then the plot shows, and the input fields no longer respond quickly to typing. If I do the same thing with Manipulate, I don't experience this problem: Manipulate[ Plot3D[f, {x, -2, 2}, {y, -2, 2}], {f}, {g}] I would like to use Dynamic rather than Manipulate because the eventual UI will be quite a bit more complicated, but I'm not sure what's causing the slow performance. Does anybody have any tips? === Subject: Re: Dynamic performance - input fields slow Interesting; when I copy it to a fresh notebook in a new session of Mathematica, I have the same problem. Perhaps it's just because my computer is old and slow. However, I tried it on a different computer, and I experience the same issue if I make the graphics complicated enough. For example: DynamicModule[{f, g}, {InputField[Dynamic[f], FieldSize -> 10], InputField[Dynamic[g], FieldSize -> 10], Dynamic[Plot3D[f, {x, -2, 2}, {y, -2, 2}, PlotPoints -> 250], TrackedSymbols -> {f}]} ] has noticeably slower response in the input fields as compared to Manipulate[ Plot3D[f, {x, -2, 2}, {y, -2, 2}, PlotPoints -> 250], {f}, {g}] It appears to me (although this is just a guess) that the Dynamic version tries to redraw the graphics each time I type in an input field, whereas the Manipulate version does not. Any idea what Manipulate does to get this behavior? By the way, I'm using Mathematica 6, if it makes a difference. > When I copy your DynamicModule example into a fresh notebook, I don't > experience any problem with slow response to typing before or after the \ p= lot > is rendered. > > David Park > djmp...@comcast.nethttp://home.comcast.net/~djmpark/ > > > > I'm writing a Dynamic module with 3D graphics and several input > fields. Once the 3D plot is rendered, simply typing in the input > fields become extremely slow (even though the graphic is not > changing). > > Here's a simple example: > > DynamicModule[{f, g}, > {InputField[Dynamic[f], FieldSize -> 10], > InputField[Dynamic[g], FieldSize -> 10], > Dynamic[Plot3D[f, {x, -2, 2}, {y, -2, 2}]] > } > ] > > Initially, both input fields respond quickly to typing. If I enter > something in the first, like x, then the plot shows, and the input > fields no longer respond quickly to typing. If I do the same thing > with Manipulate, I don't experience this problem: > > Manipulate[ > Plot3D[f, {x, -2, 2}, {y, -2, 2}], > {f}, {g}] > > I would like to use Dynamic rather than Manipulate because the > eventual UI will be quite a bit more complicated, but I'm not sure > what's causing the slow performance. Does anybody have any tips? > === Subject: Re: uncomplete NDSOlve results >I numerically simulated an ODE systems with NDSOlve. I tried all >kinds of methods and I always get a solution back, seemingly over >the whole integration interval, i.e. 100: >sol={{A->InterpolatingFunction[{{0.,100.}},<>]}}. >However, when I plot A (Plot[A[t]/.sol,{t,0,100},PlotRange->All]) >the curve just stops after a fraction of the simulation time. So, >there seems to be no solution after a certain time. But upon >integration I get no errors. Since you did not post the system you are solving with NDSolve, all I can do is offer *guesses* as to the source of the problem. One possibility is the solution to the problem has a complex value for some range of values. If this is the case, NDSolve will execute with no errors but Plot will not plot anything for the range where the solution is complex since it only plots real valued functions. === Subject: simultaneous equations for chemical speciation starting to realise the possibilities. I am trying to do a chemical speciation calculation. I have a set of simultaneous equations which represents the equilibria, mass balance, and charge balance in the system. I want to eliminate some of the variables, and then be able to solve for the remaining ones. My system of equations looks like this: a=b+c+d e=f+g+c+2d h=c/(bg) i=d/(cg) hi=d/(bg^2) j=mg/f k=lm n+m+b+c=g+l Basically, I can solve for the variable I want, but I am having trouble eliminating the ones I don't want (ie. I am getting an answer that is in terms of the wrong variables) Sofar my formula looks like: Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, n + m + b + c == g + l}, {g}] If I use a similar formula for the \Eliminate\ function, I get error mesages. I have been in the help files for ages, and don't really understand how to do this. I would really appreciate some pointers!! === Subject: Re: simultaneous equations for chemical speciation Hi Jem, First, the equation: a=b+c+d e=f+g+c+2d j=mg/f k=lm n+m+b+c=g+l do not add any information because they only introduce a new variable that does not appear anywhere else. This leaves 3 equations: h=c/(bg) i=d/(cg) hi=d/(bg^2) Multiplying the first 2 gives the third. Therefore, we actually have 2 equations: h=c/(bg) i=d/(cg) These do not have a general solution. Only under special circumstances we get a solution. For this problem we have Reduce. Therefore, you get possible solutions by: Reduce[{h == c/(b*g), i == d/(c*g)}, {g}] Daniel > starting to realise the possibilities. > > I am trying to do a chemical speciation calculation. > I have a set of simultaneous equations which represents the equilibria, > mass balance, and charge balance in the system. > > I want to eliminate some of the variables, and then be able to solve for > the remaining ones. > My system of equations looks like this: > a=b+c+d > e=f+g+c+2d > h=c/(bg) > i=d/(cg) > hi=d/(bg^2) > j=mg/f > k=lm > n+m+b+c=g+l > > Basically, I can solve for the variable I want, but I am having trouble > eliminating the ones I don't want (ie. I am getting an answer that is in > terms of the wrong variables) > Sofar my formula looks like: > > Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), > i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, > n + m + b + c == g + l}, {g}] > > If I use a similar formula for the \Eliminate\ function, I get error > mesages. > > I have been in the help files for ages, and don't really understand how > to do this. > I would really appreciate some pointers!! > > === Subject: Re: simultaneous equations for chemical speciation and we can look on you post for ages, but we will never find out *what* variables you wish to eliminate, so we will not found out *what* error message or what's wrong. And more over whe I try eqn = {a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, n + m + b + c == g + l} syms = Cases[eqn, _Symbol, Infinity, Heads -> False] // Union Eliminate[eqn, #] & /@ syms all work fine with out an error message. Jens > starting to realise the possibilities. > > I am trying to do a chemical speciation calculation. > I have a set of simultaneous equations which represents the equilibria, > mass balance, and charge balance in the system. > > I want to eliminate some of the variables, and then be able to solve for > the remaining ones. > My system of equations looks like this: > a=b+c+d > e=f+g+c+2d > h=c/(bg) > i=d/(cg) > hi=d/(bg^2) > j=mg/f > k=lm > n+m+b+c=g+l > > Basically, I can solve for the variable I want, but I am having trouble > eliminating the ones I don't want (ie. I am getting an answer that is in > terms of the wrong variables) > Sofar my formula looks like: > > Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), > i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, > n + m + b + c == g + l}, {g}] > > If I use a similar formula for the \Eliminate\ function, I get error > mesages. > > I have been in the help files for ages, and don't really understand how > to do this. > I would really appreciate some pointers!! > > === Subject: Re: 100,000 posts! This time it was a kind of \interception in reverse\: I sent the message to Steven and did not really mean to post this to the MathGroup. But you can't win them all ;-) Andrzej > great job you have done, particularly over the last decade during > which I have been posting to the MathGroup. In my case there is an > additional reason for gratitude: the rather large number of your > \interventions\ that intercepted in time some of my rashest posts. > > With best wishes. > > Andrzej Kozlowski > > > >> Hello everyone, >> >> The Mathematica mailing list and newsgroup have been in existence >> for more >> than twenty years now. In January 2005, we past the 50,000 message >> mark. >> Now, in only a little more than four years, we have added another >> 50,000. >> This is very gratifying to me and I hope that this effort will >> continue >> to grow and help as many users as possible. >> >> A little personal history. I was honored to be a student and friend >> of Bryce DeWitt, who some of you know was one of the finest >> theoretical >> physicists of the last 100 years. One of the things he told me back >> in the 70's was >> >> \Make sure all your projects are useful, work that will still be >> valuable to >> others twenty years from now.\ >> >> I have tried to take this to heart in doing the moderation of this >> group >> for twenty years and running sunfreeware.com for fifteen years. >> >> It is obvious that Stephen, the folks at Wolfram Research, and many >> of >> to >> all of you. >> >> >> Steve Christensen >> Moderator >> > > === Subject: Re: 100,000 posts! great job you have done, particularly over the last decade during which I have been posting to the MathGroup. In my case there is an additional reason for gratitude: the rather large number of your \interventions\ that intercepted in time some of my rashest posts. With best wishes. Andrzej Kozlowski > Hello everyone, > > The Mathematica mailing list and newsgroup have been in existence > for more > than twenty years now. In January 2005, we past the 50,000 message > mark. > Now, in only a little more than four years, we have added another > 50,000. > This is very gratifying to me and I hope that this effort will > continue > to grow and help as many users as possible. > > A little personal history. I was honored to be a student and friend > of Bryce DeWitt, who some of you know was one of the finest > theoretical > physicists of the last 100 years. One of the things he told me back > in the 70's was > > \Make sure all your projects are useful, work that will still be > valuable to > others twenty years from now.\ > > I have tried to take this to heart in doing the moderation of this > group > for twenty years and running sunfreeware.com for fifteen years. > > It is obvious that Stephen, the folks at Wolfram Research, and many of > all of you. > > > Steve Christensen > Moderator > === Subject: Re: 100,000 posts! great job you have done, particularly over the last decade during which I have been posting to the MathGroup. In my case there is an additional reason for gratitude: the rather large number of your \interventions\ that intercepted in time some of my rashest posts. With best wishes. Andrzej Kozlowski > Hello everyone, > > The Mathematica mailing list and newsgroup have been in existence > for more > than twenty years now. In January 2005, we past the 50,000 message > mark. > Now, in only a little more than four years, we have added another > 50,000. > This is very gratifying to me and I hope that this effort will > continue > to grow and help as many users as possible. > > A little personal history. I was honored to be a student and friend > of Bryce DeWitt, who some of you know was one of the finest > theoretical > physicists of the last 100 years. One of the things he told me back > in the 70's was > > \Make sure all your projects are useful, work that will still be > valuable to > others twenty years from now.\ > > I have tried to take this to heart in doing the moderation of this > group > for twenty years and running sunfreeware.com for fifteen years. > > It is obvious that Stephen, the folks at Wolfram Research, and many of > all of you. > > > Steve Christensen > Moderator > === Subject: Re: What happened to StandardForm? > >> I used to be able to cut and paste a newsgroup example, do a ctl-shift-N >> and turn it into StandardForm. This key stroke sequence seems to have >> vanished. Any ideas? >> >> Kevin >> > It works for me, using Mathematica 7.0 on Windows. I wonder if you are > actually encountering this issue with Thunderbird: > > x circumflex 2 (* where you use the ^ operator! *) > > prints using normal superscript notation, which looks great until you > copy and paste it into Mathematica, when it comes out as x2. > > If this is your actual problem, a partial solution is to view the > message source and copy and paste from that. > > David Bailey > http://www.dbaileyconsultancy.co.uk Incidentally, this problem can be fully worked around by turning off the display of emoticons in the Thunderbird preferences. The emoticon support also affects the superscript behavior. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: Bug of NotebookRead P.S. I have added your observation to the bug report that I originally filed with Wolfram. So this is all in the system... --David > > cell tags could be very useful to extract quickly selected information > from notebooks, see David Reiss \ presentationhttp://scientificarts.com/wor= klife/conference2008.html > > But be aware of the following bug of NotebookRead applied to tagged > cells in a structured notebook with sections and subsections: > The section cell and the input / output cells in the example are > tagged, but not the subsection cell. The resulting notebook contains > only the section cell. The tagged input/ouput cells are lost as a > consequence of the read notebook data containing a wrong CellGroupData > [[{Cell[..]},Cell[..]] instead of a correct CellGroupData[[{Cell > [..],Cell[..]}]. This could be fixed by a corresponding replacement > rule. But the second input/output cell is missing completely and > cannot be recovered at all. > > notebook1 = Notebook[{ > Cell[\Section 1\, \Section\, CellTags -> \zzz\], > Cell[\Subsection 1 (no tag)\, \Subsection\], > Cell[BoxData[RowBox[{\x\, \=\, \1\}]], \Input\, CellTags -> > \zzz\], > Cell[BoxData[\1\], \Output\, CellTags -> \zzz\], > Cell[BoxData[RowBox[{\y\, \=\, \2\}]], \Input\, CellTags -> > \zzz\], > Cell[BoxData[\2\], \Output\, CellTags -> \zzz\] > }]; > notebookObject = NotebookPut[notebook1, WindowTitle -> \Notebook 1\]; > NotebookFind[notebookObject, \zzz\, All, CellTags]; > notebookData = NotebookRead[notebookObject] > notebook2 = Notebook[Flatten[{notebookData}]]; > NotebookPut[notebook2, WindowTitle -> \Notebook 2\]; > > Did anybody encounter this problem, are there workarounds? I am new to > the tagging approach and a bit frustrated as this was my very first > experience with it. > > I am using Mathematica 7.0.1 on Windows XP > > Hannes Kessler === Subject: Re: Bug of NotebookRead Yes, I came across this back in Version 6 and reported it to the WOlfram bugs system. Following is is the note that I sent them. In my experience I have come across this problem only rarely. But I did encounter it when working on http://scientificarts.com/worklife which makes use of lots and lots of tagging. I think that the workaround that I may have use for the particular case that I had was to use FrontEndExecute[FrontEndToken[notebookObject, \Copy\]] rather than NotebookRead. Then I paste the result in an invisible notebook using (after creating a notebook InvisibleNotebooksObject that has the optoin Visible->False) FrontEndExecute[FrontEndToken[InvisibleNotebooksObject, \Paste\]] And then I select all cells in that notebook and do a NotebookRead on them (then close the invisible notebook. ****************************************************** In[1]:= $Version Out[1]= \6.0 for Mac OS X x86 (32-bit) (June 19, 2007)\ NotebookRead sometimes does not read its selection Create the following notebook: nb = NotebookPut[ Notebook[{Cell[ CellGroupData[{Cell[\Subsubsection\, \Subsubsection\], Cell[\item 1\, \Item\], Cell[\item 2\, \Item\], Cell[\item 3\, \Item\]}, Open]]}]] In this notebook select the \Subsubsection\ cell and the \item 2\ cell. (Exclude the \item 1\ cell and the \item3\ cell.) Then in a second notebook execute NotebookRead[nb] The following corrupted CellGroupData expression results. Note that the second cell apears as a second argument to the CellGroupData rather than as part of an element in the list that is the first argument to CellGroupData. Cell[CellGroupData[{Cell[\Subsubsection\, \Subsubsection\]}, Cell[\item 2\, \Item\]]] Now select the \Subsubsection\ cell, the \item 2\ cell, and the \item 3\ cell (exclude the \item 1\ cell) Then in a second notebook execute NotebookRead[nb]. This is the result. NotebookRead[nb] Cell[CellGroupData[{Cell[\Subsubsection\, \Subsubsection\]}, Cell[\item 2\, \Item\]]] Note that the CellGroupData is corrupted as above and that the third (\item 3\) cell does not appear in the expression at all. ****************************************************** > > cell tags could be very useful to extract quickly selected information > from notebooks, see David Reiss \ presentationhttp://scientificarts.com/wor= klife/conference2008.html > > But be aware of the following bug of NotebookRead applied to tagged > cells in a structured notebook with sections and subsections: > The section cell and the input / output cells in the example are > tagged, but not the subsection cell. The resulting notebook contains > only the section cell. The tagged input/ouput cells are lost as a > consequence of the read notebook data containing a wrong CellGroupData > [[{Cell[..]},Cell[..]] instead of a correct CellGroupData[[{Cell > [..],Cell[..]}]. This could be fixed by a corresponding replacement > rule. But the second input/output cell is missing completely and > cannot be recovered at all. > > notebook1 = Notebook[{ > Cell[\Section 1\, \Section\, CellTags -> \zzz\], > Cell[\Subsection 1 (no tag)\, \Subsection\], > Cell[BoxData[RowBox[{\x\, \=\, \1\}]], \Input\, CellTags -> > \zzz\], > Cell[BoxData[\1\], \Output\, CellTags -> \zzz\], > Cell[BoxData[RowBox[{\y\, \=\, \2\}]], \Input\, CellTags -> > \zzz\], > Cell[BoxData[\2\], \Output\, CellTags -> \zzz\] > }]; > notebookObject = NotebookPut[notebook1, WindowTitle -> \Notebook 1\]; > NotebookFind[notebookObject, \zzz\, All, CellTags]; > notebookData = NotebookRead[notebookObject] > notebook2 = Notebook[Flatten[{notebookData}]]; > NotebookPut[notebook2, WindowTitle -> \Notebook 2\]; > > Did anybody encounter this problem, are there workarounds? I am new to > the tagging approach and a bit frustrated as this was my very first > experience with it. > > I am using Mathematica 7.0.1 on Windows XP > > Hannes Kessler === Subject: NDSolve with Numeric Function Please could someone explain why my NDSolve examples below don't work? In the first case I think it fails because NDSolve attempts to evaluate the function RHS symbolically. The second case should remain unevaluated and signal to NDSolve to go numerical but this fails why? In the third case a similar check to the second works. Why? Hugh Goyder ClearAll[RHS]; RHS[x_, v_, f_] := Module[{x1, y1, x2, y2, x1v, y1v, x2v, y2v}, {x1, y1, x2, y2} = x; {x1v, y1v, x2v, y2v} = v; -{{1, 2, 3, 5}, {3, 2, 1, 2}, {5, 7, 1, 1}, {3, 2, 4, 5}}.{x1, y1, x2, y2} + 3 {x1v, y1v, x2v, y2v} ] sol = NDSolve[{x''[t] == RHS[x[t], x'[t], 1], x[0] == {-1, 0, 1, 0}, x'[0] == {0, 0, 0, 0}}, x, {t, 0, 2}] ClearAll[RHS]; RHS[x_ /; NumericQ[x[[1]]], v_, f_] := Module[{x1, y1, x2, y2, x1v, y1v, x2v, y2v}, {x1, y1, x2, y2} = x; {x1v, y1v, x2v, y2v} = v; -{{1, 2, 3, 5}, {3, 2, 1, 2}, {5, 7, 1, 1}, {3, 2, 4, 5}}.{x1, y1, x2, y2} + 3 {x1v, y1v, x2v, y2v} ] sol = NDSolve[{x''[t] == RHS[x[t], x'[t], 1], x[0] == {-1, 0, 1, 0}, x'[0] == {0, 0, 0, 0}}, x, {t, 0, 2}] ClearAll[RHS]; RHS[x_ /; Head[x] == List, v_, f_] := Module[{x1, y1, x2, y2, x1v, y1v, x2v, y2v}, {x1, y1, x2, y2} = x; {x1v, y1v, x2v, y2v} = v; -{{1, 2, 3, 5}, {3, 2, 1, 2}, {5, 7, 1, 1}, {3, 2, 4, 5}}.{x1, y1, x2, y2} + 3 {x1v, y1v, x2v, y2v} ] sol = NDSolve[{x''[t] == RHS[x[t], x'[t], 1], x[0] == {-1, 0, 1, 0}, x'[0] == {0, 0, 0, 0}}, x, {t, 0, 2}] === Subject: Re: NDSolve with Numeric Function RHS[x_List, v_List, f_] := Module[{x1, y1, x2, y2, x1v, y1v, x2v, y2v}, {x1, y1, x2, y2} = x; {x1v, y1v, x2v, y2v} = v; -{{1, 2, 3, 5}, {3, 2, 1, 2}, {5, 7, 1, 1}, {3, 2, 4, 5}}.{x1, y1, x2, y2} + 3 {x1v, y1v, x2v, y2v}] sol = NDSolve[{x''[t] == RHS[x[t], x'[t], 1], x[0] == {-1, 0, 1, 0}, x'[0] == {0, 0, 0, 0}}, x, {t, 0, 2}] work fine. And the problem is, that NDSolve[] evaluate its arguments before it found out that you wish to solve a vector equation. Jens > Please could someone explain why my NDSolve examples below don't work? > In the first case I think it fails because NDSolve attempts to > evaluate the function RHS symbolically. > The second case should remain unevaluated and signal to NDSolve to go > numerical but this fails why? > In the third case a similar check to the second works. Why? > > Hugh Goyder > > ClearAll[RHS]; > RHS[x_, v_, f_] := Module[{x1, y1, x2, y2, x1v, y1v, x2v, y2v}, > {x1, y1, x2, y2} = x; > {x1v, y1v, x2v, y2v} = v; > -{{1, 2, 3, 5}, {3, 2, 1, 2}, {5, 7, 1, 1}, {3, 2, 4, 5}}.{x1, y1, > x2, y2} + 3 {x1v, y1v, x2v, y2v} > ] > > sol = NDSolve[{x''[t] == RHS[x[t], x'[t], 1], x[0] == {-1, 0, 1, 0}, > x'[0] == {0, 0, 0, 0}}, x, {t, 0, 2}] > > ClearAll[RHS]; > RHS[x_ /; NumericQ[x[[1]]], v_, f_] := > Module[{x1, y1, x2, y2, x1v, y1v, x2v, y2v}, > {x1, y1, x2, y2} = x; > {x1v, y1v, x2v, y2v} = v; > -{{1, 2, 3, 5}, {3, 2, 1, 2}, {5, 7, 1, 1}, {3, 2, 4, 5}}.{x1, y1, > x2, y2} + 3 {x1v, y1v, x2v, y2v} > ] > > sol = NDSolve[{x''[t] == RHS[x[t], x'[t], 1], x[0] == {-1, 0, 1, 0}, > x'[0] == {0, 0, 0, 0}}, x, {t, 0, 2}] > > ClearAll[RHS]; > RHS[x_ /; Head[x] == List, v_, f_] := > Module[{x1, y1, x2, y2, x1v, y1v, x2v, y2v}, > {x1, y1, x2, y2} = x; > {x1v, y1v, x2v, y2v} = v; > -{{1, 2, 3, 5}, {3, 2, 1, 2}, {5, 7, 1, 1}, {3, 2, 4, 5}}.{x1, y1, > x2, y2} + 3 {x1v, y1v, x2v, y2v} > ] > > sol = NDSolve[{x''[t] == RHS[x[t], x'[t], 1], x[0] == {-1, 0, 1, 0}, > x'[0] == {0, 0, 0, 0}}, x, {t, 0, 2}] > === Subject: Re: overlay of multiple plots Show command does not work Specific examples would help. Show often works but is a bit unintuitive and confusing in the method it uses to pick up options. It also requires \graphics level jumping\ if you want to include graphics primitives, or have them separately crammed into \ an Epilog option. The Presentations package is more intuitive and easier to use. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I am having here also trouble with Show... Combining a simple Graphics Point Plot with a ListCountourPlot just outputs one or the other, but they don't overlay... best, manuel On 8 Apr., 11:04, Jens-Peer Kuska > > lst = Table[ > With[{a = RandomReal[{1, 6}]}, > Plot[Sin[a*x], {x, 0, 2 Pi}]], {100}]; > > and > > Show @@ lst > > work as it should. Can you be more specific ? > > Jens > > > > I generated a list of plots, which I want to overlay. (say around 100 > > plots). > > > I tried to read in the list inside the Show[] command. > > But somehow it does not seem to work. > > > Any suggestions? > > > I would be very grateful. > > > Venkatesh Ramakrishnan > > National Facility for High Field NMR > > Tata Institute of Fundamental Research > > Mumbai 400 005 > > India === Subject: Re: Shade area between two polar curves The solution below works just fine. In a separate post I offered a method that uses only PolarPlot. It seems to me that one should not have to convert to cartesian coordiantes at all in order to do this kind of filling. The underlying trouble, of course, is that Mathematica does not currently include a Filling option for PolarPlot or ParametricPlot. > Show[ > {PolarPlot[{1 + 2 Cos[t], 2}, {t, 0, 2 \\[Pi]}], > RegionPlot[ > 2 <= Sqrt[x^2 + y^2] <= 1 + 2 x/Sqrt[(x^2 + y^2)], {x, 0, > 3}, {y, -2, 2}, > MaxRecursion -> 3, > BoundaryStyle -> Thick]}, > Axes -> False, > ImageSize -> 300] > > > Hi All > > I have plotted two graphs using PolarPlot, namely the limacon r=1+2 \ cos(t) > and the circle r = 2 from t = 0 to t = 2 Pi. and I wish to shade the area > inside the limacon but outside the circle. Can anyone suggest a way to do > it? > > Chee > > > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Shade area between two polar curves Hi All I have plotted two graphs using PolarPlot, namely the limacon r=1+2 cos(t) and the circle r = 2 from t = 0 to t = 2 Pi. and I wish to shade the area inside the limacon but outside the circle. Can anyone suggest a way to do it? Chee === Subject: Re: Keep Slider Consistent With a Slow Graph > The graph displayed by the Manipulate below takes a while to display. > While the calculation is taking place, if you click on some other > value on the slider, the slider moves and displays its new value. > However, the graph will plot using the original value. > > The result is that the graph and the slider are now out of sync. This > is bad user interface design. > > In the real example I am working with, there is no way to make the > calculations go fast enough to keep up with clicks on the slider. For > the same reason, I cannot allow the user to slide the slider, so > ContinuousAction must be False. > > Nevertheless, is there some way to make sure the slider and the graph > stay consistent with each other? > > Robert Baillie > > plotSlowGraph[xMax_] := > Module[ > { x, t }, > Plot[ NIntegrate[1/((t^2 - 1)*t*Log[t]), > {t, x, Infinity}], {x, 2, xMax} ] > ]; > > Manipulate[ > Graphics[ plotSlowGraph[xMax] ], > { {xMax, 10, \x Max\}, 10, 400, 10, Appearance -> \Labeled\ }, > ContinuousAction -> False, SaveDefinitions->True > ] > I would have thought that if you have a really slow process, a slider just isn't a good way to manipulate it. Even with ContinuousAction->False, you have the problem that merely releasing the mouse will initiate a calculation at a value the user may not want. Maybe you need a design in which the slider manipulates a number in an InputField (which could obviously also be set directly) together with a button that initiates a calculation. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Keep Slider Consistent With a Slow Graph You cannot plot without a numeric value for xMax so definition sholud be \ restricted to numeric input plotSlowGraph[xMax_?NumericQ] := Module[{x, t}, Plot[ NIntegrate[1/((t^2 - 1)*t*Log[t]), {t, x, Infinity}], {x, 2, xMax}]]; To ensure that they are synched, set option SynchronousUpdating to True Manipulate[plotSlowGraph[xMax], {{xMax, 10, \x Max\}, 10, 400, 10, Appearance -> \Labeled\}, SynchronousUpdating -> True, ContinuousAction -> False, SaveDefinitions -> True] Bob Hanlon The graph displayed by the Manipulate below takes a while to display. While the calculation is taking place, if you click on some other value on the slider, the slider moves and displays its new value. However, the graph will plot using the original value. The result is that the graph and the slider are now out of sync. This is bad user interface design. In the real example I am working with, there is no way to make the calculations go fast enough to keep up with clicks on the slider. For the same reason, I cannot allow the user to slide the slider, so ContinuousAction must be False. Nevertheless, is there some way to make sure the slider and the graph stay consistent with each other? Robert Baillie plotSlowGraph[xMax_] := Module[ { x, t }, Plot[ NIntegrate[1/((t^2 - 1)*t*Log[t]), {t, x, Infinity}], {x, 2, xMax} ] ]; Manipulate[ Graphics[ plotSlowGraph[xMax] ], { {xMax, 10, \x Max\}, 10, 400, 10, Appearance -> \Labeled\ }, ContinuousAction -> False, SaveDefinitions->True ] === Subject: Re: simultaneous equations for chemical speciation You have 13 unknowns but only 8 equation. I presume you want to derive an expression for g? Remove[\Global`*\] 1. Your systems is chem = {a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, n + m + b + c == g + l}; 2. Solving the 6th eqn gives an idea as to what g should look like, gsol = Solve[chem[[6]], g] gives the following. g-> f j / m 3. Let's replace f, j and m in above by solving the appropriate equations in \ your system. Solving the eqn 2 for f and replace into the system (giving the replaced \ system a new name chem2) fsol = Solve[chem[[2]], f] chem2 = chem /. fsol // Flatten 4. Repeat for m. msol = Solve[chem2[[7]], m] chem3 = chem2 /. msol // Flatten 5. Now note j expression is really ugly. Let's use i and h equations to \ simplify. chem4 = chem3 /. {i -> d/(c g), h -> c/(b g)} 6. Solve for b and replace. bsol = Solve[chem4[[1]], b] chem5 = chem4 /. bsol // Flatten 7. Solve for l and replace. lsol = Solve[chem5[[6]], l] chem6 = chem5 /. lsol // Cancel // Flatten 8. Finally solve for g and you will get a huge expression. gsol = Solve[chem6[[8]], g] %//length You can now do parameter lumping to see if you can further simplify the \ expressions for g. There are 3 roots. I don't know if you need all 3. Since \ it's chem, you will need positive ones. People in here will be able to tell you how to simplify this further. If you want to do everything in one cell, copy and paste the following. Remove[\Global`*\] chem = {a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, n + m + b + c == g + l}; gsol = Solve[chem[[6]], g] fsol = Solve[chem[[2]], f] chem2 = chem /. fsol // Flatten msol = Solve[chem2[[7]], m] chem3 = chem2 /. msol // Flatten chem4 = chem3 /. {i -> d/(c g), h -> c/(b g)} bsol = Solve[chem4[[1]], b] chem5 = chem4 /. bsol // Flatten lsol = Solve[chem5[[6]], l] chem6 = chem5 /. lsol // Cancel // Flatten gsol = Solve[chem6[[8]], g] % // Length === > Subject: simultaneous equations for chemical speciation > completely new to mathematica, I am just > starting to realise the possibilities. > > I am trying to do a chemical speciation calculation. > I have a set of simultaneous equations which represents the > equilibria, > mass balance, and charge balance in the system. > > I want to eliminate some of the variables, and then be able > to solve for > the remaining ones. > My system of equations looks like this: > a=b+c+d > e=f+g+c+2d > h=c/(bg) > i=d/(cg) > hi=d/(bg^2) > j=mg/f > k=lm > n+m+b+c=g+l > > Basically, I can solve for the variable I want, but I am > having trouble > eliminating the ones I don't want (ie. I am getting an > answer that is in > terms of the wrong variables) > Sofar my formula looks like: > > Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), > i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == > l*m, > n + m + b + c == g + l}, {g}] > > If I use a similar formula for the \Eliminate\ function, I > get error > mesages. > > I have been in the help files for ages, and don't really > understand how > to do this. > I would really appreciate some pointers!! > > === Subject: Re: list manipulation Join[ Take[#,n], {f[#[[n+1]],#[[n+2]]]}, Drop[#,n+2] ]& /@ data If f can operate on lists then Transpose@Join[ Take[#,n], {f[#[[n+1]],#[[n+2]]]}, Drop[#,n+2] ]& @ Transpose@data should be faster. > I'm wondering if anyone has bright ideas on the puzzle below. I'm trying > to take a very large list of the following form: > > {{.., .., a, b, ..},{.., .., c, d, ..},..} > > into the form > > {{.., .., f[a, b], ..},{.., .., f[c, d], ..},..} > > It seems to me that there must be some clever and beautiful way to do \ this > that I haven't thought of. My code is below with two clumsy solutions. > > Suggestions on how to do better? > > My code: > > In[1]:= (*shown here as minimal to define problem but actual list has \\ > large N and many entries*) > > data = {{element11, element12, element1N, target11, target12, > element1N3, element1N4}, {element21, element22, element2N, > target21, target22, element2N3, element2N4}}; > > In[2]:= (* first clumsy approach *) > > Replace[data, list : _List :> {Sequence @@ list[[1 ;; 3]], > Sequence[f[list[[4 ;; 5]]]], Sequence @@ list[[6 ;;]]}, {1}] > > Out[2]= {{element11, element12, element1N, f[{target11, target12}], > element1N3, element1N4}, {element21, element22, element2N, > f[{target21, target22}], element2N3, element2N4}} > > In[3]:= (* second clumsy approach *) > > data /. {a : Repeated[_, {3}], b : Repeated[_, {2}], > c : __} -> {a, f[b], c} > > Out[3]= {{element11, element12, element1N, f[target11, target12], > element1N3, element1N4}, {element21, element22, element2N, > f[target21, target22], element2N3, element2N4}} === Subject: Re: list manipulation Hi Scot, I would not call your solutions clumsy. I think they are brief, reasonably fast and accomplish their goal. Note that your second solution won't work \ in the way you put it - you also need Replace, otherwise the matching will happen on a higher level - f will be applied to the 4-th and 5-th sublists of your main list (you did not observe it since you only had 2 sublists). Also, I think you need there RuleDelayed rather than Rule: In[1] = data = {{element11, element12, element1N, target11, target12, element1N3, element1N4}, {element21, element22, element2N, target21, target22, element2N3, element2N4}}; In[2] = Replace[data, {a : Repeated[_, {3}], b : Repeated[_, {2}], c : __} :> {a, f[b], c}, {1}] Out[2] = {{element11, element12, element1N, f[target11, target12], element1N3, element1N4}, {element21, element22, element2N, f[target21, target22], element2N3, element2N4}} Note also that they are not equivalent: your first one creates f[{a,b}] while the second one just f[a,b]. Here is a little more obscure but faster (about 4 x times, according to my benchmarks) way to accomplish your goal (assuming the format of your \ second solution): In[3] = Module[{copy = data}, copy[[All, 4]] = f @@@ copy[[All, {4, 5}]]; copy[[All, 5]] = Sequence[]; copy] Out[3] = {{element11, element12, element1N, f[target11, target12], element1N3, element1N4}, {element21, element22, element2N, f[target21, target22], element2N3, element2N4}} Hope this helps. Leonid > I'm wondering if anyone has bright ideas on the puzzle below. I'm trying > to take a very large list of the following form: > > {{.., .., a, b, ..},{.., .., c, d, ..},..} > > into the form > > {{.., .., f[a, b], ..},{.., .., f[c, d], ..},..} > > It seems to me that there must be some clever and beautiful way to do \ this > that I haven't thought of. My code is below with two clumsy solutions. > > Suggestions on how to do better? > > My code: > > In[1]:= (*shown here as minimal to define problem but actual list has \\ > large N and many entries*) > > data = {{element11, element12, element1N, target11, target12, > element1N3, element1N4}, {element21, element22, element2N, > target21, target22, element2N3, element2N4}}; > > > > In[2]:= (* first clumsy approach *) > > Replace[data, list : _List :> {Sequence @@ list[[1 ;; 3]], > Sequence[f[list[[4 ;; 5]]]], Sequence @@ list[[6 ;;]]}, {1}] > > > Out[2]= {{element11, element12, element1N, f[{target11, target12}], > element1N3, element1N4}, {element21, element22, element2N, > f[{target21, target22}], element2N3, element2N4}} > > > > In[3]:= (* second clumsy approach *) > > data /. {a : Repeated[_, {3}], b : Repeated[_, {2}], > c : __} -> {a, f[b], c} > > Out[3]= {{element11, element12, element1N, f[target11, target12], > element1N3, element1N4}, {element21, element22, element2N, > f[target21, target22], element2N3, element2N4}} > > === Subject: Re: list manipulation data /. {a_, b_, c_, d_, e_, x__} :> {a, b, c, f[d, e], x} ? Jens > I'm wondering if anyone has bright ideas on the puzzle below. I'm trying > to take a very large list of the following form: > > {{.., .., a, b, ..},{.., .., c, d, ..},..} > > into the form > > {{.., .., f[a, b], ..},{.., .., f[c, d], ..},..} > > It seems to me that there must be some clever and beautiful way to do this \ > that I haven't thought of. My code is below with two clumsy solutions. > > Suggestions on how to do better? > > My code: > > In[1]:= (*shown here as minimal to define problem but actual list has \\ > large N and many entries*) > > data = {{element11, element12, element1N, target11, target12, > element1N3, element1N4}, {element21, element22, element2N, > target21, target22, element2N3, element2N4}}; > > > > In[2]:= (* first clumsy approach *) > > Replace[data, list : _List :> {Sequence @@ list[[1 ;; 3]], > Sequence[f[list[[4 ;; 5]]]], Sequence @@ list[[6 ;;]]}, {1}] > > > Out[2]= {{element11, element12, element1N, f[{target11, target12}], > element1N3, element1N4}, {element21, element22, element2N, > f[{target21, target22}], element2N3, element2N4}} > > > > In[3]:= (* second clumsy approach *) > > data /. {a : Repeated[_, {3}], b : Repeated[_, {2}], > c : __} -> {a, f[b], c} > > Out[3]= {{element11, element12, element1N, f[target11, target12], > element1N3, element1N4}, {element21, element22, element2N, > f[target21, target22], element2N3, element2N4}} > === Subject: Re: list manipulation The Presentations package from my web site ($50) has a command in the Manipulations section named MapLevelParts that does what you want. MapLevelParts[function, {topposition, levelpositions}][expr] will map the function onto the selected level positions in an expression. Levelpositions is a list of the selected parts. The function is applied to them as a group and they are replaced with a single new expression. Other parts not specified in levelpositions are left unchanged. Example: a + b + c + d + e // MapLevelParts[f, {{2,4,5}}] -> a + c + f[b + d + e] For your case we could do it as follows: testlist = RandomInteger[{-10, 10}, {5, 5}] {{6, 4, 5, -5, -2}, {-3, -5, -8, 9, -3}, {6, -2, -3, 8, -4}, {4, 10, 2, -6, 9}, {-2, -7, 4, 4, -7}} MapLevelParts[f @@ # &, {{3, 4}}] /@ testlist {{6, 4, f[5, -5], -2}, {-3, -5, f[-8, 9], -3}, {6, -2, f[-3, 8], -4}, {4, 10, f[2, -6], 9}, {-2, -7, f[4, 4], -7}} David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm wondering if anyone has bright ideas on the puzzle below. I'm trying to take a very large list of the following form: {{.., .., a, b, ..},{.., .., c, d, ..},..} into the form {{.., .., f[a, b], ..},{.., .., f[c, d], ..},..} It seems to me that there must be some clever and beautiful way to do this that I haven't thought of. My code is below with two clumsy solutions. Suggestions on how to do better? My code: In[1]:= (*shown here as minimal to define problem but actual list has \\ large N and many entries*) data = {{element11, element12, element1N, target11, target12, element1N3, element1N4}, {element21, element22, element2N, target21, target22, element2N3, element2N4}}; In[2]:= (* first clumsy approach *) Replace[data, list : _List :> {Sequence @@ list[[1 ;; 3]], Sequence[f[list[[4 ;; 5]]]], Sequence @@ list[[6 ;;]]}, {1}] Out[2]= {{element11, element12, element1N, f[{target11, target12}], element1N3, element1N4}, {element21, element22, element2N, f[{target21, target22}], element2N3, element2N4}} In[3]:= (* second clumsy approach *) data /. {a : Repeated[_, {3}], b : Repeated[_, {2}], c : __} -> {a, f[b], c} Out[3]= {{element11, element12, element1N, f[target11, target12], element1N3, element1N4}, {element21, element22, element2N, f[target21, target22], element2N3, element2N4}} === Subject: Re: list manipulation I'm wondering if anyone has bright ideas on the puzzle below. I'm trying to take a very large list of the following form: {{.., .., a, b, ..},{.., .., c, d, ..},..} into the form {{.., .., f[a, b], ..},{.., .., f[c, d], ..},..} It seems to me that there must be some clever and beautiful way to do this that I haven't thought of. My code is below with two clumsy solutions. Suggestions on how to do better? My code: In[1]:= (*shown here as minimal to define problem but actual list has \\ large N and many entries*) data = {{element11, element12, element1N, target11, target12, element1N3, element1N4}, {element21, element22, element2N, target21, target22, element2N3, element2N4}}; In[2]:= (* first clumsy approach *) Replace[data, list : _List :> {Sequence @@ list[[1 ;; 3]], Sequence[f[list[[4 ;; 5]]]], Sequence @@ list[[6 ;;]]}, {1}] Out[2]= {{element11, element12, element1N, f[{target11, target12}], element1N3, element1N4}, {element21, element22, element2N, f[{target21, target22}], element2N3, element2N4}} In[3]:= (* second clumsy approach *) data /. {a : Repeated[_, {3}], b : Repeated[_, {2}], c : __} -> {a, f[b], c} Out[3]= {{element11, element12, element1N, f[target11, target12], element1N3, element1N4}, {element21, element22, element2N, f[target21, target22], element2N3, element2N4}} === Subject: Re: list manipulation Hi Scot, I would not call your solutions clumsy. I think they are brief, reasonably fast and accomplish their goal. Note that your second solution won't work \ in the way you put it - you also need Replace, otherwise the matching will happen on a higher level - f will be applied to the 4-th and 5-th sublists of your main list (you did not observe it since you only had 2 sublists). Also, I think you need there RuleDelayed rather than Rule: In[1] = data = {{element11, element12, element1N, target11, target12, element1N3, element1N4}, {element21, element22, element2N, target21, target22, element2N3, element2N4}}; In[2] = Replace[data, {a : Repeated[_, {3}], b : Repeated[_, {2}], c : __} :> {a, f[b], c}, {1}] Out[2] = {{element11, element12, element1N, f[target11, target12], element1N3, element1N4}, {element21, element22, element2N, f[target21, target22], element2N3, element2N4}} Note also that they are not equivalent: your first one creates f[{a,b}] while the second one just f[a,b]. Here is a little more obscure but faster (about 4 x times, according to my benchmarks) way to accomplish your goal (assuming the format of your \ second solution): In[3] = Module[{copy = data}, copy[[All, 4]] = f @@@ copy[[All, {4, 5}]]; copy[[All, 5]] = Sequence[]; copy] Out[3] = {{element11, element12, element1N, f[target11, target12], element1N3, element1N4}, {element21, element22, element2N, f[target21, target22], element2N3, element2N4}} Hope this helps. Leonid > I'm wondering if anyone has bright ideas on the puzzle below. I'm trying > to take a very large list of the following form: > > {{.., .., a, b, ..},{.., .., c, d, ..},..} > > into the form > > {{.., .., f[a, b], ..},{.., .., f[c, d], ..},..} > > It seems to me that there must be some clever and beautiful way to do \ this > that I haven't thought of. My code is below with two clumsy solutions. > > Suggestions on how to do better? > > My code: > > In[1]:= (*shown here as minimal to define problem but actual list has \\ > large N and many entries*) > > data = {{element11, element12, element1N, target11, target12, > element1N3, element1N4}, {element21, element22, element2N, > target21, target22, element2N3, element2N4}}; > > > > In[2]:= (* first clumsy approach *) > > Replace[data, list : _List :> {Sequence @@ list[[1 ;; 3]], > Sequence[f[list[[4 ;; 5]]]], Sequence @@ list[[6 ;;]]}, {1}] > > > Out[2]= {{element11, element12, element1N, f[{target11, target12}], > element1N3, element1N4}, {element21, element22, element2N, > f[{target21, target22}], element2N3, element2N4}} > > > > In[3]:= (* second clumsy approach *) > > data /. {a : Repeated[_, {3}], b : Repeated[_, {2}], > c : __} -> {a, f[b], c} > > Out[3]= {{element11, element12, element1N, f[target11, target12], > element1N3, element1N4}, {element21, element22, element2N, > f[target21, target22], element2N3, element2N4}} > > === Subject: Re: list manipulation data /. {a_, b_, c_, d_, e_, x__} :> {a, b, c, f[d, e], x} ? Jens > I'm wondering if anyone has bright ideas on the puzzle below. I'm trying > to take a very large list of the following form: > > {{.., .., a, b, ..},{.., .., c, d, ..},..} > > into the form > > {{.., .., f[a, b], ..},{.., .., f[c, d], ..},..} > > It seems to me that there must be some clever and beautiful way to do this \ > that I haven't thought of. My code is below with two clumsy solutions. > > Suggestions on how to do better? > > My code: > > In[1]:= (*shown here as minimal to define problem but actual list has \\ > large N and many entries*) > > data = {{element11, element12, element1N, target11, target12, > element1N3, element1N4}, {element21, element22, element2N, > target21, target22, element2N3, element2N4}}; > > > > In[2]:= (* first clumsy approach *) > > Replace[data, list : _List :> {Sequence @@ list[[1 ;; 3]], > Sequence[f[list[[4 ;; 5]]]], Sequence @@ list[[6 ;;]]}, {1}] > > > Out[2]= {{element11, element12, element1N, f[{target11, target12}], > element1N3, element1N4}, {element21, element22, element2N, > f[{target21, target22}], element2N3, element2N4}} > > > > In[3]:= (* second clumsy approach *) > > data /. {a : Repeated[_, {3}], b : Repeated[_, {2}], > c : __} -> {a, f[b], c} > > Out[3]= {{element11, element12, element1N, f[target11, target12], > element1N3, element1N4}, {element21, element22, element2N, > f[target21, target22], element2N3, element2N4}} > === Subject: Re: list manipulation The Presentations package from my web site ($50) has a command in the Manipulations section named MapLevelParts that does what you want. MapLevelParts[function, {topposition, levelpositions}][expr] will map the function onto the selected level positions in an expression. Levelpositions is a list of the selected parts. The function is applied to them as a group and they are replaced with a single new expression. Other parts not specified in levelpositions are left unchanged. Example: a + b + c + d + e // MapLevelParts[f, {{2,4,5}}] -> a + c + f[b + d + e] For your case we could do it as follows: testlist = RandomInteger[{-10, 10}, {5, 5}] {{6, 4, 5, -5, -2}, {-3, -5, -8, 9, -3}, {6, -2, -3, 8, -4}, {4, 10, 2, -6, 9}, {-2, -7, 4, 4, -7}} MapLevelParts[f @@ # &, {{3, 4}}] /@ testlist {{6, 4, f[5, -5], -2}, {-3, -5, f[-8, 9], -3}, {6, -2, f[-3, 8], -4}, {4, 10, f[2, -6], 9}, {-2, -7, f[4, 4], -7}} David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm wondering if anyone has bright ideas on the puzzle below. I'm trying to take a very large list of the following form: {{.., .., a, b, ..},{.., .., c, d, ..},..} into the form {{.., .., f[a, b], ..},{.., .., f[c, d], ..},..} It seems to me that there must be some clever and beautiful way to do this that I haven't thought of. My code is below with two clumsy solutions. Suggestions on how to do better? My code: In[1]:= (*shown here as minimal to define problem but actual list has \\ large N and many entries*) data = {{element11, element12, element1N, target11, target12, element1N3, element1N4}, {element21, element22, element2N, target21, target22, element2N3, element2N4}}; In[2]:= (* first clumsy approach *) Replace[data, list : _List :> {Sequence @@ list[[1 ;; 3]], Sequence[f[list[[4 ;; 5]]]], Sequence @@ list[[6 ;;]]}, {1}] Out[2]= {{element11, element12, element1N, f[{target11, target12}], element1N3, element1N4}, {element21, element22, element2N, f[{target21, target22}], element2N3, element2N4}} In[3]:= (* second clumsy approach *) data /. {a : Repeated[_, {3}], b : Repeated[_, {2}], c : __} -> {a, f[b], c} Out[3]= {{element11, element12, element1N, f[target11, target12], element1N3, element1N4}, {element21, element22, element2N, f[target21, target22], element2N3, element2N4}} === Subject: Re: list manipulation I'm wondering if anyone has bright ideas on the puzzle below. I'm trying to take a very large list of the following form: {{.., .., a, b, ..},{.., .., c, d, ..},..} into the form {{.., .., f[a, b], ..},{.., .., f[c, d], ..},..} It seems to me that there must be some clever and beautiful way to do this that I haven't thought of. My code is below with two clumsy solutions. Suggestions on how to do better? My code: In[1]:= (*shown here as minimal to define problem but actual list has \\ large N and many entries*) data = {{element11, element12, element1N, target11, target12, element1N3, element1N4}, {element21, element22, element2N, target21, target22, element2N3, element2N4}}; In[2]:= (* first clumsy approach *) Replace[data, list : _List :> {Sequence @@ list[[1 ;; 3]], Sequence[f[list[[4 ;; 5]]]], Sequence @@ list[[6 ;;]]}, {1}] Out[2]= {{element11, element12, element1N, f[{target11, target12}], element1N3, element1N4}, {element21, element22, element2N, f[{target21, target22}], element2N3, element2N4}} In[3]:= (* second clumsy approach *) data /. {a : Repeated[_, {3}], b : Repeated[_, {2}], c : __} -> {a, f[b], c} Out[3]= {{element11, element12, element1N, f[target11, target12], element1N3, element1N4}, {element21, element22, element2N, f[target21, target22], element2N3, element2N4}} === Subject: Tube in ParametricPlot3D with too many details I'm using the following code to get a tube around a homoclinic loop hloop = ParametricPlot3D[{-2 Sech[ u], u - 2 Tanh[ u], 0 }, {u, -5, 5}, PlotStyle -> {Tube[0.1], Red}, Axes -> None] The only issue is that, if I try to export it as a pdf, I get too many details which results in (too) big pdf. Is there anyway to have Mathematica producing a plot with less Giovanni Lanzani === Subject: Re: constants >Hi mathematica community I have to Reduce[{x + a*z/(1 - d) == y + >a*w/(1 - d)] I need to tell mathematica that a and d are constants >how ? Why do you think you need to have a means to make a and d constant? What are you expecting Reduce to do here. If you replace a with 1 and d with 0 the relationship becomes x + z == y + w which cannot be reduced further without more information. The same is true regardless of what constant values are chosen for a and d with the one exception of d = 1. === Subject: Re: update notebook calculations on startup? > I'm using mathematica to do some calculations on financial data and want to know if there is a way to make the calculations execute automatically \ when I notebook is open. > > For example I have a notebook with the following code: > stock1 = \ASX:RHC\ > > stock2 = \ASX:PRY\ > > > correlationOffset = -150 > > FinancialData[stock2, \Jan. 1,2009\]}, Joined -> True, > PlotLabel -> \Blue -> \ + stock1 + \Red -> \ + stock2, > > I would like it to update the graph automatically rather than me having to \ go through and shift+enter on each of the lines. > One possibility is to encapsulate your code as a Dynamic item (simplest example is in a Manipulate, but using more general Dynamic functionality allows much more creativity) with an appropriate Refresh. This has been covered in this group at times in the past (I don't have time to give an example right now ---yes Fermat Lives!). But such an approach can cause your example to automatically update at a specified interval. Sorry for the brevity of this comment... --David === Subject: Re: update notebook calculations on startup? Make the cells you want to be automatically evaluated Initialization cells. You do this be selecting them and then using Menu -> Cell -> Cell \ Properties -> Initialization Cell. Or use Alt-CPI. When you first save the notebook you will be asked if you want it saved as an AutoGenerated Package. Answer NO. (That would generate a .m package \ file, which you don't want. You just want the initialization cells to be \ evaluated when you open the notebook.) So far, what this will do is cause a pop-up window to ask if you want the initialization cells evaluated when you first try to evaluate any cell in the notebook. What you want is for the initialization cells to be automatically evaluated when the notebook is opened. To get that open the Options Inspector (Shift-Ctrl-O), set the selection in Show option values \ to your notebook, and go to Notebook Options, Evaluation Options. Then set InitializationCellEvaluation to True and InitializationCellWarning to \ False. Then change Show option values to Global Preferences and set GlobalInitializationCellWarning to False. (Otherwise you will obtain a pop-up window on opening the notebook asking if you want to evaluate the initialization cells.) Then the desired cells will be automatically evaluated on opening the notebook. Another possibility is to put all of the cells you want to initialize in \ one Section of the notebook, without making them initialization cells. Then select the entire section and evaluate it when you open the notebook. This isn't automatic but it is fairly easy. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm using mathematica to do some calculations on financial data and want to know if there is a way to make the calculations execute automatically when \ I notebook is open. For example I have a notebook with the following code: stock1 = \ASX:RHC\ stock2 = \ASX:PRY\ correlationOffset = -150 =C2 FinancialData[stock2, \Jan. 1,2009\]}, Joined -> True, =C2 PlotLabel -> \Blue -> \ + stock1 +=C2 \Red -> \ + stock2, I would like it to update the graph automatically rather than me having to go through and shift+enter on each of the lines. === Subject: Re: update notebook calculations on startup? > I'm using mathematica to do some calculations on financial data and want \ to know if there is a way to make the calculations execute automatically when \ I notebook is open. > > For example I have a notebook with the following code: > stock1 = \ASX:RHC\ > > stock2 = \ASX:PRY\ > > > correlationOffset = -150 > > =C2 FinancialData[stock2, \Jan. 1,2009\]}, Joined -> True, > =C2 PlotLabel -> \Blue -> \ + stock1 +=C2 \Red -> \ + stock2, > > I would like it to update the graph automatically rather than me having to \ go through and shift+enter on each of the lines. Make them initialization cells. Select the cells in question, then click on Cell, Cell Properties, Initialization Cell. -- Helen Read University of Vermont === Subject: Re: update notebook calculations on startup? Make the cells you want to be automatically evaluated Initialization cells. You do this be selecting them and then using Menu -> Cell -> Cell \ Properties -> Initialization Cell. Or use Alt-CPI. When you first save the notebook you will be asked if you want it saved as an AutoGenerated Package. Answer NO. (That would generate a .m package \ file, which you don't want. You just want the initialization cells to be \ evaluated when you open the notebook.) So far, what this will do is cause a pop-up window to ask if you want the initialization cells evaluated when you first try to evaluate any cell in the notebook. What you want is for the initialization cells to be automatically evaluated when the notebook is opened. To get that open the Options Inspector (Shift-Ctrl-O), set the selection in Show option values \ to your notebook, and go to Notebook Options, Evaluation Options. Then set InitializationCellEvaluation to True and InitializationCellWarning to \ False. Then change Show option values to Global Preferences and set GlobalInitializationCellWarning to False. (Otherwise you will obtain a pop-up window on opening the notebook asking if you want to evaluate the initialization cells.) Then the desired cells will be automatically evaluated on opening the notebook. Another possibility is to put all of the cells you want to initialize in \ one Section of the notebook, without making them initialization cells. Then select the entire section and evaluate it when you open the notebook. This isn't automatic but it is fairly easy. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm using mathematica to do some calculations on financial data and want to know if there is a way to make the calculations execute automatically when \ I notebook is open. For example I have a notebook with the following code: stock1 = \ASX:RHC\ stock2 = \ASX:PRY\ correlationOffset = -150 =C2 FinancialData[stock2, \Jan. 1,2009\]}, Joined -> True, =C2 PlotLabel -> \Blue -> \ + stock1 +=C2 \Red -> \ + stock2, I would like it to update the graph automatically rather than me having to go through and shift+enter on each of the lines. === Subject: Re: update notebook calculations on startup? > I'm using mathematica to do some calculations on financial data and want \ to know if there is a way to make the calculations execute automatically when \ I notebook is open. > > For example I have a notebook with the following code: > stock1 = \ASX:RHC\ > > stock2 = \ASX:PRY\ > > > correlationOffset = -150 > > =C2 FinancialData[stock2, \Jan. 1,2009\]}, Joined -> True, > =C2 PlotLabel -> \Blue -> \ + stock1 +=C2 \Red -> \ + stock2, > > I would like it to update the graph automatically rather than me having to \ go through and shift+enter on each of the lines. Make them initialization cells. Select the cells in question, then click on Cell, Cell Properties, Initialization Cell. -- Helen Read University of Vermont === Subject: Re: no Condition in EventHandler? You are correct. You should, instead, use CurrentValue[] on the rhs of the \MouseDown\ event handler to probe the behavior. The EventHandler will \ trigger for every \MouseDown\ event, of course, but just code the event handler so \ that it's a no-op when you don't need it, and does the appropriate thing when you \ do. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > EventHandler[ > > \TEST\, > (\MouseDown\ :> Print[1]) /; CurrentValue[\AltKey\], > (\MouseDown\ :> Print[2]) /; CurrentValue[\ControlKey\], > (\MouseDown\ :> Print[3]) /; CurrentValue[\ShiftKey\], > (\MouseDown\ :> > Print[4, CurrentValue[\AltKey\], CurrentValue[\ControlKey\], > CurrentValue[\ShiftKey\]]) /; True, > \MouseDown\ :> > Print[5, CurrentValue[\AltKey\], CurrentValue[\ControlKey\], > CurrentValue[\ShiftKey\]] /; False > ] > > Does not do what I expect. (5 is always printed, and nothing else, no > matter what keys are down). > > I can only speculate that EventHandler doesn't evaluate its actions in > such a way that a Condition has a chance to take effect or not? === Subject: Working with Indeterminate in large numerical lists Hi everyone, I'm wondering about the optimal way to work with Indeterminate in large matrices. I've been using this to replace \bad\ data points that I want to prevent from polluting calculations involving lists of data, but I'm not sure I'm working as smartly as I could be. As an example, suppose I have a list of machine-precision reals and some Indeterminate elements: x = RandomSample[Join[RandomReal[1, 1000], ConstantArray [Indeterminate, 10]]; If I want to take only the valid entries, the best I have been able to find is something like: Select[x, NumberQ] This seems to work reasonably well. But if I want to specifically select the Indeterminate entries, there doesn't seem to be any function (equivalent to, say, \isnan\ from another system), so I have to resort to something less succinct like Does anyone have any suggestions on better ways to do this, or any general tips for working with Indeterminate in this context? I'm particularly keen to do things in the most efficient way possible as I'm working with rather large lists. Peter. === Subject: Re: Working with Indeterminate in large numerical lists x /. Indeterminate:> Sequence[] ? DeleteCases[x,Indeterminate,Infinity] ? Jens > Hi everyone, > I'm wondering about the optimal way to work with Indeterminate in > large matrices. I've been using this to replace \bad\ data points that > I want to prevent from polluting calculations involving lists of data, > but I'm not sure I'm working as smartly as I could be. > > As an example, suppose I have a list of machine-precision reals and > some Indeterminate elements: > > x = RandomSample[Join[RandomReal[1, 1000], ConstantArray > [Indeterminate, 10]]; > > If I want to take only the valid entries, the best I have been able to > find is something like: > > Select[x, NumberQ] > > This seems to work reasonably well. But if I want to specifically > select the Indeterminate entries, there doesn't seem to be any > function (equivalent to, say, \isnan\ from another system), so I have \ to > resort to something less succinct like > > > Does anyone have any suggestions on better ways to do this, or any > general tips for working with Indeterminate in this context? > > I'm particularly keen to do things in the most efficient way possible > as I'm working with rather large lists. > > Peter. > === Subject: Re: using predefined expressions in functions [newbie This is a problem of scope. You use SetDelayed (:=) (which is generally a right thing when defining a function), which does not evaluate the r.h.s. The resulting definition of does not know about you parameters: In[1] = DownValues[f] Out[1] = {HoldPattern[f[x1_, y1_, z1_, x2_, y2_, z2_]] :> R1.R2} The parameter - passing is a 2-step process: first, the porameters are substituted textually into the code of the r.h.s as present in \ ...Values (DownValues in this case), then the resulting code is evaluated. In your case, no substitution takes place in step 1 since R1 and R2 are just \ symbols - they do not explicitly (literally) contain x1, y1, etc. Since the step 1 was idle, the step 2 just uses symbolic expression for R1, R2 that you defined - hence your answer. The simplest solution in your case is to use Set, making sure that your variables don't have global values (use Clear for instance): In[2] = Clear[x1, x2, y1, y2, z1, z2]; f[x1_, y1_, z1_, x2_, y2_, z2_] = R1.R2; In[3] = f[1, 2, 3, 4, 5, 6] Out[3] = 32 Note that in general using proxies like R1, R2 and then Set to define functions is error - prone. It is better to either use the actual expressions on the r.h.s or make R1, R2 functions and either way use SetDelayed: In[4] = Clear[R1, R2, f]; R1[x_, y_, z_] := {x, y, z}; R2[x_, y_, z_] := {x, y, z}; f[x1_, y1_, z1_, x2_, y2_, z2_] := R1[x1, y1, z1].R2[x2, y2, z2] In[5] = f[1, 2, 3, 4, 5, 6] Out[5] = 32 Leonid > > I've been trying to write a function using some predefined > expressions, but the function assignment seems to understand the > symbols in the expressions as literals. eg., > > Needs[\VectorAnalysis`\] > R1 := {x1,y1,z1} > R2 := {x2,y2,z2} > f[x1_,y1_,z1_,x2_,y2_,z2_] := R1 . R2 > > f[1,2,3,4,5,6] > > gives the output > x1 x2 + y1 y2 + z1 z2 > instead of > 32 ( = 1*4 + 2*5 + 3*6 ) > > > > -ChangMo > > === Subject: Re: simultaneous equations for chemical speciation eqns = { a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, n + m + b + c == g + l}; Length[eqns] 8 vars = Union[Cases[eqns, _Symbol, Infinity]] {a,b,c,d,e,f,g,h,i,j,k,l,m,n} Length[vars] 14 You have 8 eqns with 14 variables. Specify 6 variables to solve for. (soln = Solve[eqns, Take[vars, {4, 9}]][[1]] // Sort) // Column Union[Cases[Last /@ soln, _Symbol, Infinity]] {a,b,c,j,l,m,n} Length[%] 7 There are only 7 of the 8 remaining variables used so you can eliminate one \ variable (soln2 = Solve[eqns, Take[vars, {5, 9}]][[1]] // Sort) // Column Union[Cases[Last /@ soln2, _Symbol, Infinity]] {b,c,d,j,l,m,n} Length[%] 7 Bob Hanlon starting to realise the possibilities. I am trying to do a chemical speciation calculation. I have a set of simultaneous equations which represents the equilibria, mass balance, and charge balance in the system. I want to eliminate some of the variables, and then be able to solve for the remaining ones. My system of equations looks like this: a=b+c+d e=f+g+c+2d h=c/(bg) i=d/(cg) hi=d/(bg^2) j=mg/f k=lm n+m+b+c=g+l Basically, I can solve for the variable I want, but I am having trouble eliminating the ones I don't want (ie. I am getting an answer that is in terms of the wrong variables) Sofar my formula looks like: Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, n + m + b + c == g + l}, {g}] If I use a similar formula for the \Eliminate\ function, I get error mesages. I have been in the help files for ages, and don't really understand how to do this. I would really appreciate some pointers!! === Subject: simultaneous equations - eliminating variables and solving I am trying to do a chemical speciation calculation. I have a set of simultaneous equations which represents the equilibria, mass \ balance, and charge balance in the system. I want to eliminate some of the variables, and then be able to solve for the \ remaining ones. My system of equations looks like this: a=b+c+d e=f+g+c+2d h=c/(bg) i=d/(cg) hi=d/(bg^2) j=mg/f k=lm n+m+b+c=g+l This is what my formula looks like sofar. Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, n + m + b + c == g + l}, {g}] Basically, I can solve for the variable I want, but I am having trouble \ eliminating the ones I don't want (ie. I am getting an answer that is in \ terms of the wrong variables) I have been in the help files for ages, and don't really understand how to \ do this. I would really appreciate some pointers!! === Subject: Re: simultaneous equations - eliminating variables and solving > This is what my formula looks like sofar. > > Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), > i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, > n + m + b + c == g + l}, {g}] > > Basically, I can solve for the variable I want, but I am having trouble \ eliminating the ones I don't want (ie. I am getting an answer that is in \ terms of the wrong variables) > > I have been in the help files for ages, and don't really understand how to \ do this. > I would really appreciate some pointers!! Try specifying the third \elims\ argument, which specifies the variables you'd like Solve to try to eliminate when expressing the answer. -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis Not bad from a girl from the gutter like me -- Kina === Subject: Re: simultaneous equations - eliminating variables and solving > > I am trying to do a chemical speciation calculation. > I have a set of simultaneous equations which represents the equilibria, \ mass balance, and charge balance in the system. > > I want to eliminate some of the variables, and then be able to solve for \ the remaining ones. > My system of equations looks like this: > a=b+c+d > e=f+g+c+2d > h=c/(bg) > i=d/(cg) > hi=d/(bg^2) > j=mg/f > k=lm > n+m+b+c=g+l > > This is what my formula looks like sofar. > > Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), > i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, > n + m + b + c == g + l}, {g}] > > Basically, I can solve for the variable I want, but I am having trouble \ eliminating the ones I don't want (ie. I am getting an answer that is in \ terms of the wrong variables) > > I have been in the help files for ages, and don't really understand how to \ do this. > I would really appreciate some pointers!! > Use the third argument to Solve. See http://reference.wolfram.com/mathematica/ref/Solve.html (But this particular set of equations doesn't seem to have a solution.) === Subject: Re: using predefined expressions in functions [newbie R1 := {x1, y1, z1} R2 := {x2, y2, z2} Don' t use SetDelayed in definition of f f[x1_, y1_, z1_, x2_, y2_, z2_] = R1.R2; f[1, 2, 3, 4, 5, 6] 32 Bob Hanlon I've been trying to write a function using some predefined expressions, but the function assignment seems to understand the symbols in the expressions as literals. eg., Needs[\VectorAnalysis`\] R1 := {x1,y1,z1} R2 := {x2,y2,z2} f[x1_,y1_,z1_,x2_,y2_,z2_] := R1 . R2 f[1,2,3,4,5,6] gives the output x1 x2 + y1 y2 + z1 z2 instead of 32 ( = 1*4 + 2*5 + 3*6 ) -ChangMo === Subject: Re: using predefined expressions in functions [newbie question] I don't see how the VectorAnalysis package is yet used in your example. Using SetDelayed means that the right hand side of the definition is not evaluated and the definition never sees any of the left hand side arguments on the right hand side. The arguments are useless and never get \ substituted. Use Set instead. R1 := {x1, y1, z1} R2 := {x2, y2, z2} f[x1_, y1_, z1_, x2_, y2_, z2_] = R1.R2 f[1, 2, 3, 4, 5, 6] 32 Perhaps it is just an example, but I don't see how this function does much. Isn't it almost as easy to write {1, 2, 3}.{4, 5, 6}? I often see questions on MathGroup where definitions are written in a non-localized manner, where parts of the definition are written in separate statements outside the principal definition. Although this will sometimes work, it seems to be an invitation to trouble. It is better to keep the definition together in one localized structure. I would tend to write your definition as: f[x1_, y1_, z1_, x2_, y2_, z2_] := {x1, y1, z1}.{x2, y2, z2} or as: f[x1_, y1_, z1_, x2_, y2_, z2_] := With[{R1 = {x1, y1, z1}, R2 = {x2, y2, z2}}, R1.R2] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I've been trying to write a function using some predefined expressions, but the function assignment seems to understand the symbols in the expressions as literals. eg., Needs[\VectorAnalysis`\] R1 := {x1,y1,z1} R2 := {x2,y2,z2} f[x1_,y1_,z1_,x2_,y2_,z2_] := R1 . R2 f[1,2,3,4,5,6] gives the output x1 x2 + y1 y2 + z1 z2 instead of 32 ( = 1*4 + 2*5 + 3*6 ) -ChangMo === Subject: Re: new to group - Chemical Equation Solutions (eqns = {a == b + c + d, e == f + g + c + 2 d, h == c/(b g), i == d/(c g), h i == d/(b g^2), j == (m g)/f, k == l m, n + m + b + c == g + l}) // Column I take it that {h, i, j, k} are equilibrium constants and {a, b, c, d, e, f, g, l, m, n} are species of chemicals. You only have 8 equations and they do not seem to be all independent. So you can only solve for 7 species. So you will have to specify the 4 equilibrium constants and \ 3 input species. One possibility is: sols = Solve[eqns, {b, c, d, f, g, n, l}] That gives 3 very long solutions and probably only one of them gives positive real values for all of the solved species. If we try a set of data: data = Thread[{h, i, j, k, a, e, m} -> {1, 1, 1, 1, 1, 1, 1}]; we do obtain one solution: First@Select[sols /. data // N, FreeQ[#, Complex] &] {n -> -0.611858, l -> 1., d -> 0.070959, f -> 0.317183, c -> 0.223717, b -> 0.705324, g -> 0.317183} In general, these kind of equations may be numerically difficult. There is probably a polytope in species space that defines the region of positive real solutions. If some of the equilibrium constants are very high or low the desired solution may be very close to a wall or corner of the polytope and the numerical evaluation may lose precision. So you may luck out with the standard Mathematica solutions or you may have to use special numerical action chemical equilibrium equations and was able to obtain nearly full computer precision over nearly the full real number dynamic range for these equations. (Journal of Chemical Physics, 1976, Vol 65, No. 8, pp 3085-3091, Computers Chem. 1990, Vol 14, No.2, pp 141-156) but your equations are slightly different and may require modified methods. There are probably similar good methods and programs but I don't know offhand of any implemented as general purpose packages in Mathematica. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ starting to realise the possibilities. I am trying to do a chemical speciation calculation. I have a set of simultaneous equations which represents the equilibria, \ mass balance, and charge balance in the system. I want to eliminate some of the variables, and then be able to solve for \ the remaining ones. My system of equations looks like this: a=b+c+d e=f+g+c+2d h=c/(bg) i=d/(cg) hi=d/(bg^2) j=mg/f k=lm n+m+b+c=g+l I will try to attach an image of what my formula looks like sofar. Basically, I can solve for the variable I want, but I am having trouble eliminating the ones I don't want (ie. I am getting an answer that is in terms of the wrong variables) I have been in the help files for ages, and don't really understand how to do this. I would really appreciate some pointers!! Solve[{a == b + c + d, e == f + g + c + 2 d, h == c/(b*g), i == d/(c*g), h*i == d/(b*g^2), j == m*g/f, k == l*m, n + m + b + c == g + l}, {g}] === Subject: Re: How to handle Units of Measure In this very simple example if I write R+iwL where R is measured in Ohms, w in s^-1, L in H, I expect that the result is given in Ohms. Why it doesn't happen in Mathematica ? Ho can I do to handle in a simple way those conversions ? I do it this way, simple enough: In[30]:= R := x*Ohm; w := z*Hz; L := y*H; H = Ohm/Hz; R + w*L // Simplify Out[34]= Ohm (x + y z) -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Numbering I tried to make a numbering in mathematica like 001,002,003,004....010,011,012..021. instead of 1,2,3,4....21.. Is there any way I can do like this ? What kind of format do I have to use to make it? === Subject: Re: Numbering > > I tried to make a numbering in mathematica like > > 001,002,003,004....010,011,012..021. > > instead of 1,2,3,4....21.. > > Is there any way I can do like this ? > Try using IntegerString, http://reference.wolfram.com/mathematica/ref/IntegerString.html === Subject: Re: Numbering Table[NumberForm[i, 2, NumberPadding -> {\0\, \0\}], {i, 1, 21}] ? But keep in mind it is a *Form and does not change the expression and a Form is wrapped around it. Jens > > I tried to make a numbering in mathematica like > > 001,002,003,004....010,011,012..021. > > instead of 1,2,3,4....21.. > > Is there any way I can do like this ? > > What kind of format do I have to use to make it? > > === Subject: Mathematica for Behavioral Research? This is Lin from Kent, OH. I am thinking about how to better use Mathematica \ for behavioral research. To be able to collect millisecond-level empirical \ responses, software packages are needed to create, present and control visual \ or auditory stimuli, some can also combine data analysis. As far as I know, \Pscycho\ is an open-source package for creating \ psychology stimuli for Python and \Psychophysics Toolbox\ is a free set of \ another system's functions for doing visual psychophysic research. I don't \ know whether or not there is a package available for Mathematica. If not, I \ would like to ask someone whether it is difficult to create such a package, \ which can create, control and present visual, auditory or lexical stimuli and \ collect millisecond response data. I guess the professional organizations, \ such as the Psychonomic Society, would always welcome such a contribution. === Subject: Re: Mathematica for Behavioral Research? With Andrew B. Watson, I developed a suite of packages for Mathematica. I still use these packages in my research, but there are some caveats. The package for stimulus control is Cinematica. I have used version 3.3 almost daily since 1999 and it is extremely robust. However, it only works with Mathematica v4. No upgrade is likely. Independent of Cinematica is Quest. This package controls adaptive psychometric staircases. You can download version 7.0 from the website http://vision.arc.nasa.gov/mathematica/psychophysica/ or, if you like, I can send you 7.4, which has a few minor improvements. These versions have been optimised for Mathematica v5. The work perfectly with Mathematica v4, but have reduced functionality in Mathematica v6 and \ v7. Finally, there is Psychophysica, which is independent of Cinematica and \ Quest. It has a bunch of useful stuff relating to psychometric functions. The website has version 3.1, which works with Mathematica v4 and v5, but I can send you Psychophysica v3.1.12, which works Mathematica v4, v5, v6 and \ v7. j > This is Lin from Kent, OH. I am thinking about how to better use \ Mathematica > for behavioral research. To be able to collect millisecond-level \ empirical > responses, software packages are needed to create, present and control \ visual > or auditory stimuli, some can also combine data analysis. > > As far as I know, \Pscycho\ is an open-source package for creating \ psychology > stimuli for Python and \Psychophysics Toolbox\ is a free set of another > system's functions for doing visual psychophysic research. I don't know > whether or not there is a package available for Mathematica. If not, I \ would > like to ask someone whether it is difficult to create such a package, \ which > can create, control and present visual, auditory or lexical stimuli and > collect millisecond response data. I guess the professional \ organizations, > such as the Psychonomic Society, would always welcome such a \ contribution. > > Since Mathematica has abilities to combine stimulus creating, experiment > presenting, data collecting and data analysis altogether and do it from a \ much > deeper symbolic level, so a pre-built package would be more powerful and > flexible than all other software. Can someone advice on how to do it? \ Many > === Subject: SingularValueDecomposition V6 In short: Is there a way to change the method in \ SingularValueDecomposition? Explanation: I have coded a relaxation scheme for solving a system of non-linear ODEs. \ The relaxation scheme involves solving a linear system of algebraic equations \ in the form S.b=-e. The matrix S is in my case 2000x2000. I use Krylov's method \ to solve it. At certain conditions the system becomes unstable/singular. So I \ am interested in finding the SVD for that Matrix. Unfortunately though the \ default method is extermely slow. I couldn't find in the help which method for \ finding the SVD is used, but by how slow it is I would assume it is the RQ method (which goes like n^4). But I was told that method's like \divide and \ conquer\ go like n^3*Ln(n) and will be significantly faster (and I have been told \ there are even faster methods). Is there a way to change the method in SingularValueDecomposition? In the end I could possibly use another method for resolving singularities (S-mI).b=-e, but to evaluate m I still need to know what the maximum \ singular value is. Will SingularValueList be sufficiently fast? Is there a way to \ change the method there? Alexander === Subject: Re: using predefined expressions in functions [newbie question] Try to determine the function explicitly in terms of its arguments like one \ of the following: f1[R1_, R2_] := R1.R2; In[17]:= f1[{1, 2, 3}, {4, 5, 6}] Out[17]= 32 or otherwise, f2[x1_, y1_, z1_, x2_, y2_, z2_] := x1*x2 + y1*y2 + z1*z2; In[25]:= f[1, 2, 3, 4, 5, 6] Out[25]= 32 or like this: In[35]:= f[x1_, y1_, z1_, x2_, y2_, z2_] := {x1, y1, z1}.{x2, y2, z2}; f[1, 2, 3, 4, 5, 6] Out[36]= 32 I've been trying to write a function using some predefined expressions, but the function assignment seems to understand the symbols in the expressions as literals. eg., Needs[\VectorAnalysis`\] R1 := {x1,y1,z1} R2 := {x2,y2,z2} f[x1_,y1_,z1_,x2_,y2_,z2_] := R1 . R2 f[1,2,3,4,5,6] gives the output x1 x2 + y1 y2 + z1 z2 instead of 32 ( = 1*4 + 2*5 + 3*6 ) -ChangMo -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Parallel processing I am running version 7.01 on a quad core CPU. I am doing some heavy calculations but was too lazy to use any special commands for parallelization. However, to my surprise, when I check the performance I see that all 4 kernels a busy calculating. Does anybody have any info about this automatic parallelization of Mathematica? Daniel === Subject: Solving integral equations numerically I'm trying to solve a set of two integral equations, which don't have an \ analytic solution, so I'm using NIntegrate and FindRoot nodes = 11 (*number of nodes*) RCOM = 2.17 (* common resistance *) RS0 = 0.1 (*off-sensor resistance for sensor*) RS = 1.1 (*sensor resistance pre node*) Ph = 6 (*hybrid power in W*) tcool = -25 (*coolant temperature (degC) *) ta = 1.2/2/0.0000862 (*activation temperature (K) *) l = 63.56/1000(*length of thermal path*) w = 128.05/1000(*width of thermal path*) T0 = 273 + tcool + Ph*RCOM T = 4/3*(Tlo - T0^2/ta)*(x^2/l^2 - 2*x/l) + Tlo (*parabolic temperature \ function in sensor*) I1 = (RCOM + RS0)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T], {x, 0, \ l}] I2 = (RS/l)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T]*x, {x, 0, \ l/2}] FindRoot[{Tlo == T0 + I1, T0^2/ta == Tlo + I2}, {{Tlo, 270}, {qref, 300}}] but I get errors like \... has evaluated to non-numerical values for all \ sampling points in the region with boundaries {{0,0.06356}}...\ and FindRoot \ does not move. Any idea what I'm doing wrong? === Subject: GeoDistance gives other value than SpheroidalDistance after switching to Mathematica 7, I tried to eliminate calls to SpheroidalDistance by calls to GeoDistance. However, the result of GeoDistance seems to differ by a factor 1000: args = {{46.8475, 15.4453}, {47.141163, 14.661255}}; GeoDistance @@ args SpheroidalDistance @@ args Any comment appreciated, Karsten. === Subject: Integrate Bug I am trying to calculate this integral that should be positive.But the answer is 0. In: Integrate[(1)/(z^2 + b^2 + a^2 - 2 z b Sin[\\[Theta]] - 2 a b Cos[\\[Theta]])^(1/2), {\\[Theta], 0, 2 \\[Pi]}, Assumptions -> {a > 0, b > 0, z > 0}] Out:0 Anybody have notice a situation like that? My platform is MacOSX 10.4 and Mathematica 7. Best wishes, === Subject: Re: SQLServerLaunch > has anyone ever tried to use SQLServerLaunch which is contained in > DatabaseLink`? I would have an application where this would be useful, > _if_ it does what I think, but since the documentation does not tell > more than the fact that there exist some functions to launch and > shutdown a SQL-server it's not even possible to tell whether it would do > what I want... In case anyone else is interested (otherwise I have stored the information where I will search for in the future...): I have spent some time yesterday night to find out that it does what I expected, namely start an instance of an HSQL server process and works like this: server = SQLServerLaunch[ {\mydatabase\ -> ToFileName[{$HomeDirectory, \Desktop\, \mydatabasedir\}, \dbfilename\]}, \Address\ -> \127.0.0.1\,\Port\->9001 ] the left hand side of the rule is the name of the database as it will be seen from clients, the right hand side is the filename corresponding to a HSQL database (as you would use for JDBC[\HSQL(Standalone)\,...]). After that you can connect to the database from other applications with the connection string: jdbc:hsqldb:hsql:127.0.0.1:9001/mydatabase// to connect from mathematica, that would reduce to: JDBC[\HSQL(Server)\, \127.0.0.1:9001/mydatabase\] of course for access from other machines you would need the or a real IP address and make sure no firewalls are blocking the access to the port you have used... After you are done, you might want to shut down the server with (I think this could hang if there are still open connections, but probably there is a timeout...): SQLServerShutdown[server] At any time, you can check for running server instances with: SQLServers[] hth, albert === Subject: Re: Basic question about Mathematica Interface >There are also \funny\ things (aka > bugs) if you have a dual screen setup with the positions of palettes > if you try and put them on the non-primary screen (on the Mac there is > anyway, not sure about Windows). Become familiar with using the \Options Inspector\ or OI to look at > and change parameters for individual windows. Be careful using the OI -Bob In win XP with 2 screens and palettes on secondary screen: no problem. I do it all the time. === Subject: Re: saving initialization cells as a .m file Bugs are sent to to the tech support team. FWIW, though, it's already been fixed in the internal development version of Mathematica, along with a few \ otherrelated issues such as the handling of Super/Sub Plus and Minus. For now, you'll have to remember to explicitly use the FullForm version of, e.g., SuperDagger[x]. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > Hi Daniel thank you for your response but unfortunately this didn't work > for me. b^\\[Dagger] // FullForm returns Power[b,\\[Dagger]]. I guess \ since > Power is Listable trying to define something like > Power[b_List,\\[Dagger]]:=Conjugate[Transpose[b]] doesn't work either. I think Sjoerd is right and this is probably a bug. I am not exactly sure > how to report a bug though. I remember that I've sent an email to > bugs@wolfram.com (or bug@wolfram.com) in the past for another bug but > nobody replied to me so I am not sure if that's the procedure. Baris > > > === >> Subject: Re: saving initialization cells as a .m file >> Hi Baris, if you want b^\\[Dagger] to mean SuperDagger[b] internall, >> you may define this e.g. by: >> Clear[SuperDagger, A]; SuperDagger[A_List] := Conjugate[Transpose[A]]; Format[A_^\\[Dagger], SuperDagger[A_]]; SuperDagger /; A_^\\[Dagger] := SuperDagger[A]; >> The Format line ensures that Dagger is printed instead of >> SuperDagger. The next line transforms an input of SuperDagger to Dagger. >> You may check the working by: >> b =.; SuperDagger[b] b^\\[Dagger] // FullForm >> Daniel >Hi thank you for your response, I actually copied this >> from a working notebook. I used Ctrl+^ Esc dg Esc to get the >> dagger symbol and when I copy and paste it in the email it >> becomes this. Also in the .m file it looks the sam e way. So >> I guess that's why it doesn't work. Is there anyway to >> do this without typing the full function name? I want to >> keep the notation because I have really really long >> equations to enter which I would like to finally convert to >> a .m file and the notation is the most important thing for > > >> > === > Subject: Re: saving initialization cells as a .m >> file >> > Hi Baris, f[t]= ^\\[Dagger] does not apply SuperDagger. You would have to say SuperDagger[f[t]] Daniel > > > I have the following code which runs fine in a notebook: SuperDagger[A_List] := Conjugate[Transpose[A]] eqn = {f'[t] == -f[t]^\\[Dagger].f[t], f[0] == RandomReal[{0, 0.1}, {3, 3}]}; NDSolve[eqn, f, {t, 0, 10}] but when I save the first two lines (definition >> of >SuperDagger and eqn) in a .m file and load them with a >> Get >command, although Mathematica loads the definitions, >> NDSolve >doesn't like the input and complains that derivative >> at t=0 >is not defined. Weirdly if I copy and paste the output >> of >NDSolve and evaluate it, it runs fine. Do you know how >> can I >fix this? > Baris Altunkaynak === Subject: Re: MemoryInUse and Print on my system I get a constant memory decrease with $HistoryLength = 0; Print[Share[]; MemoryInUse[]]; Print[Share[]; MemoryInUse[]]; Print[Share[]; MemoryInUse[]]; Print[Share[]; MemoryInUse[]]; Print[Share[]; MemoryInUse[]]; Jens > No idea? Any comment? > > Istvan > === Subject: Bad IL Format (.Net/Link) Hey everyone...I am having an intermittent problem with .Net/Link, and was wondering if any of you have any ideas. One in a while when I try to compute a string, I get this error: System.Exception: System.BadImageFormatException: Bad IL format. at Wolfram.NETLink.Internal.NativeLink.getDefaultLaunchString() at Wolfram.NETLink.Internal.NativeLink..ctor(String cmdLine) at Wolfram.NETLink.MathKernel.Connect() at Wolfram.NETLink.MathKernel.Compute() at Wolfram.NETLink.MathKernel.Compute(String input) It happens once in a blue moon, but I don't seem to be able to recover from the error and have to completely restart my application to get it working once again (simply closing out the MathKernel and creating a new one doesn't seem to do it...the new MathKernel will throw the same error). Does anyone have an idea of what might be causing this exception and/or what I can do to avoid it? === Subject: Re: Future for Mathematica on Solaris > I was interested in purchasing a copy of Mathematica for Solaris, but have seen various things on the net suggesting the Solaris (and to a > lesser extent linux) versions are more buggy than the Windows version. Looking on the Wolfram web site where one can request a trial http://www.wolfram.com/products/mathematica/experience/request.cgi I find one can't request a trail on Solaris from the web site. So I contacted Wolfram Research directly by email and asked about a > 14-day save-disabled trail. I received a reply in a couple of days, > telling me no trial version of Mathematica exists for Solaris. Given the Solaris version is more expensive than the windows one, > there are various reports of bugs on Solaris, and one can't even get a > trail version, it does beg the question whether Wolfram Research are > serious about the future of Mathematica on Solaris. Peter I'm sure that somebody has already (or will very soon) contacted you, \ Peter. But for anybody else who might have been following this, there's a bit more \ to say here. The person you spoke to correctly pointed out that there is no \ trial version for Solaris, but didn't realize there was another option which \ would have accomplished your goal. If you're talking to a representative of our \ salesteam, they can grant a temporary evaluation license. We're spreading the word internally to make sure that anybody who might be fielding questions such as this will be aware of the option in the future. aware of the oversight. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: A question on Grid and nested lists post. I make good progress in learning Mathematica and I really like it. However, here is again a problem where I am stuck. In my dialog, I would like to lay out a table of parameters in two columns. Each parameter consists of two or three elements, like param = {{text1, Slider[...], varValue1}, {text2, Slider[...], varValue2}, {text3, PopupMenu[..]}, ...} Since they are quite a lot parameters, I would like to put two parameters in one row. I tried Grid[Partition[param,2]], which work essentially fine, but there are these curly braces indicating a list around each parameter. I think I cannot flatten out on the second nesting level, because then I would loose the centering of the parameters. So what can I do here? I tried param = Partition[param,2]; param = Map[Grid[#]&, param, {2}]; (* Map[Pane[#... does not help either *) Grid[param] but that didn't help. If you could help me here, that would be very nice. Karsten. === Subject: 100,000 posts! Hello everyone, The Mathematica mailing list and newsgroup have been in existence for more than twenty years now. In January 2005, we past the 50,000 message mark. Now, in only a little more than four years, we have added another 50,000. This is very gratifying to me and I hope that this effort will continue to grow and help as many users as possible. A little personal history. I was honored to be a student and friend of Bryce DeWitt, who some of you know was one of the finest theoretical physicists of the last 100 years. One of the things he told me back in the 70's was \Make sure all your projects are useful, work that will still be valuable \ to others twenty years from now.\ I have tried to take this to heart in doing the moderation of this group for twenty years and running sunfreeware.com for fifteen years. It is obvious that Stephen, the folks at Wolfram Research, and many of all of you. Steve Christensen Moderator === Subject: Mathematica in Research and Education - Liege and Delft CANdiensten would like to invite you to the presentation \Mathematica in Research and Education\ by Dr. Tom Wickham Jones, director of Strategic Kernel Technology Wolfram Research, Inc. More information and On-Line registration: June 8th. Liege - Belgium http://www.can.nl/events/details.php?id=61 June 9th. Delft - The Netherlands http://www.can.nl/events/details.php?id=60 Also, feel free to invite your colleagues to come with you. Please let me know if you have any questions. Dick Verkerk Check out our complete event list at: http://www.can.nl/events/ _________________________ CANdiensten, Nieuwpoortkade 23-25, NL-1055 RX Amsterdam voice: +31 20 5608400 fax: +31 20 5608448 verkerk@can.nl _________________________ Your Partner in Finance, Mathematics and Statistics! === Subject: Re: print variable name and its value Opps...this will display better for arbitrary expressions: DumpVar[x_] := Print[HoldForm[x], \:\, x]; SetAttributes[DumpVar, {Listable, HoldAll, Flat}] x=4; y=5; DumpVar[{x^2+3,x^y}] === Subject: Re: print variable name and its value Something like this works: DumpVar[x_] := Print[ToString[HoldForm[x]], \:\, x]; SetAttributes[DumpVar, {Listable, HoldAll}] x:=1; y=2; DumpVar[x]; DumpVar[y]; DumpVar[{x,y}]; === I would like to add a PlotLegend to a time series plot like the one below. \Microsoft Corporation\], Tooltip[FinancialData[\SNE\, \2006\], \Sony Corporation\], Joined -> True] I tried using the PlotLegends package, but it doesn't appear to work (code below) Needs[\PlotLegends`\] Joined -> True, PlotLegend -> { \Microsoft Corporation\, \Sony Corporation\, \Akamai Technologies Inc\}] Is there a work around to this problem or something wrong with my code? I want to export the graph to for use in a latex document so Tooltip is not a useful option. === Subject: Logscale Tick Function Hi group, I am somewhat unsatisfied with the default Tick function for LogPlots, especially when it comes to preparing plots for publications, so I tried come up with a custom tick function. Maybe it is useful to somebody else. I would appreciate any comments on the function. logtic[min_, max_] := Module[{up, bot, steps, major, minor, maxlabels}, bot = Floor[Log10@min]; up = Ceiling[Log10@max]; maxlabels = 13; (* max labels visible per axis *) If[up - bot > 10, steps = Ceiling[(up - bot)/maxlabels], steps = 1]; major = Table[{10^(i) // N, If[i =!= 0, DisplayForm[SuperscriptBox[10, i]], 1], {0.00625`, 0.`}, {GrayLevel[0.`], AbsoluteThickness[0.25`]}}, {i, bot, up, steps}]; Which[up - bot <= 10, minor = Flatten[Table[{d*10^(i), \\, {0.00375`, 0.`}}, {i, bot, up}, {d, 2, 9}] // N, 1], up - bot <= 20, minor = Join[Table[{10^(i) // N, \\, {0.00625`, 0.`}, {GrayLevel[0.`], AbsoluteThickness[0.25`]}}, {i, bot + 1, up, steps}], Flatten[Table[{d*10^(i), \\, {0.00375`, 0.`}}, {i, bot, up}, {d, 2, 9}] // N, 1]], True, minor = Flatten[Table[{d*10^(i), \\, {0.00375`, 0.`}}, {i, bot, up}, {d, 1, 1}] // N, 1]]; Flatten[Join[{minor}, {major}], 1]] (* Examples *) LogLogPlot[x, {x, 10^-3, 10^5}, Ticks -> tic] LogLogPlot[x, {x, 10^-3, 10^15}, Ticks -> tic] LogLogPlot[x, {x, 10^-3, 10^35}, Ticks -> tic] (* compare this with the automatic behavior, which is not very reasonable I think *) LogLogPlot[x, {x, 10^-3, 10^15}] Markus P.S. Maybe my glasses are not as good as they used to be, but it looks like Mathematica renders some of the subticks longer than the others. The EPS output looks fine though. Did anybody else notice this? === Subject: Re: How to resize elements in GraphicsGrid Hi Daniel, you should use a scalable fontsize. E.g.: FontSize -> Scaled[0.1] But this does not fix everything. GraphicsGrid does not listen to the option: ImageSize->Automatic. It should display all of the pictures without truncation. This looks to me like a bug, maybe you want to tell Wolfram. I fiddled around with FontSize and ImageSize and was able to produce images now that are ok after I take a screenshot and reduce them down with an image editor. As you say it's not ideal and looks like a bug in GraphicsGrid. We've actually got premium support or whatever they call it so I've raised a technical request - hopefully they will come back with something. Perhaps there is an obscure option I'm missing. David. === Subject: Re: Wolfram|Alpha Lookup Tool for Mathematica >>With the release of Wolfram|Alpha I have created a small tool that >>allows you to send a query to Wolfram|Alpha directly from >>Mathematica. >Unfortunately, this is clearly against the terms of use: >http://www.wolframalpha.com/termsofuse.html >In particular: \The Wolfram|Alpha service may be used only by a >human being using a conventional web browser to manually enter >queries one at a time.\ >I think that Mathematica is clearly not a conventional web browser. >Now, I don't mean to imply that this tool should not have been >written or that it is Wolfram Research's intention to forbid this >specific use. On the contrary, the ease of writing such a tool >using query strings would indicate otherwise. Hopefully, the >forthcoming API will include separate terms of use that clarify this >matter. Have you used David's tool? Entry of search terms in the tool cause your default web browser to launch and send a query to Wolfram|Alpha. And the tool only allows one search at a time to be done. The only thing David's tool does is create a convenient perspective of the Wolfram|Alpha server's the result is identical to a human entering a single query in a conventional web browser. Consequently, it is far from obvious this is against the terms of use. And since the query sent to the server is identical in both cases, there is no way to Wolfram to distinguish between the two cases. === Subject: Re: print variable name and its value SetAttributes[dumpVar, {HoldAll, Listable}] dumpVar[var_] := Print[ToString[Unevaluated[var]], \ = \, var]; myVar1 = 1; myVar2 = 2; dumpVar[myVar1]; myVar1 = 1 dumpVar[{myVar1, myVar2}]; myVar1 = 1 myVar2 = 2 Bob Hanlon how can I dump out a variable with its value? The following does not work: myVar1 = 1; myVar2 = 2; DumpVars[list_List] := MapThread[(Print[#1, \: \, #2]) &, {Map[ToString[#] &, Unevaluated[list]], list}]; DumpVar[var_] := Print[ToString[Unevaluated[var]], \:\, var]; DumpVars[{myVar1, myVar2}] DumpVar[myVar1] Any ideas? Karsten. === Subject: Re: print variable name and its value Karsten, Try SymbolName how can I dump out a variable with its value? The following does not > work: myVar1 = 1; > myVar2 = 2; > DumpVars[list_List] := > MapThread[(Print[#1, \: \, #2]) &, {Map[ToString[#] &, > Unevaluated[list]], list}]; DumpVar[var_] := Print[ToString[Unevaluated[var]], \:\, var]; DumpVars[{myVar1, myVar2}] > DumpVar[myVar1] Any ideas? Karsten. === Subject: Re: print variable name and its value how can I dump out a variable with its value? The following does not > work: myVar1 = 1; > myVar2 = 2; > DumpVars[list_List] := > MapThread[(Print[#1, \: \, #2]) &, {Map[ToString[#] &, > Unevaluated[list]], list}]; DumpVar[var_] := Print[ToString[Unevaluated[var]], \:\, var]; DumpVars[{myVar1, myVar2}] > DumpVar[myVar1] Any ideas? Karsten. See http://reference.wolfram.com/mathematica/ref/HoldAll.html === Subject: Re: print variable name and its value Hi Karsten, Mathematica tries to evaluate every expression if possible. By default, a function gets bits arguments only after they are evaluated. To prevent this, you must specify the attribute HoldAll or HoldFirst. Further inside the function you muast again take care that the expression is not evaluated. myVar1 = 1; myVar2 = 2; SetAttributes[DumpVars, HoldAll]; DumpVars[d_List] := Function[{x}, Print[HoldForm[x], \= \, x], HoldAll] /@ (Unevaluated@d); DumpVars[{myVar1, myVar2}] Daniel > > how can I dump out a variable with its value? The following does not > work: > > myVar1 = 1; > myVar2 = 2; > DumpVars[list_List] := > MapThread[(Print[#1, \: \, #2]) &, {Map[ToString[#] &, > Unevaluated[list]], list}]; > > DumpVar[var_] := Print[ToString[Unevaluated[var]], \:\, var]; > > > DumpVars[{myVar1, myVar2}] > DumpVar[myVar1] > > Any ideas? > > Karsten. > === Subject: Re: print variable name and its value > > how can I dump out a variable with its value? The following does not > work: > > myVar1 = 1; > myVar2 = 2; > DumpVars[list_List] := > MapThread[(Print[#1, \: \, #2]) &, {Map[ToString[#] &, > Unevaluated[list]], list}]; > > DumpVar[var_] := Print[ToString[Unevaluated[var]], \:\, var]; > > > DumpVars[{myVar1, myVar2}] > DumpVar[myVar1] > > Any ideas? Use attributes. To get ahold of the unevaluated forms within the function definition you _need_ HoldFirst (or HoldAll). Listable just makes the code simpler and probably can motivate you to learn more about how attributes can make your life easier :-) The following should do what you want: ClearAll[DumpVar] SetAttributes[DumpVar, {HoldFirst, Listable}] DumpVar[s_Symbol] := (Print[HoldForm[s], \: \, s]); attribute Listable: DumpVar[myVar1]; DumpVar[{myVar1, myVar2}]; hth, albert === Subject: Re: Wolfram|Alpha Lookup Tool for Mathematica This tool has been cleared directly with Wolfram Research. --David > With the release of Wolfram|Alpha I have created a small tool that > > allows you to send a query to Wolfram|Alpha directly from > > Mathematica. Unfortunately, this is clearly against the terms of \ use:http://www.wolfra= malpha.com/termsofuse.html In particular: > \The Wolfram|Alpha service may be used only by a human > being using a conventional web browser to manually enter > queries one at a time.\ I think that Mathematica is clearly not a conventional web browser. > Now, I don't mean to imply that this tool should not have been > written or that it is Wolfram Research's intention to forbid this > specific use. On the contrary, the ease of writing such a tool > using query strings would indicate otherwise. Hopefully, the > forthcoming API will include separate terms of use that clarify > this matter. Mark McClure === Subject: Re: Wolfram|Alpha Lookup Tool for Mathematica Yes, Wolfram|Alpha has an API which is described in the document linked from this page: http://www.wolframalpha.com/developers.html Best, David On May 20, 4:58 am, \gigabitbuc...@BrockEng.com\ > 1.) Presumably, at some point under some conditions, the (XML?) output > of Wolfram|Alpha will be made available to Import[]. Does anyone have > any comment, rumor, or progress to report? 2.) I'd like it if the Wolfram|Alpha toolbars included a button for > ScienceWorld. Must be just an oversight. AFAICT, W|A doesn't mine > ScienceWorld effectively. Maybe that'll evolve in a positive way. Or > maybe I'll learn that I'm wrong. Fred Klingener > > On Monday 19 MAY w/a was working well, i.e. no waiting time. > David's tool is a very useful addition to our Mathematica weaponry. > I also signal the Wolfram toolbar for your favourite browser is > > available in the w/a site. > > It has links to all major Wolfram sites and a query box. > > Nice touch WRI! === Subject: Re: Wolfram|Alpha Lookup Tool for Mathematica Getting access to the notebook (or PDF) version requires information contained within the web page and associated unique identifiers of that particular web page (you can see this by looking at the html source code of the page and examining the javascript functions and their arguments). If however, you take a peek at the W|A API documentation you will see that the API will include functionality for getting notebooks directly. But getting notebooks directly from a simple link will probably not work at \ this point (and may be a violation of the terms of service for W|A). David > Have you noted the little link \Download as Live Mathematica\ in the > Wolfram Alpha response? I have managed to get that working, and when > downloaded into Mathematica, a notebook will open and 3D graphics will be > live. But I > do not know how to bypass the HTML page and get the download of the > notebook directly into Mathematica from a Mathematica call, which of \ course > would be ideal for the Mathematica user. Ingolf Dahl -----Original Message----- === > Subject: Re: Wolfram|Alpha Lookup Tool for Mathematica 1.) Presumably, at some point under some conditions, the (XML?) output > of Wolfram|Alpha will be made available to Import[]. Does anyone have > any comment, rumor, or progress to report? 2.) I'd like it if the Wolfram|Alpha toolbars included a button for > ScienceWorld. Must be just an oversight. AFAICT, W|A doesn't mine > ScienceWorld effectively. Maybe that'll evolve in a positive way. Or > maybe I'll learn that I'm wrong. Fred Klingener > > > On Monday 19 MAY w/a was working well, i.e. no waiting time. > > David's tool is a very useful addition to our Mathematica weaponry. > > I also signal the Wolfram toolbar for your favourite browser is > > available in the w/a site. > > It has links to all major Wolfram sites and a query box. > > Nice touch WRI! > > > -- This message and any attachments, may contain confidential and/or legally privileged information. If you are not the intended recipient of the message by the original sender, please destroy it. Message and attachments copyright (c) 2009, all rights reserved. Any unauthorized dissemination, distribution or copying is strictly forbidden. === Subject: Re: Wolfram|Alpha Lookup Tool for Mathematica > > With the release of Wolfram|Alpha I have created a small tool that > > allows you to send a query to Wolfram|Alpha directly from > > Mathematica. > > Unfortunately, this is clearly against the terms of use: > http://www.wolframalpha.com/termsofuse.html > Wolfram|Alpha may or may not be one of the greatest computer tools to emerge in our time (to be quite honest, I'm frankly hoping it's not). But this \Terms of Us\ document, circa 3000 words long and containing I believe it's nine links leading to God knows how many additional words of similar legalese, has to be among the nuttiest, or looniest, documents appearing on the web in some time. And it's this general looniness, also exhibited in other recent Terms of Use on Wolfram websites, not to mention in other broader policies, that makes me express the unfriendly hope I did above. === Subject: Re: Wolfram|Alpha Lookup Tool for Mathematica Have you noted the little link \Download as Live Mathematica\ in the Wolfram Alpha response? I have managed to get that working, and when downloaded into Mathematica, a notebook will open and 3D graphics will be live. But I do not know how to bypass the HTML page and get the download of \ the notebook directly into Mathematica from a Mathematica call, which of course \ would be ideal for the Mathematica user. Ingolf Dahl -----Original Message----- === Subject: Re: Wolfram|Alpha Lookup Tool for Mathematica 1.) Presumably, at some point under some conditions, the (XML?) output of Wolfram|Alpha will be made available to Import[]. Does anyone have any comment, rumor, or progress to report? 2.) I'd like it if the Wolfram|Alpha toolbars included a button for ScienceWorld. Must be just an oversight. AFAICT, W|A doesn't mine ScienceWorld effectively. Maybe that'll evolve in a positive way. Or maybe I'll learn that I'm wrong. Fred Klingener > On Monday 19 MAY w/a was working well, i.e. no waiting time. David's tool is a very useful addition to our Mathematica weaponry. I also signal the Wolfram toolbar for your favourite browser is > available in the w/a site. > It has links to all major Wolfram sites and a query box. > Nice touch WRI! === Subject: Re: Wolfram|Alpha Lookup Tool for Mathematica On May 20, 4:58 am, \gigabitbuc...@BrockEng.com\ > 1.) Presumably, at some point under some conditions, the (XML?) output > of Wolfram|Alpha will be made available to Import[]. Does anyone have > any comment, rumor, or progress to report? I think that Wolfram|Alpha will definitely be linked tightly into \ Mathematica. I've watched a few of Stephen Wolfram's video introductions and he makes it clear that Mathematica will likely be the largest user of the forthcoming API. Mark McClure === Subject: Re: Are you wolfing tonight? Yes, for most things Wolfram Alpha is thin gruel. I wanted to get the increase in budgets of Hoover vs. Roosevelt and it didn't understand the question. I asked for U.S. Budget 1928 - 1932 and there was no data. I \ asked for U.S. Inflation History and all I got was thin gruel, which was also incorrect because W|A forgot to multiply by 100 to get percent. But when I looked up 'inflation' in Wikipedia I quickly obtained a graph of U.S. inflation and deflation from the 1600's to the present. What W|A is better at is scientific data. What it is best at is doing Mathematica calculations. So, essentially WRI is giving the super \ calculator aspects of Mathematica away for free. For me, this raises the question: Why doesn't WRI give away Mathematica PlayerPro for free, and make it easy to obtain and install? Then anyone could read a dynamic Mathematica notebook, just as anyone can read a PDF document with Acrobat Reader. Nothing would do more to promote sales of the full Mathematica and it would be a real service to science in promoting greatly improved scientific and technical communication. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > Are you wolfing tonight? > Not yet the title of a new pop song, but wolfing (or walphing) is the > new thing to do on the net. Not necessarily lonesome. Wolfram|Alpha went live in test mode at 8:48pm CST on Friday 15th May. > While its fictional \city\ cousin HAL comes from Urbana, W/A is > perhaps more \rural\ coming from Champaign :-) > It can't yet play chess and hasn't killed anybody yet, but it's > nevertheless a killer app. Yes, it is a killer app. It kills itself !! Just type into it \Ampere's law\ and watch what do you get. Or, if You do not want to bother yourself with such bagatelle, type in: \Map of lung cancer in Connecticut\ and see what is unfolding. J=E1nos P.S. Of course if I type the same in Google, I am getting something. === Subject: Re: Are you wolfing tonight? > Are you wolfing tonight? > Not yet the title of a new pop song, but wolfing (or walphing) is the > new thing to do on the net. Not necessarily lonesome. > > Wolfram|Alpha went live in test mode at 8:48pm CST on Friday 15th May. > While its fictional \city\ cousin HAL comes from Urbana, W/A is > perhaps more \rural\ coming from Champaign :-) > It can't yet play chess and hasn't killed anybody yet, but it's > nevertheless a killer app. > It is bringing lots of people in contact with Mathematica technology and \ this > might mean wider use of Mathematica in due time. > For us, Mathematica users, W/A integration in our notebooks means curated \ data > to the n-th power. > Take note of David Reiss W/A tool (mentioned in another 3d) and of the > W/A toolbar for your browser available on the W/A site. > > > I notice that it accepts some, but not all Mathematica syntax. For example, Integrate and D commands seem to be accepted, but something like FullForm[{a,b,c}] was not. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Are you wolfing tonight? I have the feeling you don't understand what Alpha is about. It's not a search engine. > Are you wolfing tonight? > > Not yet the title of a new pop song, but wolfing (or walphing) is the > > new thing to do on the net. Not necessarily lonesome. > Wolfram|Alpha went live in test mode at 8:48pm CST on Friday 15th May. > > While its fictional \city\ cousin HAL comes from Urbana, W/A is > > perhaps more \rural\ coming from Champaign :-) > > It can't yet play chess and hasn't killed anybody yet, but it's > > nevertheless a killer app. Yes, it is a killer app. It kills itself !! > > Just type into it \Ampere's law\ and watch what do you get. Or, if You do not want to bother yourself with such bagatelle, type > in: \Map of lung cancer in Connecticut\ and see what is unfolding. J=E1nos P.S. Of course if I type the same in Google, I am getting something. === Subject: Re: Are you wolfing tonight? > Are you wolfing tonight? > > Not yet the title of a new pop song, but wolfing (or walphing) is the > > new thing to do on the net. Not necessarily lonesome. > Wolfram|Alpha went live in test mode at 8:48pm CST on Friday 15th May. > > While its fictional \city\ cousin HAL comes from Urbana, W/A is > > perhaps more \rural\ coming from Champaign :-) > > It can't yet play chess and hasn't killed anybody yet, but it's > > nevertheless a killer app. Yes, it is a killer app. It kills itself !! > > Just type into it \Ampere's law\ and watch what do you get. Or, if You do not want to bother yourself with such bagatelle, type > in: \Map of lung cancer in Connecticut\ and see what is unfolding. J=E1nos P.S. Of course if I type the same in Google, I am getting something. Yes the semantic capabilities of W/A are not very impressive (yet?). For instance: it understands that \square root\ is a unique concept, but thinks that \Ampere's Law\ or \Law of Ampere\ are lists of 2 (minor) towns. Still if we stick to the strictly technical data and use reasonably simple input, we can get a lot of info. other words: it expands the data that is already available to Mathematica users and does not require you to follow a precise syntax in the input field. I imagine that the quality of the service will be a non-decreasing function of time. === Subject: Re: Are you wolfing tonight? I think that with any complex tool, you will find some silly things being generated. It comes with the territory. Of course one of the things that we all like to do (and I am being quite serious here) is to prod something new to see how we can break it. This is one of the ways that we, as scientists, try to understand how something works. and understand what they were by looking at all the smashed up stuff that comes flying out. So, perhaps we, as supporters of Mathematica and parties interested in seeing good things come from its wider infrastructure should both report the silly things that W|A can generate, but also help shepherd people towards how to interact with it. Naive expectations are that it will answer anything--which of course is not the case. In the subfields that it currently covers, it does give quite useful information. And it's parser in these fields--if treated with some reasonableness (i.e., ask it relatively simple calculational questions)--does work much of the time. It's best, I feel, to be a mixture of realistic and supportive. If it generates something that is *really* funny, then enjoy the laugh. But submit a useful bug report! This one of the ways we can help this child down the birth canal.... Just my (non flaming) two cents... http://www16.wolframalpha.com/input/?i=+two+cents --David > Are you wolfing tonight? > > Not yet the title of a new pop song, but wolfing (or walphing) is the > > new thing to do on the net. Not necessarily lonesome. > Wolfram|Alpha went live in test mode at 8:48pm CST on Friday 15th May. > > While its fictional \city\ cousin HAL comes from Urbana, W/A is > > perhaps more \rural\ coming from Champaign :-) > > It can't yet play chess and hasn't killed anybody yet, but it's > > nevertheless a killer app. Yes, it is a killer app. It kills itself !! > > Just type into it \Ampere's law\ and watch what do you get. Or, if You do not want to bother yourself with such bagatelle, type > in: \Map of lung cancer in Connecticut\ and see what is unfolding. J=E1nos P.S. Of course if I type the same in Google, I am getting something. === Subject: Re: Are you wolfing tonight? > Or, if You do not want to bother yourself with such bagatelle, type > in: \Map of lung cancer in Connecticut\ and see what is unfolding. what Connecticut has lung cancer ? I thought Virginia,Georgia, Tenessee Kentucky and North Carolina are the main tobacco producers -- is the US Smokeless Tobacco Company so bad and should it not cause oral cavity cancer ? Jens > >> Are you wolfing tonight? >> Not yet the title of a new pop song, but wolfing (or walphing) is the >> new thing to do on the net. Not necessarily lonesome. Wolfram|Alpha went live in test mode at 8:48pm CST on Friday 15th May. >> While its fictional \city\ cousin HAL comes from Urbana, W/A is >> perhaps more \rural\ coming from Champaign :-) >> It can't yet play chess and hasn't killed anybody yet, but it's >> nevertheless a killer app. Yes, it is a killer app. It kills itself !! > > Just type into it \Ampere's law\ and watch what do you get. Or, if You do not want to bother yourself with such bagatelle, type > in: \Map of lung cancer in Connecticut\ and see what is unfolding. J=E1nos P.S. Of course if I type the same in Google, I am getting something. > > > === Subject: Import of NIST ANOVA data sets I am using Mathematica 7 and if I bring the data set into Excel 2007 then save it as an .xls file, Mathematica imports the data fine but the then the ANOVA fails (Error: \ANOVA::arg1:The 1st argument has unequal columns or rows.\). If I save the .xls file as a CSV file, import it into Mathematica and run the ANOVA, it runs successfully. Any ideas on why the xls import is breaking the ANOVA? Adrian. === Subject: Rotating a list of 3D point coordinates in one shot Hi: I have a list of 3D coordinates: list={{1., 0., 0.}, {0.987688, 0.156434, 0.}, {0.951057, 0.309017, 0.}, {0.891007, 0.45399, 0.}, {0.809017, 0.587785, 0.}, \ {0.707107, 0.707107, 0.}, {0.587785,0.809017, 0.}, {0.45399, 0.891007, 0.}, {0.309017, 0.951057, 0.}, \ {0.156434, 0.987688, 0.}, {0., 1., 0.}, {-0.156434, 0.987688, 0.}, {-0.309017, 0.951057, 0.}, {-0.45399, 0.891007, 0.}, {-0.587785, 0.809017, 0.}, {-0.707107, 0.707107, 0.}, {-0.809017, 0.587785, 0.}, {-0.891007, 0.45399, 0.}, {-0.951057, 0.309017, 0.}, {-0.987688, 0.156434, 0.}, {-1., 0., 0.}}. I'd like to rotate all the coordinates in the list in one shot, using \ something like this: Rotate[list, 180 Degree, {-1, -2, -1}]}} (*Axis angle rotation.*) I haven't gotten this to work though. I can rotate a single point at a time \ using a similiar method, but that is very time consuming. Question: Is there a way to rotate a list of numerous 3D coordinates such \ as in my example above, and if so, how do I code that using Mathematica \ 6.0.1? Bill === Subject: Animated Bubble Chart I am looking to create an animated bubble chart similar to what Hans Rosling did at TED a few years ago. It seems like Mathematica's Manipulate function is a perfect tool for doing this. Can anyone suggest some ideas on how to approach this? I am a newbie user and have gotten stuck. I am pulling in data using the CountryData function and one of the examples from the built-in documentation. Here is the code from the online documentation: countries = CountryData[\Europe\]; properties = {\PovertyFraction\, \GDPPerCapita\, \Population\}; data = {#1, Log@#2, #3} & @@@ Table[CountryData[c, p], {c, countries}, {p, properties}]; labeler[v_, {r_, c_}, ___] := {\Poverty\, Row[{Round[100 v[[1]]], \%\}]}, {\GDP Per Capita\, Row[{\$\, Round[Exp[v[[2]]]]}]}, {\Population\, Row[{NumberForm[v[[3]] 10^-6, {4, 2}], \ million\}]}}, Alignment -> Left], Tooltip] BubbleChart[data, ChartStyle -> 24, LabelingFunction -> labeler, FrameLabel -> {\Poverty Fraction\, \Log GDP Per Capita\}] The chart is using poverty on the X-Axis, GDP Per Capita on the Y, and Population for the bubble size. I would like to animate the bubbles for a 10-year period, 1990-2000. Any pointers would be appreciated. Jon PS: Here is a link to Hans' TED presentation: http://www.ted.com/index.php/talks/hans_rosling_shows_the_best_stats_you_ve_\ ever_seen.html === Subject: Re: Rotating a list of 3D point coordinates in one shot Look at RotationTransform list = { {1., 0., 0.}, {0.987688, 0.156434, 0.}, {0.951057, 0.309017, 0.}, {0.891007, 0.45399, 0.}, {0.809017, 0.587785, 0.}, {0.707107, 0.707107, 0.}, {0.587785, 0.809017, 0.}, {0.45399, 0.891007, 0.}, {0.309017, 0.951057, 0.}, {0.156434, 0.987688, 0.}, {0., 1., 0.}, {-0.156434, 0.987688, 0.}, {-0.309017, 0.951057, 0.}, {-0.45399, 0.891007, 0.}, {-0.587785, 0.809017, 0.}, {-0.707107, 0.707107, 0.}, {-0.809017, 0.587785, 0.}, {-0.891007, 0.45399, 0.}, {-0.951057, 0.309017, 0.}, {-0.987688, 0.156434, 0.}, {-1., 0., 0.}}; list2 = RotationTransform[180 Degree, {-1, -2, -1}][#] & /@ list; ListPlot3D[{list, list2}] Bob Hanlon Hi: I have a list of 3D coordinates: list={{1., 0., 0.}, {0.987688, 0.156434, 0.}, {0.951057, 0.309017, 0.}, {0.891007, 0.45399, 0.}, {0.809017, 0.587785, 0.}, \ {0.707107, 0.707107, 0.}, {0.587785,0.809017, 0.}, {0.45399, 0.891007, 0.}, {0.309017, 0.951057, 0.}, \ {0.156434, 0.987688, 0.}, {0., 1., 0.}, {-0.156434, 0.987688, 0.}, {-0.309017, 0.951057, 0.}, {-0.45399, 0.891007, 0.}, {-0.587785, 0.809017, 0.}, {-0.707107, 0.707107, 0.}, {-0.809017, 0.587785, 0.}, {-0.891007, 0.45399, 0.}, {-0.951057, 0.309017, 0.}, {-0.987688, 0.156434, 0.}, {-1., 0., 0.}}. I'd like to rotate all the coordinates in the list in one shot, using \ something like this: Rotate[list, 180 Degree, {-1, -2, -1}]}} (*Axis angle rotation.*) I haven't gotten this to work though. I can rotate a single point at a time \ using a similiar method, but that is very time consuming. Question: Is there a way to rotate a list of numerous 3D coordinates such \ as in my example above, and if so, how do I code that using Mathematica \ 6.0.1? Bill === PlotLegend works only for Plot, ListPlot and ListLinePlot. For all other plots use ShowLegend like here: << PlotLegends` ShowLegend[ \Microsoft Corporation\], Tooltip[FinancialData[\SNE\, \2006\], \Sony Corporation\], Joined -> True, PlotStyle -> {Red, Green, Blue}], {{{Graphics[{Red, Line[{{0, 0}, {1, 0}}]}], \MSFT\}, {Graphics[{Green, Line[{{0, 0}, {1, 0}}]}], LegendSize -> 0.5, LegendShadow -> None, LegendLabel -> \Company\, LegendPosition -> {0.8, 0.0}}] > I would like to add a PlotLegend to a time series plot like the one > below. > \Microsoft Corporation\], > Tooltip[FinancialData[\SNE\, \2006\], \Sony Corporation\], > Joined -> True] I tried using the PlotLegends package, but it doesn't appear to work > (code below) > Needs[\PlotLegends`\] > > Joined -> True, > PlotLegend -> { \Microsoft Corporation\, \Sony Corporation\, > \Akamai Technologies Inc\}] Is there a work around to this problem or something wrong with my > code? I want to export the graph to for use in a latex document so > Tooltip is not a useful option. === > I would like to add a PlotLegend to a time series plot like the one > below. > \Microsoft Corporation\], > Tooltip[FinancialData[\SNE\, \2006\], \Sony Corporation\], > Joined -> True] I tried using the PlotLegends package, but it doesn't appear to work > (code below) > Needs[\PlotLegends`\] > > Joined -> True, > PlotLegend -> { \Microsoft Corporation\, \Sony Corporation\, > \Akamai Technologies Inc\}] Is there a work around to this problem or something wrong with my > code? I want to export the graph to for use in a latex document so > Tooltip is not a useful option. > > > > The legend generation code is getting confused by the date specifications, and this is something we will look into fixing in a future version. As a workaround for now, you can convert the dates to AbsoluteTimes. Then the x coordinates in the data are just numbers as the PlotLegends code is expecting. Needs[\PlotLegends`\] data = {FinancialData[\MSFT\, \2006\], FinancialData[\SNE\, \ \2006\], Table[data[[i, All, 1]] = Map[AbsoluteTime, data[[i, All, 1]]], {i, 3}]; PlotLegend -> {\Microsoft Corporation\, \Sony Corporation\, \Akamai Technologies Inc\}] Darren Glosemeyer Wolfram Research === > I would like to add a PlotLegend to a time series plot like the one > below. > \Microsoft Corporation\], > Tooltip[FinancialData[\SNE\, \2006\], \Sony Corporation\], > Joined -> True] I tried using the PlotLegends package, but it doesn't appear to work > (code below) > Needs[\PlotLegends`\] > > Joined -> True, > PlotLegend -> { \Microsoft Corporation\, \Sony Corporation\, > \Akamai Technologies Inc\}] Is there a work around to this problem or something wrong with my > code? I want to export the graph to for use in a latex document so > Tooltip is not a useful option. > Needs[\PlotLegends`\] ShowLegend[ Joined -> True, PlotStyle -> {Red, Green, Blue}], {{{Graphics[{Red, Thick, Line[{{0, 0}, {1, 0}}]}], \Microsoft Corporation\}, {Graphics[{Green, Thick, Line[{{0, 0}, {1, 0}}]}], \Sony Corporation\}, {Graphics[{Blue, Thick, Line[{{0, 0}, {1, 0}}]}], \Akamai Technologies Inc\}}, LegendPosition -> {-1, -1.15}, LegendSize -> {1, 0.5}, LegendTextSpace -> 3} ] -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Instead of using a legend you could label the lines Tooltip[FinancialData[\MSFT\, \2006\], \Microsoft Corporation\], Tooltip[FinancialData[\SNE\, \2006\], \Sony Corporation\], Joined -> True, ImageSize -> 500, Epilog -> { Text[Style[\Microsoft Corp\, 12], {{2006, 7, 1}, 19}], Text[Style[\Sony Corp\, 12], {{2006, 5, 1}, 53}], Text[Style[\Akamai Technologies Inc\, 12], {{2006, 8, 5}, 33}, {-1, 0}]}] Bob Hanlon I would like to add a PlotLegend to a time series plot like the one below. \Microsoft Corporation\], Tooltip[FinancialData[\SNE\, \2006\], \Sony Corporation\], Joined -> True] I tried using the PlotLegends package, but it doesn't appear to work (code below) Needs[\PlotLegends`\] Joined -> True, PlotLegend -> { \Microsoft Corporation\, \Sony Corporation\, \Akamai Technologies Inc\}] Is there a work around to this problem or something wrong with my code? I want to export the graph to for use in a latex document so Tooltip is not a useful option. === Subject: Re: A question on Grid and nested lists param = {{\BlindText\, Slider[], varValue1}, {\BlindText\, Slider[], varValue2}, {\BlindText\, PopupMenu[x, {\a\, \b\, \c\}]}, {\BlindText\, PopupMenu[y, {\a\, \b\, \c\}]}} and Map[Row , Grid[Partition[param, 2]], {3}] does not help ? Jens > > post. I make good progress in learning Mathematica and I really like > it. However, here is again a problem where I am stuck. > > In my dialog, I would like to lay out a table of parameters in two > columns. Each parameter consists of two or three elements, like > > param = {{text1, Slider[...], varValue1}, {text2, Slider[...], > varValue2}, {text3, PopupMenu[..]}, ...} > > Since they are quite a lot parameters, I would like to put two > parameters in one row. I tried > > Grid[Partition[param,2]], > > which work essentially fine, but there are these curly braces > indicating a list around each parameter. I think I cannot flatten out > on the second nesting level, because then I would loose the centering > of the parameters. So what can I do here? I tried > > param = Partition[param,2]; > param = Map[Grid[#]&, param, {2}]; (* Map[Pane[#... does not help > either *) > Grid[param] > > but that didn't help. > > If you could help me here, that would be very nice. > > Karsten. > > > > > === Subject: Re: A question on Grid and nested lists > > post. I make good progress in learning Mathematica and I really like > it. However, here is again a problem where I am stuck. > > In my dialog, I would like to lay out a table of parameters in two > columns. Each parameter consists of two or three elements, like > > param = {{text1, Slider[...], varValue1}, {text2, Slider[...], > varValue2}, {text3, PopupMenu[..]}, ...} > > Since they are quite a lot parameters, I would like to put two > parameters in one row. I tried > > Grid[Partition[param,2]], > > which work essentially fine, but there are these curly braces > indicating a list around each parameter. I think I cannot flatten out > on the second nesting level, because then I would loose the centering > of the parameters. So what can I do here? I tried > > param = Partition[param,2]; > param = Map[Grid[#]&, param, {2}]; (* Map[Pane[#... does not help > either *) > Grid[param] > It really depends on how you want to format and align the contents of each sublist. I guess that this should do what you want, it will just arrange each sublist as a Row: Grid[Partition[Row /@ param, 2]] hth, albert === Subject: Re: Trouble with FullSimplify Anyone who uses Simplify or FullSimplify with approximate numbers =9A > fully deserves the consequences. Andrzej Kozlowski Khm... In version 5.2 this bug was absent... \Deserves the consequences\?! We are punished? === Subject: Re: 100,000 posts! benefits of his work that may not be obvious to a lot of people. Steve has provided a unique area where Wolfram staffers and Mathematica users can \ commune. This not only pushes more information out of the company and into the hands \ of users, it also directly impacts the development directions the company and \ its developers choose to take Mathematica in. I've talked to several people from Wolfram who post here. Most have very little time. They read this forum and post to it in their free time, not as \ a requirement (or even recommendation) of their job description. Without an environment which promotes the kind of civil and almost uniquely Mathematica-focused discourse that goes on here, most would have found \ better uses for their time. Here, people with questions can feel safe to ask them without being harassed \ or insulted by so-called experts. Experts (both in and outside of Wolfram) \ can feel safe to answer questions without the need to defend themselves from \ the typical partisanship, brinksmanship, and general childishness which results \ in something like Godwin's Law being accepted as an inevitable part of \ Internet discourse. Occasionally, people have expressed concern that moderation has stifled conversation. On the contrary, I claim; it enables conversations \ which would never, ever happen in the presence of your typical Internet rabble-rousers. Speaking as a developer, I have two primary ways to interact directly with users. One is the annual Wolfram conference, which only lets me talk with a very narrow slice of users and for only four days a year. The other is \ this forum. I've learned a lot here about how people use Mathematica, and that knowledge feeds back into the product. Wolfram has a fine crew of \ technical support and sales people who are on the front line with customers, but \ things inevitably get muffled by the time they reach developers...just as in the child's game of Telephone. Here, we hear you loud and clear. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > Hello everyone, The Mathematica mailing list and newsgroup have been in existence for > more than twenty years now. In January 2005, we past the 50,000 message > mark. Now, in only a little more than four years, we have added another > 50,000. This is very gratifying to me and I hope that this effort will > continue to grow and help as many users as possible. A little personal history. I was honored to be a student and friend > of Bryce DeWitt, who some of you know was one of the finest theoretical > physicists of the last 100 years. One of the things he told me back > in the 70's was \Make sure all your projects are useful, work that will still be \ valuable > to others twenty years from now.\ I have tried to take this to heart in doing the moderation of this group > for twenty years and running sunfreeware.com for fifteen years. It is obvious that Stephen, the folks at Wolfram Research, and many of > all of you. > Steve Christensen > Moderator === Subject: Re: NIntegrate & Integrate >Easy question for Mathematica. Evaluate definite integral: 2*Cos[x] >from 8.76 to 4.56. >I have evaluated it three different ways: Integrate, NIntegrate and >Integral sign from basic math input palette. >Here is the code(without Integral sign from basic math input >palette): >Clear[x] >{a, b} = {8.76, 4.56}; >NIntegrate[2*Cos[x], {x, a, b}] >Clear[x] >Integrate[2*Cos[x], {x, a, b}] >My output is: >3.21059(NIntegrate) >-3.21059(Integrate) >The right answer is -3.21059. >Why does NIntegrate gave me wrong answer? I cannot reproduce your results above. I get the correct value by simply pasting your code up to the line for NIntegrate into a fresh session. That is: In[1]:= {a, b} = {8.76, 4.56}; NIntegrate[2*Cos[x], {x, a, b}] Out[2]= -3.21059 In[3]:= $Version Out[3]= 7.0 for Mac OS X x86 (64-bit) (February 19, 2009) === Subject: Re: ColorFunction on a linux system (xorg) loses graphics I had the same problem (running on Archlinux with Intel graphics). http://ubuntuforums.org/archive/index.php/t-1136142.html the trick that helped me is to add Option \AccelMethod\ \uxa\ into the Device section of your /etc/X11/xorg.conf. Now I cen see the output of Plot3D and also output of Curtis's example (which I did not get prior the edit of xorg.conf). On the other hand, the rotation of 3D graphic in Mathematica works strange now - but this does not trouble me much. To conclude, it seems to me like problem with new x.org server (guys in the discussion above have ATI graphic cards, so I guess it is not a driver problem...). Looks like we have to wait for new version of Mathematica... > again, as I thought that issue had been fixed in the later Mathematica \ bui= lds (used to use it all the time). In any case, it doesn't seem to work \ for= me (3D plots still disappear except upon rotation, and ColorFunctions \ stil= TI are having such problems that they no longer provide any new \ proprietary= drivers for their older cards -- it's causing headaches in the community, \ = obviously. > When I try the XLIB... export, Mathematica shows many \holes\ in t= he Plot3D graphs, and the rotations are much slower and jerkier than \ usual.= I guess I'll just live with the state of things as they are now, until \ Mat= hematica learns to work with the drivers, or the driver writers can agree \ o= n a unified front (ha!). > > Curtis O. > > > > > Hi Curtis, > > > on an Ubuntu system I use a script, which calls Mathematica with \ para= meters > > > which let me use the mouse-wheel and the NumLock-key. Additionally \ it= sets the > > > environment variable XLIB_SKIP_ARGB_VISUALS to 1, which removed \ probl= ems > > > similar to the one you describe. Maybe it is worth a try (the little \ = utility > > > \imwheel\ has to be installed): > > petsie@leierkasten:~$ cat run-math > > > #!/bin/sh > > # run-math.sh version 4 > > > # `-r' flag means don't use the \Configurator\ > > > # and pass wheel events to the root window > > > # > > > # Ensure a single instance of Mathematica with > > > # the option `-singleLaunch'. > > > # Allow the use of the NumLock key with the > > > # '-primaryModifierMask' and '-secondaryModifierMask' > > > # switches. > > MARGS=\-singleLaunch -primaryModifierMask Mod1Mask -secondaryModifi= erMask > > > Mod3Mask\ > > if `ps -C imwheel > /dev/null`; then > > > XLIB_SKIP_ARGB_VISUALS=1 Mathematica $1 $MARGS > > > else > > > imwheel -r > > > XLIB_SKIP_ARGB_VISUALS=1 Mathematica $1 $MARGS > > > imwheel -kq > > > fi > Oops... this works with the proprietary drivers for an ATI Mobility \ 347= 0 > > graphics card on a laptop, but not with the opensource radeon driver \ on= a > > desktop workstation with a HIS x1050 graphic card?? > > Must be a bug in the OSS-Radeon-driver. > > B.t.w.: compiz is installed on both computers. > > Peter -- > Curtis Osterhoudt > cfo@remove_this.lanl.and_this.gov > PGP Key ID: 0x4DCA2A10 === Subject: Re: no Condition in EventHandler? Hi Michael, My guess (I may be wrong here) is that the rule semantics in EventHandler \ is indeed just a convenient syntax (namely, that delayed rule is used only as \ a convenient container which has a nice representation/formatting and does \ not evaluate its second arg, but no rule substitution with this rule is happening, and thus no condition is checked ). There is only one \ \MouseDown\ event. But you may get the functionality you need in a different way - for example, like this (I changed printing to assignments to a variable displayed with Dynamic): Column[{Dynamic[x], EventHandler[\TEST\, {\MouseDown\ :> (\anything\ /. {_ /; CurrentValue[\AltKey\] :> ( x = 1), _ /; CurrentValue[\ControlKey\] :> (x = 2), _ /; CurrentValue[\ShiftKey\] :> (x = 3)})}]}, Frame -> All] Hope this helps. Leonid > EventHandler[ > \TEST\, > (\MouseDown\ :> Print[1]) /; CurrentValue[\AltKey\], > (\MouseDown\ :> Print[2]) /; CurrentValue[\ControlKey\], > (\MouseDown\ :> Print[3]) /; CurrentValue[\ShiftKey\], > (\MouseDown\ :> > Print[4, CurrentValue[\AltKey\], CurrentValue[\ControlKey\], > CurrentValue[\ShiftKey\]]) /; True, > \MouseDown\ :> > Print[5, CurrentValue[\AltKey\], CurrentValue[\ControlKey\], > CurrentValue[\ShiftKey\]] /; False > ] Does not do what I expect. (5 is always printed, and nothing else, no > matter what keys are down). I can only speculate that EventHandler doesn't evaluate its actions in > such a way that a Condition has a chance to take effect or not? > > === Subject: Apply function breaks Parallelize? I'm trying to evaluate matrix multiplication in parallel, but I'm running into a small snag. I have a large vector of large matrices, and I want them multiplied. However, I'm having difficulty getting it to parallelize, so I did a little experiment. This: Parallelize[Dot[{{a,c},{b,d}},{{e,f},{g,h}},{{i,j},{k,l}},{{m,n}, {o,p}}]] Evaluates without any problems. However, if I try: Parallelize[Dot@@{{{a,c},{b,d}},{{e,f},{g,h}},{{i,j},{k,l}},{{m,n}, {o,p}}}] I get this error: Parallelize::nopar1: Dot@@{{{a,c},{b,d}},{{e,f},{g,h}},{{i,j},{k,l}}, {{m,n},{o,p}}} cannot be parallelized; proceeding with sequential evaluation. >> Why would using the Apply[] function break Parallelize? If I type in just the Dot@@{} bit, I get the exact same thing I'm putting into the first one which works! === Subject: Re: MOVE/EXPORT FILES AT ONCE would it not be simplest just to do this within the operating system; for example in linux/mac - rsync -Pvaze ssh source destination 2009/5/23 Alain Mazure : > Hi How is it possible to move, at once, to e.g another directory , files > identified with e.g: FileNames[\*.dat\] I.e, what is the equivalent of the classic cp *.dat and better the > equivalent of cp *.* ? > > Alain Mazure Laboratoire d'Astrophysique de Marseille > P=F4le de l'=C9toile Site de Ch=E2teau-Gombert > 38, rue Fr=E9d=E9ric Joliot-Curie > 13388 Marseille cedex 13, France http://alain.mazure.free.fr/ Mails: > alain.mazure@oamp.fr > -- Peter Lindsay === Subject: Re: 100,000 posts! > Steve > > Without your efforts, history would've unfolded differently: many > collaborations emerged from correspondence on this forum, collaboration \ that > changed our lives in ways we cannot fathom. All due to you. > > And DeWitt, your professor, friend, and guide. > > We're all looking for the 200K mark and beyond. You'll be around for a \ very > long time. That reminds me, a talk I give next month is about work that happened through MathGroup. http://aca2009.etsmtl.ca/proposal-details.asp?id=335 The main person behind the method was a fellow from Colombia named Juergen Tischer, who was active in MathGroup around 1998-9. He was, in my opinion, quite adept at using Mathematica to do math. In point of fact, a fair amount of the more interesting computations I have encountered came about through MathGroup interactions. At least three problems I discussed in our 2006 Tech Conference came from MathGroup. http://library.wolfram.com/infocenter/Conferences/6530/ will be a long road. Best, Daniel === Subject: Re: 100,000 posts! Dr. Stephen Wolfram, Sir, Dr. Steven M. Christensen, Sir, dear contributors to this forum, I (*1950) owe to you my past career in the banking industry. You endowed me with the instruments and techniques to calculate results I only dreamt of before (1967 - 2002). Please continue. With all my reverence, MATTHIAS BODE Las Lomas de Aranjuez Calle Los Molles 4 B S 17.35775¡, W 066.14577¡ CEL: +591-70 71 56 64 TEL: +591-4-445 76 65 LVSABA@HOTMAIL.COM -------------------------------------------------- === Subject: Re: 100,000 posts! > > > Jens > >> Hello everyone, The Mathematica mailing list and newsgroup have been in existence for >> more >> than twenty years now. In January 2005, we past the 50,000 message >> mark. >> Now, in only a little more than four years, we have added another \ 50,000. >> This is very gratifying to me and I hope that this effort will continue >> to grow and help as many users as possible. A little personal history. I was honored to be a student and friend >> of Bryce DeWitt, who some of you know was one of the finest theoretical >> physicists of the last 100 years. One of the things he told me back >> in the 70's was \Make sure all your projects are useful, work that will still be \ valuable >> to >> others twenty years from now.\ I have tried to take this to heart in doing the moderation of this group >> for twenty years and running sunfreeware.com for fifteen years. It is obvious that Stephen, the folks at Wolfram Research, and many of >> all of you. >> Steve Christensen >> Moderator >> > > === Subject: Re: 100,000 posts! Jens > Hello everyone, > > The Mathematica mailing list and newsgroup have been in existence for \ more > than twenty years now. In January 2005, we past the 50,000 message \ mark. > Now, in only a little more than four years, we have added another 50,000. > This is very gratifying to me and I hope that this effort will continue > to grow and help as many users as possible. > > A little personal history. I was honored to be a student and friend > of Bryce DeWitt, who some of you know was one of the finest theoretical > physicists of the last 100 years. One of the things he told me back > in the 70's was > > \Make sure all your projects are useful, work that will still be valuable \ to > others twenty years from now.\ > > I have tried to take this to heart in doing the moderation of this group > for twenty years and running sunfreeware.com for fifteen years. > > It is obvious that Stephen, the folks at Wolfram Research, and many of > all of you. > > > Steve Christensen > Moderator > === Subject: Re: 100,000 posts! tool work. I knew Bryce when I was in grad school - it must have been great fun working with him. Kevin > Hello everyone, > > The Mathematica mailing list and newsgroup have been in existence for \ more > than twenty years now. In January 2005, we past the 50,000 message \ mark. > Now, in only a little more than four years, we have added another 50,000. > This is very gratifying to me and I hope that this effort will continue > to grow and help as many users as possible. > > A little personal history. I was honored to be a student and friend > of Bryce DeWitt, who some of you know was one of the finest theoretical > physicists of the last 100 years. One of the things he told me back > in the 70's was > > \Make sure all your projects are useful, work that will still be valuable \ to > others twenty years from now.\ > > I have tried to take this to heart in doing the moderation of this group > for twenty years and running sunfreeware.com for fifteen years. > > It is obvious that Stephen, the folks at Wolfram Research, and many of > all of you. > > > Steve Christensen > Moderator > === Subject: Copy error message from messages window to clipboard? is there a simple way to copy just the error message to the clipboard? If I mark the error message and right-click, then there is a Copy-As Menu. But for every format I try, I always get a very long string like MapThread::mptd: \\\!\\(\\* StyleBox[\\\\\\\\\\Object \\\\\\\\\\, \\\MT\\\]\\)\\!\\(\\* StyleBox[ \ RowBox [{\\\ReadExcelSheets\\\, \\\[\\\, RowBox[{DynamicBox[ToBoxes [FE`PelletMarket`ModelManager`Private`inputFile$$5, StandardForm], ImageSizeCache->{434., {2., 9.}}], \\\,\\\, RowBox[{\\\{\\\, \ RowBox[{\\\\\\\ \\\Akteure\\\\\\\\\\, \\\,\\\, \\\\\\\\\\Verbrauch\\\\\\\\\\, \ \\\,\\\, \\\\\\\\\\Produktion\\ \\\\\\\\, \\\,\\\, \\\\\\\\\\Lieferbeziehungen\\\\\\\\\\, \\\,\\\, \ \\\\\\\\\\Parameter\\\\ \\\\\\}], \\\}\\\}]}], \\\]\\\}], \\\MT\\\]\\)\\!\\(\\* \ StyleBox[\\\\\\\\\\ at position {2, \\\\\\\\\\, \\\MT\\\]\\)\\!\\(\\* StyleBox[\\\2\\\, \ \\\MT\\\]\\)\\!\\(\\* StyleBox[\\\\\\\\\\} in \\\\\\\\\\, \\\MT\\\]\\)\\!\\(\\* StyleBox[ \ RowBox [{\\\MapThread\\\, \\\[\\\, RowBox[{ RowBox[{ RowBox[{\\\(\\\, \ RowBox [{\\\#1\\\, \\\=\\\, RowBox[{\\\ToDataFunction\\\, \\\[\\\, \ RowBox[{\\\#2\\\, \\\,\\\, \\\\\\\\\\Id\\\\\\\\\\}], \\\]\\\}]}], \\\)\\\}], \ \\\&\\\}], \\\,\\\, RowBox [{\\\{\\\, RowBox[{ RowBox[{\\\{\\\, RowBox[{\\\AkteurData\\\, \ \\\,\\\, \\\VerbrauchData\\\, \\\,\\\, \\\ProduktionData\\\, \\\,\\\, \ \\\BeziehungData \\\, \\\,\\\, \\\ParameterData\\\}], \\\}\\\}], \\\,\\\, RowBox [{\\\ReadExcelSheets\\\, \\\[\\\, RowBox[{DynamicBox[ToBoxes [FE`PelletMarket`ModelManager`Private`inputFile$$5, StandardForm], ImageSizeCache->{434., {2., 9.}}], \\\,\\\, RowBox[{\\\{\\\, \ RowBox[{\\\\\\\ \\\Akteure\\\\\\\\\\, \\\,\\\, \\\\\\\\\\Verbrauch\\\\\\\\\\, \ \\\,\\\, \\\\\\\\\\Produktion\\ \\\\\\\\, \\\,\\\, \\\\\\\\\\Lieferbeziehungen\\\\\\\\\\, \\\,\\\, \ \\\\\\\\\\Parameter\\\\ \\\\\\}], \\\}\\\}]}], \\\]\\\}]}], \\\}\\\}]}], \\\]\\\}], \ \\\MT\\\]\\)\\!\\(\\* StyleBox[\\\\\\\\\\ has only \\\\\\\\\\, \\\MT\\\]\\)\\!\\(\\* \ StyleBox[\\\0\\\, \\\MT \\\]\\)\\!\\(\\* StyleBox[\\\\\\\\\\ of required \\\\\\\\\\, \ \\\MT\\\]\\)\\!\\(\\* StyleBox[\\\1\\\, \\\MT\\\]\\)\\!\\(\\* StyleBox[\\\\\\\\\, \ \\\MT\\\]\\) dimensions which is not readable. Any help appreciated, Karsten. === Subject: Re: Solving integral equations numerically The message NIntegrate::inumr is issued because Tlo does not have a numerical value. I'm trying to solve a set of two integral equations, which don't have an \ analytic solution, so I'm using NIntegrate and FindRoot nodes = 11 (*number of nodes*) > RCOM = 2.17 (* common resistance *) > RS0 = 0.1 (*off-sensor resistance for sensor*) > RS = 1.1 (*sensor resistance pre node*) > Ph = 6 (*hybrid power in W*) > tcool = -25 (*coolant temperature (degC) *) > ta = 1.2/2/0.0000862 (*activation temperature (K) *) > l = 63.56/1000(*length of thermal path*) > w = 128.05/1000(*width of thermal path*) > T0 = 273 + tcool + Ph*RCOM > T = 4/3*(Tlo - T0^2/ta)*(x^2/l^2 - 2*x/l) + Tlo (*parabolic temperature \ function in sensor*) > I1 = (RCOM + RS0)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T], {x, \ 0, l}] > I2 = (RS/l)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T]*x, {x, 0, \ l/2}] > FindRoot[{Tlo == T0 + I1, T0^2/ta == Tlo + I2}, {{Tlo, 270}, {qref, \ 300}}] but I get errors like \... has evaluated to non-numerical values for all \ sampling points in the region with boundaries {{0,0.06356}}...\ and FindRoot \ does not move. Any idea what I'm doing wrong? > === Subject: Re: Solving integral equations numerically for what do you need NIntegrate[] ? Your first integral Integrate[T^2*Exp[-ta/T], {x, 0, l}] -> (l*T^2)/E^(ta/T) and you second one Integrate[T^2*Exp[-ta/T]*x, {x, 0, l/2}] -> (l^2*T^2)/(8*E^(ta/T)) if I have overlooked something, usual a definition like I1[qref_?NumericQ] := (RCOM + RS0)*w*qref*Exp[ta/273]/273^2* NIntegrate[T^2*Exp[-ta/T], {x, 0, l}] I2[qref_?NumericQ] := (RS/l)*w*qref*Exp[ta/273]/273^2* NIntegrate[T^2*Exp[-ta/T]*x, {x, 0, l/2}] FindRoot[{Tlo == T0 + I1[qref], T0^2/ta == Tlo + I2[qref]}, {{Tlo, 270}, {qref, 300}}] should be sufficient. Jens > > I'm trying to solve a set of two integral equations, which don't have an \ analytic solution, so I'm using NIntegrate and FindRoot > > nodes = 11 (*number of nodes*) > RCOM = 2.17 (* common resistance *) > RS0 = 0.1 (*off-sensor resistance for sensor*) > RS = 1.1 (*sensor resistance pre node*) > Ph = 6 (*hybrid power in W*) > tcool = -25 (*coolant temperature (degC) *) > ta = 1.2/2/0.0000862 (*activation temperature (K) *) > l = 63.56/1000(*length of thermal path*) > w = 128.05/1000(*width of thermal path*) > T0 = 273 + tcool + Ph*RCOM > T = 4/3*(Tlo - T0^2/ta)*(x^2/l^2 - 2*x/l) + Tlo (*parabolic temperature \ function in sensor*) > I1 = (RCOM + RS0)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T], {x, \ 0, l}] > I2 = (RS/l)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T]*x, {x, 0, \ l/2}] > FindRoot[{Tlo == T0 + I1, T0^2/ta == Tlo + I2}, {{Tlo, 270}, {qref, \ 300}}] > > but I get errors like \... has evaluated to non-numerical values for all \ sampling points in the region with boundaries {{0,0.06356}}...\ and FindRoot \ does not move. Any idea what I'm doing wrong? > > === Subject: Re: Solving integral equations numerically Hi Georg, In the Nintegrate call you use T which is defined (among other things) by a variable Tlo without a numeric value. For NIntegrate to work all variables must have numeric values. You can circumvent this problem by writing I1 and I2 as function definitions with argumnts and := (SetDelayed, to prevent inmediate evaluation). If you require the arguments to be numeric FindRoot won't be trying to evaluate them symbolically at the start. This would work if the numbers involved were not so gargantuan. I suspect that the value of ta (the activation temperature) is wrong. It's almost 7000 K. That's more than the outer temperature of the sun. I cannot imagine any material you might be interested in having an activation temperature that is that high. I'm trying to solve a set of two integral equations, which don't have an \ = analytic solution, so I'm using NIntegrate and FindRoot nodes = 11 (*number of nodes*) > RCOM = 2.17 (* common resistance *) > RS0 = 0.1 (*off-sensor resistance for sensor*) > RS = 1.1 (*sensor resistance pre node*) > Ph = 6 (*hybrid power in W*) > tcool = -25 (*coolant temperature (degC) *) > ta = 1.2/2/0.0000862 (*activation temperature (K) *) > l = 63.56/1000(*length of thermal path*) > w = 128.05/1000(*width of thermal path*) > T0 = 273 + tcool + Ph*RCOM > T = 4/3*(Tlo - T0^2/ta)*(x^2/l^2 - 2*x/l) + Tlo (*parabolic temperature= function in sensor*) > I1 = (RCOM + RS0)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T], {= x, 0, l}] > I2 = (RS/l)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T]*x, {x, 0= , l/2}] > FindRoot[{Tlo == T0 + I1, T0^2/ta == Tlo + I2}, {{Tlo, 270}, {qre= f, 300}}] but I get errors like \... has evaluated to non-numerical values for all \ = sampling points in the region with boundaries {{0,0.06356}}...\ and \ FindRoo= t does not move. Any idea what I'm doing wrong? > === Subject: Re: Solving integral equations numerically In defining I1 or I2, NIntegrate needs T (hence Tlo) defined AND numeric. But Tlo is undefined, so T is undefined. Bobby I'm trying to solve a set of two integral equations, which don't have an \ > analytic solution, so I'm using NIntegrate and FindRoot nodes = 11 (*number of nodes*) > RCOM = 2.17 (* common resistance *) > RS0 = 0.1 (*off-sensor resistance for sensor*) > RS = 1.1 (*sensor resistance pre node*) > Ph = 6 (*hybrid power in W*) > tcool = -25 (*coolant temperature (degC) *) > ta = 1.2/2/0.0000862 (*activation temperature (K) *) > l = 63.56/1000(*length of thermal path*) > w = 128.05/1000(*width of thermal path*) > T0 = 273 + tcool + Ph*RCOM > T = 4/3*(Tlo - T0^2/ta)*(x^2/l^2 - 2*x/l) + Tlo (*parabolic temperature > function in sensor*) > I1 = (RCOM + RS0)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T], > {x, 0, l}] > I2 = (RS/l)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T]*x, {x, 0, \ > l/2}] > FindRoot[{Tlo == T0 + I1, T0^2/ta == Tlo + I2}, {{Tlo, 270}, {qref, > 300}}] but I get errors like \... has evaluated to non-numerical values for all \ > sampling points in the region with boundaries {{0,0.06356}}...\ and > FindRoot does not move. Any idea what I'm doing wrong? > > -- DrMajorBob@bigfoot.com === Subject: Re: Solving integral equations numerically To have a CHANCE of success, you need to define functions properly, so that FindRoot has something to work with. For instance: nodes = 11; (*number of nodes*) RCOM = 2.17 ;(*common resistance*) RS0 = 0.1 ;(*off-sensor resistance for sensor*) RS = 1.1 ;(*sensor resistance pre node*) Ph = 6 ;(*hybrid power in W*) tcool = -25; (*coolant temperature \\ (degC)*) ta = 1.2/2/0.0000862; (*activation temperature (K)*) l = 63.56/1000;(*length of thermal path*) w = 128.05/1000;(*width of thermal path*) T0 = 273 + tcool + Ph*RCOM; Clear[T] T[Tlo_] = 4/3*(Tlo - T0^2/ta)*(x^2/l^2 - 2*x/l) + Tlo ; Clear[I1, I2, nint] nint[Tlo_?NumericQ, upper_?NumericQ] := NIntegrate[T[Tlo]^2*Exp[-ta/T[Tlo]]*x, {x, 0, upper}] I1[qref_?NumericQ, Tlo_?NumericQ] := (RCOM + RS0)*w*qref* Exp[ta/273]/273^2*nint[Tlo, 1] I2[qref_?NumericQ, Tlo_?NumericQ] := (RS/l)*w*qref*Exp[ta/273]/273^2* nint[Tlo, 1/2] FindRoot[{Tlo == T0 + I1[qref, Tlo], T0^2/ta == Tlo + I2[qref, Tlo]}, {{Tlo, 270}, {qref, 300}}] Unfortunately, FindRoot still fails... because the functions \blow up\ to \ unreasonable values. You need a better starting point, better understanding of the functions, or something. Bobby I'm trying to solve a set of two integral equations, which don't have an \ > analytic solution, so I'm using NIntegrate and FindRoot nodes = 11 (*number of nodes*) > RCOM = 2.17 (* common resistance *) > RS0 = 0.1 (*off-sensor resistance for sensor*) > RS = 1.1 (*sensor resistance pre node*) > Ph = 6 (*hybrid power in W*) > tcool = -25 (*coolant temperature (degC) *) > ta = 1.2/2/0.0000862 (*activation temperature (K) *) > l = 63.56/1000(*length of thermal path*) > w = 128.05/1000(*width of thermal path*) > T0 = 273 + tcool + Ph*RCOM > T = 4/3*(Tlo - T0^2/ta)*(x^2/l^2 - 2*x/l) + Tlo (*parabolic temperature > function in sensor*) > I1 = (RCOM + RS0)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T], > {x, 0, l}] > I2 = (RS/l)*w*qref*Exp[ta/273]/273^2*NIntegrate[T^2*Exp[-ta/T]*x, {x, 0, \ > l/2}] > FindRoot[{Tlo == T0 + I1, T0^2/ta == Tlo + I2}, {{Tlo, 270}, {qref, > 300}}] but I get errors like \... has evaluated to non-numerical values for all \ > sampling points in the region with boundaries {{0,0.06356}}...\ and > FindRoot does not move. Any idea what I'm doing wrong? > > -- DrMajorBob@bigfoot.com === Subject: Re: 100,000 posts! 2009/5/21 Steven M. Christensen : > Hello everyone, The Mathematica mailing list and newsgroup have been in existence for \ more > than twenty years now. In January 2005, we past the 50,000 message \ mark. > Now, in only a little more than four years, we have added another 50,000. > This is very gratifying to me and I hope that this effort will continue > to grow and help as many users as possible. A little personal history. I was honored to be a student and friend > of Bryce DeWitt, who some of you know was one of the finest theoretical > physicists of the last 100 years. One of the things he told me back > in the 70's was \Make sure all your projects are useful, work that will still be valuable \ to > others twenty years from now.\ I have tried to take this to heart in doing the moderation of this group > for twenty years and running sunfreeware.com for fifteen years. It is obvious that Stephen, the folks at Wolfram Research, and many of > all of you. > Steve Christensen > Moderator > > -- Peter Lindsay === Subject: Re: 100,000 posts! Steven, Congratulations on an outstanding job. Ben Benedetto Bongiorno CPA CRE Cell 214-707-6546 Land 972-470-9138 Fax 972-470-9748 bongiob@sbcglobal.net This Email is covered by the Electronic Communications Privacy Act, 18 U.S.C. Sections 2510-2521 and is legally privileged. The information contained in this Email is intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distributions or copying of this communication is strictly prohibited. If you have received this communication in error, please notify -----Original Message----- === Subject: 100,000 posts! Hello everyone, The Mathematica mailing list and newsgroup have been in existence for more than twenty years now. In January 2005, we past the 50,000 message mark. Now, in only a little more than four years, we have added another 50,000. This is very gratifying to me and I hope that this effort will continue to grow and help as many users as possible. A little personal history. I was honored to be a student and friend of Bryce DeWitt, who some of you know was one of the finest theoretical physicists of the last 100 years. One of the things he told me back in the 70's was \Make sure all your projects are useful, work that will still be valuable \ to others twenty years from now.\ I have tried to take this to heart in doing the moderation of this group for twenty years and running sunfreeware.com for fifteen years. It is obvious that Stephen, the folks at Wolfram Research, and many of all of you. Steve Christensen Moderator === Subject: Re: 100,000 posts! Steven, I have benefitted greatly for several years now from being a daily user and sometime contributor to MathGroup. I collect and compare the various solutions to posts on a daily basis. I have found that in doing so I get an education in the use and capability of Mathematica that is invaluable. MathGroup has also generated a number of opportunities to interact with other members, to share ideas and collaborate. Best wishes for the next 100,000 posts. Syd Syd Geraghty B.Sc, M.Sc. sydgeraghty@mac.com Mathematica 7.0.1 for Mac OS X x86 (64 - bit) (18th February 2009) MacOS X V 10.5.6 > Hello everyone, The Mathematica mailing list and newsgroup have been in existence > for more > than twenty years now. In January 2005, we past the 50,000 message > mark. > Now, in only a little more than four years, we have added another > 50,000. > This is very gratifying to me and I hope that this effort will > continue > to grow and help as many users as possible. A little personal history. I was honored to be a student and friend > of Bryce DeWitt, who some of you know was one of the finest > theoretical > physicists of the last 100 years. One of the things he told me back > in the 70's was \Make sure all your projects are useful, work that will still be > valuable to > others twenty years from now.\ I have tried to take this to heart in doing the moderation of this > group > for twenty years and running sunfreeware.com for fifteen years. It is obvious that Stephen, the folks at Wolfram Research, and many of > all of you. > Steve Christensen > Moderator > === Subject: Re: 100,000 posts! Muy most sincere congratulations Steve _________________________________________ This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy = it. As its integrity cannot be secured on the Internet, E. Mart=EDn-Serrano liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted. = confidencial destinada solamente a la(s) persona(s) mencionadas anteriormente pueden estar protegidos por secreto profesional. Si usted recibe este correo electronico por error, gracias por informar Mart=EDn-Serrano no se hace responsable por su contenido. Su contenido = no constituye ningun compromiso para el remitente, salvo ratificacion escrita por ambas = partes. Aunque se esfuerza al maximo por mantener su red libre de virus, el = emisor no puede garantizar nada al respecto y no sera responsable de = cualesquiera da=F1os que puedan resultar de una transmision de virus. -----Original Message----- === Subject: 100,000 posts! Hello everyone, The Mathematica mailing list and newsgroup have been in existence for = more than twenty years now. In January 2005, we past the 50,000 message = mark. Now, in only a little more than four years, we have added another = 50,000. This is very gratifying to me and I hope that this effort will continue to grow and help as many users as possible. A little personal history. I was honored to be a student and friend of Bryce DeWitt, who some of you know was one of the finest theoretical physicists of the last 100 years. One of the things he told me back in the 70's was \Make sure all your projects are useful, work that will still be = valuable to others twenty years from now.\ I have tried to take this to heart in doing the moderation of this group for twenty years and running sunfreeware.com for fifteen years. It is obvious that Stephen, the folks at Wolfram Research, and many of all of you. Steve Christensen Moderator === Subject: Re: 100,000 posts! Steve Without your efforts, history would've unfolded differently: many collaborations emerged from correspondence on this forum, collaboration \ that changed our lives in ways we cannot fathom. All due to you. And DeWitt, your professor, friend, and guide. We're all looking for the 200K mark and beyond. You'll be around for a \ very long time. Bruce Colletti -----Original Message----- === Subject: 100,000 posts! Hello everyone, The Mathematica mailing list and newsgroup have been in existence for more than twenty years now. In January 2005, we past the 50,000 message mark. Now, in only a little more than four years, we have added another 50,000. This is very gratifying to me and I hope that this effort will continue to grow and help as many users as possible. A little personal history. I was honored to be a student and friend of Bryce DeWitt, who some of you know was one of the finest theoretical physicists of the last 100 years. One of the things he told me back in the 70's was \Make sure all your projects are useful, work that will still be valuable \ to others twenty years from now.\ I have tried to take this to heart in doing the moderation of this group for twenty years and running sunfreeware.com for fifteen years. It is obvious that Stephen, the folks at Wolfram Research, and many of all of you. Steve Christensen Moderator === Subject: Re: Rotating a list of 3D point coordinates in one shot > Hi: I have a list of 3D coordinates: list={{1., 0., 0.}, {0.987688, 0.156434, 0.}, > {0.951057, 0.309017, 0.}, {0.891007, 0.45399, 0.}, {0.809017, 0.587785, \ 0.}, {0.707107, 0.707107, 0.}, > {0.587785,0.809017, 0.}, {0.45399, 0.891007, 0.}, {0.309017, 0.951057, 0. \ }, {0.156434, 0.987688, 0.}, > {0., 1., 0.}, {-0.156434, 0.987688, 0.}, > {-0.309017, 0.951057, 0.}, {-0.45399, 0.891007, 0.}, > {-0.587785, 0.809017, 0.}, {-0.707107, 0.707107, 0.}, > {-0.809017, 0.587785, 0.}, {-0.891007, 0.45399, 0.}, > {-0.951057, 0.309017, 0.}, {-0.987688, 0.156434, 0.}, > {-1., 0., 0.}}. I'd like to rotate all the coordinates in the list in one shot, using \ something like this: Rotate[list, 180 Degree, {-1, -2, -1}]}} (*Axis angle rotation.*) I haven't gotten this to work though. I can rotate a single point at a \ time using a similiar method, but > that is very time consuming. > > Question: Is there a way to rotate a list of numerous 3D coordinates such \ as in my example above, and if so, how do I code that using Mathematica \ 6.0.1? > Bill There is the function ListPointPlot3D[list] that would generate a 3D plot that you can easily click & drag to rotate, or you could then use Rotate, e.g. ll = ListPointPlot3D[list] Rotate[ll, 180 Degree] -Bob === Subject: Re: Rotating a list of 3D point coordinates in one shot > Hi: I have a list of 3D coordinates: list={{1., 0., 0.}, {0.987688, 0.156434, 0.}, > {0.951057, 0.309017, 0.}, {0.891007, 0.45399, 0.}, {0.809017, 0.587785, \ 0= .}, {0.707107, 0.707107, 0.}, > {0.587785,0.809017, 0.}, {0.45399, 0.891007, 0.}, {0.309017, 0.951057, \ 0.= }, {0.156434, 0.987688, 0.}, > {0., 1., 0.}, {-0.156434, 0.987688, 0.}, > {-0.309017, 0.951057, 0.}, {-0.45399, 0.891007, 0.}, > {-0.587785, 0.809017, 0.}, {-0.707107, 0.707107, 0.}, > {-0.809017, 0.587785, 0.}, {-0.891007, 0.45399, 0.}, > {-0.951057, 0.309017, 0.}, {-0.987688, 0.156434, 0.}, > {-1., 0., 0.}}. I'd like to rotate all the coordinates in the list in one shot, using \ som= ething like this: Rotate[list, 180 Degree, {-1, -2, -1}]}} (*Axis angle rotation.*) I haven't gotten this to work though. I can rotate a single point at a \ ti= me using a similiar method, but > that is very time consuming. > > Question: Is there a way to rotate a list of numerous 3D coordinates s= uch as in my example above, and if so, how do I code that using \ Mathematica= 6.0.1? > Bill Bill, You can rotate all at once by matrix multiplication using the rotation matrix. For example, if you wanted to rotate 45 degrees counterclockwise about the {0,0,1} axis, you would use: RotationMatrix[\\[Pi]/4, {0, 0, 1}].Transpose[list] // Transpose As long as the dimensions of list are nx3, n can be any positive integer. Nick. === Subject: Re: Rotating a list of 3D point coordinates in one shot Rotate[#, 180 Degree, {-1, -2, -1}] & /@ list or Unprotect[Rotate] Rotate[lst_?MatrixQ,a_,axis_]:=Rotate[#,a,axis] & /@ lst Protect[Rotate] Jens > Hi: > > I have a list of 3D coordinates: > > list={{1., 0., 0.}, {0.987688, 0.156434, 0.}, > {0.951057, 0.309017, 0.}, {0.891007, 0.45399, 0.}, {0.809017, 0.587785, \ 0.}, {0.707107, 0.707107, 0.}, > {0.587785,0.809017, 0.}, {0.45399, 0.891007, 0.}, {0.309017, 0.951057, \ 0.}, {0.156434, 0.987688, 0.}, > {0., 1., 0.}, {-0.156434, 0.987688, 0.}, > {-0.309017, 0.951057, 0.}, {-0.45399, 0.891007, 0.}, > {-0.587785, 0.809017, 0.}, {-0.707107, 0.707107, 0.}, > {-0.809017, 0.587785, 0.}, {-0.891007, 0.45399, 0.}, > {-0.951057, 0.309017, 0.}, {-0.987688, 0.156434, 0.}, > {-1., 0., 0.}}. > > I'd like to rotate all the coordinates in the list in one shot, using \ something like this: > > Rotate[list, 180 Degree, {-1, -2, -1}]}} (*Axis angle rotation.*) > > I haven't gotten this to work though. I can rotate a single point at a \ time using a similiar method, but > that is very time consuming. > > Question: Is there a way to rotate a list of numerous 3D coordinates such \ as in my example above, and if so, how do I code that using Mathematica \ 6.0.1? > > > > Bill > === Subject: Re: Rotating a list of 3D point coordinates in one shot Hi Bill, Rotate is for 2D rotations of graphics and other Mathematica expressions. RotationMatrix[180 Degree, {-1, -2, -1}] .# & /@ list will do the trick. It's an example of functional programming in which a function which takes one argument (# defines the slot for the argument and & indicates that this is a 'pure' function). The function is mapped on every member of the list (/@ is a shortcut and infix notation for Map). If you find it more readable you could write it as Map[ Function[{vec}, RotationMatrix[180 Degree, {-1, -2, -1}] .vec ], list ] which is fully equivalent. > Hi: I have a list of 3D coordinates: list={{1., 0., 0.}, {0.987688, 0.156434, 0.}, > {0.951057, 0.309017, 0.}, {0.891007, 0.45399, 0.}, {0.809017, 0.587785, \ 0= .}, {0.707107, 0.707107, 0.}, > {0.587785,0.809017, 0.}, {0.45399, 0.891007, 0.}, {0.309017, 0.951057, \ 0.= }, {0.156434, 0.987688, 0.}, > {0., 1., 0.}, {-0.156434, 0.987688, 0.}, > {-0.309017, 0.951057, 0.}, {-0.45399, 0.891007, 0.}, > {-0.587785, 0.809017, 0.}, {-0.707107, 0.707107, 0.}, > {-0.809017, 0.587785, 0.}, {-0.891007, 0.45399, 0.}, > {-0.951057, 0.309017, 0.}, {-0.987688, 0.156434, 0.}, > {-1., 0., 0.}}. I'd like to rotate all the coordinates in the list in one shot, using \ som= ething like this: Rotate[list, 180 Degree, {-1, -2, -1}]}} (*Axis angle rotation.*) I haven't gotten this to work though. I can rotate a single point at a \ ti= me using a similiar method, but > that is very time consuming. > > Question: Is there a way to rotate a list of numerous 3D coordinates s= uch as in my example above, and if so, how do I code that using \ Mathematica= 6.0.1? > Bill === Subject: Re: Rotating a list of 3D point coordinates in one shot Use a rotation matrix and linear algebra: w = Normalize@{-1, -1, -1} l1 = RotationMatrix[180 \\[Degree], w].# & /@ list l2 = list.RotationMatrix[180 \\[Degree], w] l1 == l2 Graphics3D[{ Point[list], Red, Point[l2], Green, Line[{{0, 0, 0}, w}], Blue, Line /@ Transpose[{list, l2}] }] Januk > Hi: I have a list of 3D coordinates: list={{1., 0., 0.}, {0.987688, 0.156434, 0.}, > {0.951057, 0.309017, 0.}, {0.891007, 0.45399, 0.}, {0.809017, 0.587785, \ 0= .}, {0.707107, 0.707107, 0.}, > {0.587785,0.809017, 0.}, {0.45399, 0.891007, 0.}, {0.309017, 0.951057, \ 0.= }, {0.156434, 0.987688, 0.}, > {0., 1., 0.}, {-0.156434, 0.987688, 0.}, > {-0.309017, 0.951057, 0.}, {-0.45399, 0.891007, 0.}, > {-0.587785, 0.809017, 0.}, {-0.707107, 0.707107, 0.}, > {-0.809017, 0.587785, 0.}, {-0.891007, 0.45399, 0.}, > {-0.951057, 0.309017, 0.}, {-0.987688, 0.156434, 0.}, > {-1., 0., 0.}}. I'd like to rotate all the coordinates in the list in one shot, using \ som= ething like this: Rotate[list, 180 Degree, {-1, -2, -1}]}} (*Axis angle rotation.*) I haven't gotten this to work though. I can rotate a single point at a \ ti= me using a similiar method, but > that is very time consuming. > > Question: Is there a way to rotate a list of numerous 3D coordinates s= uch as in my example above, and if so, how do I code that using \ Mathematica= 6.0.1? > Bill === Subject: Re: Rotating a list of 3D point coordinates in one shot You could use: RotationTransform[180 Degree, {-1, -2, -1}] /@ list Although RotationTransform does not have the attribute Listable, it still appears to behave as if it does. list // RotationTransform[180 Degree, {-1, -2, -1}] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hi: I have a list of 3D coordinates: list={{1., 0., 0.}, {0.987688, 0.156434, 0.}, {0.951057, 0.309017, 0.}, {0.891007, 0.45399, 0.}, {0.809017, 0.587785, \ 0.}, {0.707107, 0.707107, 0.}, {0.587785,0.809017, 0.}, {0.45399, 0.891007, 0.}, {0.309017, 0.951057, 0.}, {0.156434, 0.987688, 0.}, {0., 1., 0.}, {-0.156434, 0.987688, 0.}, {-0.309017, 0.951057, 0.}, {-0.45399, 0.891007, 0.}, {-0.587785, 0.809017, 0.}, {-0.707107, 0.707107, 0.}, {-0.809017, 0.587785, 0.}, {-0.891007, 0.45399, 0.}, {-0.951057, 0.309017, 0.}, {-0.987688, 0.156434, 0.}, {-1., 0., 0.}}. I'd like to rotate all the coordinates in the list in one shot, using something like this: Rotate[list, 180 Degree, {-1, -2, -1}]}} (*Axis angle rotation.*) I haven't gotten this to work though. I can rotate a single point at a time using a similiar method, but that is very time consuming. Question: Is there a way to rotate a list of numerous 3D coordinates such as in my example above, and if so, how do I code that using Mathematica 6.0.1? Bill === Subject: Re: Rotating a list of 3D point coordinates in one shot > Hi: I have a list of 3D coordinates: list={{1., 0., 0.}, {0.987688, 0.156434, 0.}, > {0.951057, 0.309017, 0.}, {0.891007, 0.45399, 0.}, {0.809017, 0.587785,= 0.}, {0.707107, 0.707107, 0.}, > {0.587785,0.809017, 0.}, {0.45399, 0.891007, 0.}, {0.309017, 0.951057, = 0.}, {0.156434, 0.987688, 0.}, > {0., 1., 0.}, {-0.156434, 0.987688, 0.}, > {-0.309017, 0.951057, 0.}, {-0.45399, 0.891007, 0.}, > {-0.587785, 0.809017, 0.}, {-0.707107, 0.707107, 0.}, > {-0.809017, 0.587785, 0.}, {-0.891007, 0.45399, 0.}, > {-0.951057, 0.309017, 0.}, {-0.987688, 0.156434, 0.}, > {-1., 0., 0.}}. > > I'd like to rotate all the coordinates in the list in one shot, using s= omething like this: > > Rotate[list, 180 Degree, {-1, -2, -1}]}} (*Axis angle rotation.*) > > I haven't gotten this to work though. I can rotate a single point at a = time using a similiar method, but > that is very time consuming. > > Question: Is there a way to rotate a list of numerous 3D coordinates s= uch as in my example above, and if so, how do I code that using Mathemati= ca 6.0.1? > Rotate is for graphics primitives, not for just coordinates, so any of the following will work: Graphics3D[Rotate[Line[list], 180 =B0, {-1, -2, -1}]] Graphics3D[Rotate[Point[list], 180 =B0, {-1, -2, -1}]] If you inspect the output with FullForm you will notice that the rotation is not resolved by the Kernel, but obviously only the rendering system will be doing the final rotate. I think this might be much more efficient. If you have things that consist of more than just one graphics primitive, you can rotate them all together by grouping them with a list, e.g.: lineandpoints = {Red, Point[list], Opacity[0.5], Black, Line[list]}; Graphics3D[Rotate[lineandpoints,180 Degree, {-1, -2, -1}]] hth, albert === Subject: Re: Rotating a list of 3D point coordinates in one shot > Hi: > > I have a list of 3D coordinates: > > list={{1., 0., 0.}, {0.987688, 0.156434, 0.}, > {0.951057, 0.309017, 0.}, {0.891007, 0.45399, 0.}, {0.809017, 0.587785, \ 0.}, {0.707107, 0.707107, 0.}, > {0.587785,0.809017, 0.}, {0.45399, 0.891007, 0.}, {0.309017, 0.951057, \ 0.}, {0.156434, 0.987