A118 === Subject: Re: Possible values for the Method option for Graphics?? > One of the very disappointing things about the documentation is that the > possible values for certain options are very difficult to find. For example, takeNIntegrate. The doc page mentions the Method option, > but it does not say what the possible values are. This is just incorrect. The possible values of the Method option are listed in NIntegrate's function page. That page has the following paragraphs: * Possible explicit settings for the Method option include: GlobalAdaptive global adaptive integration strategy LocalAdaptive local adaptive integration strategy DoubleExponential double exponential quadrature MonteCarlo Monte Carlo integration AdaptiveMonteCarlo adaptive Monte Carlo integration QuasiMonteCarlo quasi Monte Carlo integration AdaptiveQuasiMonteCarlo adaptive quasi Monte Carlo integration * With Method->{strategy,Method->rule} or Method- >{strategy,Method->{Subscript[rule, 1],Subscript[rule, 2],[Ellipsis]}} possible strategy methods include: GlobalAdaptive subdivide based on global error estimates LocalAdaptive subdivide based only on local error estimates * Methods used as rules include: CartesianRule multidimensional Cartesian product of rules ClenshawCurtisRule Clenshaw[Dash]Curtis rule GaussKronrodRule Gauss points with Kronrod extension LobattoKronrodRule Gauss[Dash]Lobatto points with Kronrod extension MultidimensionalRule multidimensional symmetric rule MultipanelRule combination of 1D rules NewtonCotesRule Newton[Dash]Cotes rule TrapezoidalRule uniform points in one dimension Anton Antonov, Wolfram Research, Inc. > Clicking the link > just takes us to a generic information page for Method which doesn't > even mentionNIntegrate. It turns out that the values *are* documented > at tutorial/NIntegrateOverview, but it is not at all obvious that one > should look there. noticed that Graphics has a Method option too. What are the possible > values and where are they documented? Szabolcs Horv=E1t === Subject: Re: Write documentation for 6.0 under Solaris Hello Karen, I have Mathematica on Solaris 10. But I do not understand what is your problem. Could you use an example? with friendly greetings, P_ter === Subject: Re: Mathlink: How do I pass arbitrary data from Mathematica to C? Hello Karen, did you already write your program? I am interested. Maybe more. As an example !? with friendly greetings, P_ter === Subject: Re: Rotation of 3D objects > Here is some code for those who have the Presentations package. > For reflection in a mirror: > Needs[Presentations`Master`] > Module[ > {(* object to reflect *) > gr = ParametricDraw3D[{t, u + t, u t/5}, {t, 0, 2}, {u, -1, 1}, > Mesh -> 5, > BoundaryStyle -> Black], > (* Mirror location and normal *) > p = {1, 1, 2}, > normal = {0, 0, 1}, > vector1, vector2}, > {vector1, vector2} = NullSpace[{normal}]; > Draw3DItems[ > {(* Original object *) > {Opacity[.7, HTML[DarkSeaGreen]], gr}, > (* Reflected object *) > {Opacity[.7, HTML[DodgerBlue]], gr} // > ReflectionTransformOp[normal, p], > (* Draw the mirror *) > {Opacity[0.3, HTML[SkyBlue]], > ParametricDraw3D[ > p + s vector1 + t vector2, {s, -3, 3}, {t, -3, 3}, > Mesh -> None]}}, > NeutralLighting[0, 0.6, .1], > NiceRotation, > ViewPoint -> {2, -2.4, .6}, > Boxed -> False, > ImageSize -> 300] > ] > Multiple copies of rotation about an axis: > Module[ > {(* object to reflect *) > gr = ParametricDraw3D[{t, u + t, u t/5}, {t, 0, 2}, {u, -1, 1}, > Mesh -> 5, > BoundaryStyle -> Black], > (* axis, location and number of copies *) > axis = {1, 1, 0}, > axislocation = {-1.5, -1.5, 2}, > ncopies = 4, > rotationangle}, > rotationangle = 2 [Pi]/ncopies; > Draw3DItems[ > {(* Rotations *) > {Opacity[.7, HTML[DarkSeaGreen]], > Table[gr // > RotationTransformOp[n rotationangle, axis, axislocation], {n= , = > 0, > ncopies - 1}]}, > (* Draw the axis *) > Red, Arrow3D[axislocation, axislocation + 5 axis, {.10}]}, > NeutralLighting[0, 0.6, .1], > NiceRotation, > ViewPoint -> {-1, -2.4, .6}, > Boxed -> False, > ImageSize -> 300] > ] > A Manipulate statement allowing the rotation about an axis by an adjusta= bl= > e > angle theta. > Manipulate[ > Module[ > {(* object to reflect *) > gr = ParametricDraw3D[{t, u + t, u t/5}, {t, 0, 2}, {u, -1, 1},= > Mesh -> 5, > BoundaryStyle -> Black], > (* axis direction and location *) > axis = {1, 1, 0}, > axislocation = {-1.5, -1.5, 2}}, > Draw3DItems[ > {(* Original object *) > {Opacity[.7, HTML[DarkSeaGreen]], gr}, > (* Rotated object *) > {Opacity[.7, HTML[DodgerBlue]], > gr // RotationTransformOp[[Theta], axis, axislocation]}, > (* Draw the axis *) > Red, Arrow3D[axislocation, axislocation + 5 axis, {.10}]}, > NeutralLighting[0, 0.6, .1], > NiceRotation, > PlotRange -> {{-1, 4}, {-1, 4}, {-1, 5}}, > ViewPoint -> {-1, -2.4, .6}, > Boxed -> False, > ImageSize -> 300] > ], > Style[Rotation about axis by angle [Theta], 16], > {[Theta], 0, 2 [Pi], Appearance -> Labeled}] > -- > David Park > djmp...@comcast.nethttp://home.comcast.net/~djmpark/ > By what command is it possible to create (without writing a code > separately ): > 1) Reflections of 3D objects about a plane? > 2) Multiple copies equally spaced by rotation around an axis throug= h > two given points? > E.g., > surf = ParametricPlot3D[{ t,u+t, u*t/5}, {t,0,2},{u,-1,1}]; > Rotate[surf,Axis->{ {-1,-1,-1},{1,1,1}} , Copies-> 4 ] ; and, > 3) A single rotation of given object through a given angle on an axis > through two defined points? > Narasimham- Hide quoted text - > - Show quoted text - Actually in engineering drawing software e.g., CATIA, Autocad Pro E > &c. such 3D operations are routinely implemented, clicking on a > standard GUI...the mathematical basis of which I was sure is well > within Mathematica's range of computational capabilities. ( and it > also appeared in 200 seconds. ).Mathematica gives the user an > advantage to see those steps, or look into the black box.Of course, > some minimum code lines have to be written. Narasimham is posted here but meant to follow Jen's msg). Is it possible to have a same frame of reference to Show another 3D object together with say 3 rotated copies of an object out of the slider ? Narasimham === Subject: What's DSolve's output when it cant find a solution ? Im using Mathematica 6 to look for solutions to a system of nonlinear ODE's. I don't expect a solution, but the only output Im getting is an exact reprint of my input. This usually means that the arguments to the function are incorrect, but Im fairly certain they're OK. Here is my input: In[11]:= Dsolve[{s''[t] + Cot[u[t]/2]*s'[t]*u'[t] == 0, u''[t] - Sin[u[t]]*s'[t]^2 == 0 }, {s[t], u[t]}, t] Out[11]:= Dsolve[{s''[t] + Cot[u[t]/2]*s'[t]*u'[t] == 0, u''[t] - Sin[u[t]]*s'[t]^2 == 0 }, {s[t], u[t]}, t] Is this what I should expect when DSolve can't find a solution ? Also, this is returned immediately without any Running ... . Dennis === Subject: Re: What's DSolve's output when it cant find a solution ? > Im using Mathematica 6 to look for solutions to a system of nonlinear ODE's. I > don't > expect a solution, but the only output Im getting is an exact reprint > of my input. > This usually means that the arguments to the function are incorrect, > but Im > fairly certain they're OK. > > Here is my input: > > In[11]:= Dsolve[{s''[t] + Cot[u[t]/2]*s'[t]*u'[t] == 0, u''[t] - > Sin[u[t]]*s'[t]^2 == 0 }, {s[t], u[t]}, t] > Out[11]:= Dsolve[{s''[t] + Cot[u[t]/2]*s'[t]*u'[t] == 0, u''[t] - > Sin[u[t]]*s'[t]^2 == 0 }, {s[t], u[t]}, t] > > Is this what I should expect when DSolve can't find a solution ? Also, > this is returned immediately > without any Running ... . Yes, when DSolve returns unevaluated, it cannot solve the equation. You misspelled DSolve as Dsolve above, but Mathematica still cannot solve this equation. === Subject: Re: What's DSolve's output when it cant find a solution ? you mean DSolve[] and *not* Dsolve and it returns unevaluated if it can't find a solution. Jens > Im using Mathematica 6 to look for solutions to a system of nonlinear ODE's. I > don't > expect a solution, but the only output Im getting is an exact reprint > of my input. > This usually means that the arguments to the function are incorrect, > but Im > fairly certain they're OK. > > Here is my input: > > In[11]:= Dsolve[{s''[t] + Cot[u[t]/2]*s'[t]*u'[t] == 0, u''[t] - > Sin[u[t]]*s'[t]^2 == 0 }, {s[t], u[t]}, t] > Out[11]:= Dsolve[{s''[t] + Cot[u[t]/2]*s'[t]*u'[t] == 0, u''[t] - > Sin[u[t]]*s'[t]^2 == 0 }, {s[t], u[t]}, t] > > Is this what I should expect when DSolve can't find a solution ? Also, > this is returned immediately > without any Running ... . > > Dennis > === Subject: Re: What's DSolve's output when it cant find a solution ? Hi Dennis, it happens to everybody, you are fooling yourself: The command is DSolve, not Dsolve. hope this helps, Daniel > Im using Mathematica 6 to look for solutions to a system of nonlinear ODE's. I > don't > expect a solution, but the only output Im getting is an exact reprint > of my input. > This usually means that the arguments to the function are incorrect, > but Im > fairly certain they're OK. > > Here is my input: > > In[11]:= Dsolve[{s''[t] + Cot[u[t]/2]*s'[t]*u'[t] == 0, u''[t] - > Sin[u[t]]*s'[t]^2 == 0 }, {s[t], u[t]}, t] > Out[11]:= Dsolve[{s''[t] + Cot[u[t]/2]*s'[t]*u'[t] == 0, u''[t] - > Sin[u[t]]*s'[t]^2 == 0 }, {s[t], u[t]}, t] > > Is this what I should expect when DSolve can't find a solution ? Also, > this is returned immediately > without any Running ... . > > Dennis > === Subject: Pythonika and dictionaries. I'm trying to squeeze the most use out of Pythonika as I can, and Python's dictionaries are a feature that would be particularly convenient on the Mathematica side. Is there a reasonable quick Python function that one can define for Pythonika that takes a dictionary out of the Python namespace and feeds it into Mathematica as a Module so it can be used the same way? Denham Quantitative Management LP 200 Clarendon Street, 25th Floor Boston, MA 02216 T: 617-587-5812 M: 617-909-7786 omri.schwarz@denhamcapital.com ---------------------------------------------------------------------------= -------------------------------------- NOTICE: This e-mail message is intended for the named recipients above. It= may contain confidential information. If you are not the intended= recipient, you are hereby notified that any dissemination, distribution,= or copying of this e-mail and any attachment(s) is strictly prohibited. = If you have received this e-mail in error, please immediately notify the= sender by replying to this e-mail and delete the message and any= attachment(s) from your system. NO REPRESENTATION OR WARRANTY IS MADE TO= ANY PERSON AS TO THE ACCURACY OR COMPLETENESS OF THE INFORMATION CONTAINED= HEREIN. Denham Capital Management(sm) is a trademark of Denham Capital Management= LP. ---------------------------------------------------------------------------= === Subject: solving a system of polynomial equations I'm pretty new to Mathematica. I want to numerically solve a system of N polynomial equations with N unknowns. I've heard that Mathematica was able to find all the real/complex solutions due to the fact that equations only involve polynomials. Is that correct? If yes, what is the command/method? thank you, Pluton === Subject: Re: solving a system of polynomial equations Hi Pluton, you may use Solve or the more powerfull Reduce. hope this helps, Daniel > > I'm pretty new to Mathematica. I want to numerically solve a system of > N polynomial equations > with N unknowns. I've heard that Mathematica was able to find all the > real/complex solutions due to > the fact that equations only involve polynomials. Is that correct? If > yes, what is the command/method? > > thank you, > > Pluton > === Subject: Re: Mixed Numerical Derivatives > How can I come up with the Hessian of a function, at a particular > point, which can only be evaluated numerically? If I had a symbolic > function, I could do something like In[123]:= > D[x^3 + z*y^-1 + z^(1/2), {{x, y, z}, 2}] /. {x -> 3, y -> 5, > z -> 12} Out[123]= {{18, 0, 0}, {0, 24/ > 125, -1/25}, {0, -1/25, -1/(96 Sqrt[3])}} The function I'm interested in, though, can only be calculated > numerically. Using ND, I can find the diagonal elements of the > Hessian: In[92]:= rules = Last[ > FindMaximum[{Total[logPr[vdt, ddt, var, #] & /@ testData], ddt > 0, > var > 0}, {{vdt, .9}, {ddt, 120}, {var, 90}}]] Out[92]= {vdt -> 0.95945, ddt -> 151.097, var -> 103.255} In[111]:= Needs[NumericalCalculus`] In[124]:= ND[ > Total[logPr[vdtp, ddt, var, #] & /@ testData] /. rules, {vdtp, 2}, > Evaluate[vdt /. rules]] Out[124]= -64.4011 But what about the off diagonal elements? If you'll need to evaluate the derivatives of the function many times, try setting up a FunctionInterpolation. You can use D on that. === Subject: Re: Mixed Numerical Derivatives [note: message sent to comp.soft-sys.math.mathematica] > > I have version 6 and can not find ND. It is in the NumericalCalculus package. > > Nevertheless, you could try an iterative approach. E.g.: > > ND[ ND[fun[x,y],{x,2},1] ,{y,2}, 1] This will appear to work for simple functions, but I would not recommend it because the inner ND is evaluated /before/ the outer ND, and produces a semi-symbolic result, i.e. something containing both 'y' and floating point numbers. This might not work at all for complicated functions that /must/ take numerical arguments, and even for simple functions ND cannot check for convergence, etc., so it is problematic. A similar solution is to define one's own double-derivative function which avoids evaluation of the inner ND explicitly, e.g. ND2[expr_, x_, y_, x0_, y0_] := Module[{fun, a}, fun[a_?NumericQ] := ND[expr /. y -> a, x, x0]; ND[fun[a], a, y0] ] ND2[Sin[x y], x, y, 1, 1] ... but I am still not comfortable with this approach ... > > hope this helps, Daniel > > > > >> How can I come up with the Hessian of a function, at a particular > >> point, which can only be evaluated numerically? If I had a symbolic > >> function, I could do something like > > >> In[123]:= > >> D[x^3 + z*y^-1 + z^(1/2), {{x, y, z}, 2}] /. {x -> 3, y -> 5, > >> z -> 12} > > >> Out[123]= {{18, 0, 0}, {0, 24/ > >> 125, -1/25}, {0, -1/25, -1/(96 Sqrt[3])}} > > >> The function I'm interested in, though, can only be calculated > >> numerically. Using ND, I can find the diagonal elements of the > >> Hessian: > > >> In[92]:= rules = Last[ > >> FindMaximum[{Total[logPr[vdt, ddt, var, #] & /@ testData], ddt > 0, > >> var > 0}, {{vdt, .9}, {ddt, 120}, {var, 90}}]] > > >> Out[92]= {vdt -> 0.95945, ddt -> 151.097, var -> 103.255} > > >> In[111]:= Needs[NumericalCalculus`] > > >> In[124]:= ND[ > >> Total[logPr[vdtp, ddt, var, #] & /@ testData] /. rules, {vdtp, 2}, > >> Evaluate[vdt /. rules]] > > >> Out[124]= -64.4011 > > >> But what about the off diagonal elements? === Subject: Re: Something very simple..... very simple.... Here I report back what I think are the easiest suggestions. 1. Apply[Sphere, sphlst, 1] 2. Complement[lsta,lsta[[lstb]]] These answers can hardly be improved for compactness, simplicity, and transparency. I admittedly avoid processes that include a lot of terse symbology such as &, #, @, /. etc., on the grounds that I'm an irregular user of Mathematica and sometimes have to look up their function. Their appearance gives no clue about what they do. But the named functions are usually intuitive and their use is clear. Steve Gray === Subject: Re: Mathematica notebooks the best method for technical > On 1 Apr, 09:20, Mariano Su=E1rez-Alvarez > Indeed. I would not be able to describe such an effort > with any other term apart from misguided. Very misguided. > Essentially > proprietary formats cannot possibly be considered as a > the simple fact that Mathematica, say, is absurdly expensive > for most of the world, to rather more complicated issues > (for example, one can never tell when the whimsical ires > of whatever be the superpower of the day, any day, may decide > to forbid selling, say, Mathematica to country X in order > to `fight Y' for whatever value X has at the time---terrorists, > peadophiles, and so on.), to so many other issues... > It simply cannot withstand any analysis. > -- m The only way I could see this happening is if Wolfram Research > released the front end under the GPL or similar. Then it might, but > even then it is far from clear it would and I personally doubt it > would. Since the semantics of .nb files are handled by the kernel, mostly, having the front end be even public domain does not solve anything. Indeed, assuming one can render any notebook just with front-end functionality, having a free-as-in-freedom frontend but not a free-as-in-freedom kernel does not leave you in any better position than having a PDF reader, which you already have. -- m === Subject: Re: Mathematica notebooks the best method And indeed there is no reason not to author documents in Mathematica and distribut them as both PDFs and Mathematica notebooks. Mathematica Player will then allow the reader to read them in their native format (and perhaps do some dynamic experiments with them if they are digitally signed so that their Manipulates are functional); anyone who chooses not to install Mathematica Player can make use of the PDF version (or an HTML version, or one of the other set of output possibilities...). The question of whether it should be a standard is different. Perhaps, generally proprietary formats should not be a standard. But the key question there is price point. Also the question is whether one is defining standard to be exclusive of any other possibilities. Price point should be low--though Microsoft office is not cheap and it is unfortunately considered a standard--or zero, and functionality should be high. There really is no sensible reason why, given the existence of Mathematica Player, Mathematica notebooks should not be acceptable as one of the key distribution formats for technical documents: there are just too many reasons involving the incredible breadth of what you can do with it to pass it up. Why limit publishing to static material? PDFs are considered a standard distribution format largely because of the free Acrobat reader. TeX is a standard because it is a wonderful old workhorse that was adopted into the technical publishing industry when electronic typesetting was in its infancy and using such technologies was forward looking, extendable, and free. Of course some aspects of a discussion such as this are admittedly religious... :-) And I admit that I use Mathematica for essentially everything. And I extend its use and scope whenever I see a need. These personal needs ultimately lead me to create http://scientificarts.com/worklife/ for just such purposes... Hope this helps, --David A WorkLife FrameWork E x t e n d i n g MATHEMATICA's Reach... Trial Version at: http://scientificarts.com/worklife/ > I agree with everything below but to tell the truth I can't see what > is supposed to be the point of this entire thread. If one wants to > write a research paper using Mathematica and submit it to a print or > on-line journal one needs only to convert it to pdf and it should then = > be acceptable in many cases it would be (assuming of course that the > contents are good enough). If one wants in addition to provide people > who are able to use Mathematica with live calculations one can put a > Mathematica notebook for download on a web page. I can't see why > anyone should wish for more or argue against this. The rest seems to > me a complete waste of time and effort and some of what I have read I > actually found quite funny (comical) though I assume it was meant to > be serious. A completely different issue is whether academic institutions should > provide their students with the opportunity to discover the (in my > opinion) very remarkable possibilities offered by the latest version > of Mathematica. That's all that my own response was concerned with. > This is a real issue while a discussion of publishing standards is a = > waste of time. I should like to repeat that I have yet to meet a student who would > complain about the lack of a printed manual and I think using that as > an argument against Mathematica is a perfect example of the sort of > academic attitude I referred to in my first response. Andrzej Kozlowski > djvu vs. pdf: no big deal. Tex vs. Mathematica: BIG deal! > With djvu and pdf, it's merely a matter of the final format in which = > the > document appears and is disseminated. > With (La)TeX and Mathematica, there's a crucial difference in the > entire > authoring process. Among other things: > (1) (La)TeX concentrates upon the logical structure of the document,= > whereas Mathematica from the start involves the actual appearance of = > the > document. > (2) Typing math markup is typically quicker in (La)TeX than in > Mathematica, as it avoids Control-key sequences (unless one is using = > an > editor where such sequences are used as shortcuts) or at least uses > shorter keystroke-only sequences. > (3) Mathematica allows live calculations in the document itself, > whereas TeX does not (except of the most primitive kind). > Exception: a > specialized TeX+CAS system. > (4) Mathematica creates graphics of all sorts directly in the > document, whereas with the exception of a limited number of native or > package add-on graphics types, graphics must be imported into a TeX > document from an external source (such as Mathematica)! > There are two other another differences: > (5) One can have an entire TeX document preparation system -- > editor, > TeX engine plus packages, viewer, and converter (dvi to ps or pdf, > e.g.) > -- for free. Needless to say, Mathematica is not free. > (6) The source code for TeX and many or most of the supporting > utilities is open source; this is certainly not the case for > Mathematica. >> ...I would like to point out that publishing standards are not >> set in stone. For several years I have witnessed PDF visibly loosing >> ground to djvu in the mathematical preprint area. I like with many >> other things I learned about it first form students, who quickly >> understood its technical superiority over PDF (most of all, much >> smaller file size). Now I see that a number of on-line mathematics >> journals are offering djvu as an alternative to pdf. > -- > Murray Eisenberg mur...@math.uma= ss.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: The FinancialData Function Hello. I work at Wolfram and have worked on FinancialData, and other curated data projects (CountryData e.g.). I might be able to address some of your concerns. We consider FinancialData - as it is now - experimental in the sense that it isn't really finished growing yet and it is going to get a lot more powerful, not in the sense that it is going to go away. We started off just making it easier for people to get public forms of data, things that are readily available in formats like Excel, into Mathematica and in standardized Mathematica expressions. Instead of our users each doing a bunch of intervening steps themselves to use this stuff, we'd do it right, once, for all of them. And add value in the form of a flexible Mathematica function that works with others in ways our users expect, etc. But we realize the types of data readily available that way, are only the first layer of what practioners want. In the future we are going to make even more available through FinancialData. To do that, we've made deals with data providers to get our users free access, within Mathematica (and subject to the usual terms of use issues over resale etc), to much more comprehensive data feeds - including options, futures, mutual funds, detailed fundamentals, economic time series, intraday tick by tick prices, etc. That should also address some concerns over possible third party changes and code breakage - our partners aren't going to change their services in ways that break our agreements with them. Implementing each of those extra features takes some work and therefore some time. Internally we have all this stuff already, in some form, but there is an intervening curation step - and some function design for qualifying arguments and the like - to get it to final forms we are satisfied with and think our users will expect. The bottom line is stay tuned, more FinancialData coming soon... I hope this helps. And I'd be happy to answer additional questions. === Subject: Re: The FinancialData Function To Harvey: On oil prices, that is one in the coming soon category, but I can give you a solution that will work today, outside of FinancialData proper. Soon there won't be a need for these sorts of lines, that is sort of the idea. But for now, you can use - Daily spot oil prices from the Department of Energy, back to 1986 dailyDOEOil = {#[[1, 1 ;; 3]], N[#[[2]]]} & /@ DeleteCases[ Import[http://tonto.eia.doe.gov/dnav/pet/xls/ PET_PRI_SPT_S1_D.xls, XLS][[2, 4 ;;, 1 ;; 2]], {, } | {_, }]; Monthly spot oil prices from the Fed, back to 1946 Import[http://research.stlouisfed.org/fred2/series/OILPRICE/ downloaddata/OILPRICE.csv]]; Both are in the same format as any other FinancialData time series, A prime reason we made FinancialData is to spare everyone else the need to figure out the fiddly details of such lines of code. As for getting lists of symbols that work in FinancialData today, you can use string patterns and wildcards in the first argument, and Lookup in the second argument. So e.g. just to see how many that is, you could ask for Length[FinancialData[*, Lookup]] - where the * is a wildcard that will match any string. The answer is 186,000 symbols and change. I won't try to guarantee that every one of them will give you meaningful data - some will return Missings, representing entities that merged recently or failed etc. For any subset of them, the symbol and second argument Name will tell you what it is. Clearly this sort of discovery can be improved, and is another area I'd call experimental. Briefly, there is good coverage of stocks, mutual funds, and indices in the existing data. Including many foreign exchanges. Newer versions should have more of the futures and economic time series you'd want for commodity-specific questions. Fine questions by the way. Jason Cawley === Subject: Re: setting elements of an array based on a condition >>2) Then I want to calculate the sum of the elements in each column >>of W. How can I do this? >Plus @@@ W >or >Total /@ W For a 2 x 2 (W) matrix, your code will output W[[1,1]]+W[[1,2]] and W[[2,1]]+W[[2,2]] I believe the requester is asking for B[[1,1]]+B[[2,1]] and B[[1,2]]+B[[2,2]] For that you would want to use Total[W] or Plus@@@Transpose[W] === Subject: Re: Colorfunction based upon flux direction Hi Patrick, I answered this question 5 days ago, but it never made it to the group. Here it is the answer again: in ListVectorFieldPlot3D the color function gets the magnitude of the vector as argument. Therefore, there is no direction info available. You must use a trick to do this, e.g. you could use a counter to access the original vectors: n=5; d=Table[r=rad{Sin[p1]Sin[p2],Sin[p1]Cos[p2],Cos[p1]};{r,r},{rad,0.01,1,1/n}, {p1,0,Pi,Pi/n},{p2,0,2 Pi,Pi/n}]; d=Flatten[d,2]; count=0; ListVectorFieldPlot3D[d,ColorFunction->Function[{x},Hue[r= d[[++count,2]];0.5+0.5 r.{1,0,0}/Sqrt[ r.r]]]] hope this helps, Daniel > > I'm quite new at using Mathematica and I am attempting to assign > colors to vector field data (3d magnetic flux) using the > ListVectorFieldPlot3D function. I would like to assign colors to the > vectors based upon the direction in which they point. Hue gives me a > color based upon vector magnitude - is there a simple way to color > vectors based upon direction? > > > Patrick Keith-Hynes > University of Virginia Physics > > === Subject: running a program Hi all, i want to ask you something very dummy. I want to run a benchmark in mathematica, and i have a nb file. How can i run my program(that is in the nb file) and get the results? I am using mathematica only one day, so if you can explain me what to do exactly? nick === Subject: Re: running a program 1) Double-click the notebook to open it up in Mathematica. 2) Use Menu, Evaluation, Evaluate Notebook. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > Hi all, i want to ask you something very dummy. I want to run a benchmark in mathematica, and i have a nb file. How can i run my program(that is in the nb file) and get the results? I am using mathematica only one day, so if you can explain me what to do > exactly? nick > === Subject: Mathematica Player Pro now available Mathematica Player Pro, the professional application delivery system for Mathematica, is now available. Player Pro extends Player's reach to include more import/export capabilities, dialog-box entry, complete dynamic capabilities (instead of just Demonstrations), and more. Technically, Player Pro contains almost all of Mathematica and differs only in that it is a pure runtime environment. That means that developers can now build virtually stand-alone Mathematica applications for the first time. Almost any notebook you create in Mathematica 6 can be deployed with Player Pro--there's no conversion required. All current individual Mathematica 6 Premier Service customers are eligible to receive three complimentary copies of Player Pro for distribution (eligible users will receive an email in the next few days with instructions on how to claim their copies). Five-pack and other volume discounts are also available. More information is available at: http://www.wolfram.com/e/6/playerpro P.S. Get the inside story on developing for Player Pro from Conrad Wolfram, Director of Strategic and International Development, on the Wolfram Blog (http://www.wolfram.com/e/6/playerproblog). === Subject: Re: setting elements of an array based on a condition Hello Claus, > I have one array, W, which for testing purposes has 25 rows and 50 columns. > There are two more things I want to accomplish with this: > 1) I want to set all elements of W which are smaller than zero to zero. > 2) Then I want to calculate the sum of the elements in each column of W. > How can I do this? The code below shows how I get to W. Claus X = RandomReal[{0, 1}, 50]; > Y = RandomReal[{0, 1}, 50]; BinWidth = 0.2; > Radius = 0.2; xyzVals2 = Table[ > {i/(1/BinWidth) + (BinWidth/2) > , j/(1/BinWidth) + (BinWidth/2) > } > , {i, 0, (1/BinWidth) - 1} > , {j, 0, (1/BinWidth) - 1}]; RasterPtsVals = Partition[Flatten[xyzVals2], 2] RasterX = RasterPtsVals[[All, 1]] > RasterY = RasterPtsVals[[All, 2]] XDiffSq = (RasterX - a /. a -> X)^2; > YDiffSq = (RasterY - b /. b -> Y)^2; > Dist = Sqrt[(XDiffSq + YDiffSq)]; W = 1 - (Dist/Radius) tmp = (W + Abs[W])/2; Plus @@@ Transpose[tmp] hth, Oliver Ruebenkoenig, === Subject: Re: setting elements of an array based on a condition > [...] > 2) Then I want to calculate the sum of the elements in each column of W. > How can I do this? > [...] In[1]:= W = Table[Random[Integer],{4},{5}] Total@W Out[1]= {{0,1,1,1,1}, {1,0,1,0,1}, {0,0,1,0,0}, {1,0,1,1,1}} Out[2]= {2,1,4,2,3} === Subject: Re: setting elements of an array based on a condition > I have one array, W, which for testing purposes has 25 rows and 50 columns. > There are two more things I want to accomplish with this: > 1) I want to set all elements of W which are smaller than zero to zero. Among many other ways to do it, W = Clip[W, {0, Infinity}] > 2) Then I want to calculate the sum of the elements in each column of W. > How can I do this? Total@W Here is a running example of the above. X = RandomReal[{0, 1}, 50]; Y = RandomReal[{0, 1}, 50]; BinWidth = 0.2; Radius = 0.2; xyzVals2 = Table[{i/(1/BinWidth) + (BinWidth/2), j/(1/BinWidth) + (BinWidth/2)}, {i, 0, (1/BinWidth) - 1}, {j, 0, (1/BinWidth) - 1}]; RasterPtsVals = Partition[Flatten[xyzVals2], 2] RasterX = RasterPtsVals[[All, 1]] RasterY = RasterPtsVals[[All, 2]] XDiffSq = (RasterX - a /. a -> X)^2; YDiffSq = (RasterY - b /. b -> Y)^2; Dist = Sqrt[(XDiffSq + YDiffSq)]; W = 1 - (Dist/Radius) W = Clip[W, {0, Infinity}] (* Negative values are set to zero *) Total@W (* Sum by columns *) [... output discarded ...] Here is W Out[12]= {{-3.44977, -3.42712, -1.38462, -1.26534, -1.08044, -2.98646, -2.22725, -3.6861, -3.40791, -3.46006, -3.28652, -3.41354, -2.8053, -2.86024, 0.906464, -3.20979, -0.716005, -2.46973, -2.80043, -2.05446, [... output discarded ...] -2.15641, -1.84735, -2.72521, -1.6088, -4.45553, -1.20688, 0.55019, -4.8174, -0.927821, 0.529696, -2.5054, -1.2456, -0.522142, -0.823514, -2.39116, -0.780842}} This is W after clipping Out[13]= {{0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.906464, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.47876, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.576626, 0., 0., 0.57248, 0., 0., 0., 0., 0., 0., 0., 0.}, {0., 0., 0., 0., 0., 0., 0., 0., [... output discarded ...] 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.55019, 0., 0., 0.529696, 0., 0., 0., 0., 0., 0.}} Sum by columns Out[14]= {0.501202, 1.12529, 1.0363, 0.869559, 1.04313, 1.06559, 1.04856, 0.997975, 1.02411, 1.00233, 0.882582, 0.584701, 1.03934, 0.999631, 0.906464, 0.939218, 0.67531, 0.973813, 0.999577, 1.05409, 0.863479, 0.925528, 0.999161, 0.875093, 1.01133, 0.990823, 0.893494, 1.03689, 0.949295, 1.06598, 0.999567, 0.907048, 0.770375, 1.00052, 1.01669, 1.06436, 1.1272, 0.989273, 0.976439, 0.526029, 0.915948, 0.665679, 0.983972, 1.08602, 1.15502, 1.03827, 0.789926, 0.990356, 1.05427, 0.976073} -- === Subject: What is @@@? I have seen several references to the command @@@ in this newsgroup, but a query of the online Documentation Center just refers me to Apply (@@). What does it do and where can I read about it? Kevin -- Kevin J. McCann Research Associate Professor JCET/Physics Physics Building University of Maryland, Baltimore County 1000 Hilltop Circle Baltimore, MD 21250 === Subject: Re: What is @@@? Kevin, Look at More Information for Apply. Here is an example: {a, b, c, d} step1 = f /@ % g @@@ % Identity @@@ % giving {a, b, c, d} {f[a], f[b], f[c], f[d]} {g[a], g[b], g[c], g[d]} {a, b, c, d} So @@@ is really a shortcut for: g @@ # & /@ step1 {g[a], g[b], g[c], g[d]} -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ >I have seen several references to the command @@@ in this newsgroup, but > a query of the online Documentation Center just refers me to Apply (@@). > What does it do and where can I read about it? > Kevin > -- Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 > === Subject: Re: What is @@@? Kevin > Kevin, > > Look at More Information for Apply. Here is an example: > > {a, b, c, d} > step1 = f /@ % > g @@@ % > Identity @@@ % giving > > {a, b, c, d} > {f[a], f[b], f[c], f[d]} > {g[a], g[b], g[c], g[d]} > {a, b, c, d} > > So @@@ is really a shortcut for: > > g @@ # & /@ step1 > {g[a], g[b], g[c], g[d]} > > -- Kevin J. McCann Research Associate Professor JCET/Physics Physics Building University of Maryland, Baltimore County 1000 Hilltop Circle Baltimore, MD 21250 === Subject: Re: What is @@@? @@@ is a special case of Apply where the specified head is being applied at level 1. @@ is a short form that applies the specified head at level 0. =46rom the help file: ---- Begin Excerpt ---- In[1]:= Apply[f, {{a, b, c}, {d, e}}, {1}] Out[1]= {f[a, b, c], f[d, e]} The short form @@@ is equivalent to applying at level 1: In[2]:= f @@@ {{a, b, c}, {d, e}} Out[2]= {f[a, b, c], f[d, e]} ---- End Excerpt ---- Januk > I have seen several references to the command @@@ in this newsgroup, but > a query of the online Documentation Center just refers me to Apply (@@). > What does it do and where can I read about it? > Kevin > -- Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 === Subject: RE: What is @@@? In the help of Apply, open the section (click the little triangle) More Information. As you can see there, @@@ is the infix form of Apply at level 1, in other words, f@@@g[h[a], z[b]] is the same as Apply[f, g[h[a], z[b]], {1}]. I think it is a good idea for you to use the following page. @@@ is briefly mentioned at the end of the page and compared with @, @@ and /@: http://homepage.cem.itesm.mx/lgomez/matecmatica/fp/fp.html Hope it helps! Jose Mexico -----Mensaje original----- De: Kevin J. McCann [mailto:Kevin.McCann@umbc.edu] Enviado el: Jueves, 03 de Abril de 2008 04:18 a.m. Para: mathgroup@smc.vnet.net Asunto: What is @@@? I have seen several references to the command @@@ in this newsgroup, but a query of the online Documentation Center just refers me to Apply (@@). What does it do and where can I read about it? Kevin -- Kevin J. McCann Research Associate Professor JCET/Physics Physics Building University of Maryland, Baltimore County 1000 Hilltop Circle Baltimore, MD 21250 === Subject: Re: What is @@@? > I have seen several references to the command @@@ in this > newsgroup, but > a query of the online Documentation Center just refers me to Apply > (@@). > What does it do and where can I read about it? > @@@ is a shorthand for Apply[f,expr,{1}] in the same way @@ is shorthand for Apply[f,expr]. In v6.0 @@@ is described in the 3rd bullet under the More Information category in the documentation on Apply. Since the More Information tab is closed by default I suppose this can lead to confusion. There are no @@@@., @@@@@, ... Ssezi === Subject: Re: What is @@@? f@@@expr is equivalent to Apply[f,expr,{1}]. Adriano Pascoletti > I have seen several references to the command @@@ in this newsgroup, but > a query of the online Documentation Center just refers me to Apply (@@). > What does it do and where can I read about it? > Kevin > -- Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 === Subject: Re: What is @@@? > I have seen several references to the command @@@ in this newsgroup, but > a query of the online Documentation Center just refers me to Apply (@@). > What does it do and where can I read about it? > Kevin > -- Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 Hallo, it means:f@@@expr is equivalent to Apply[f,expr,{1}]. === Subject: Re: What is @@@? Kevin, The short form @@@ is equivalent to applying at level 1 : See : ref/Apply in Mathematica Help > Scope (10) > ($Line = 0; Null) HTH ... Syd Syd Geraghty B.Sc, M.Sc. sydgeraghty@mac.com My System Mathematica 6.0.1 for Mac OS X x86 (64 - bit) (June 19, 2007) MacOS X V 10.5 .20 > I have seen several references to the command @@@ in this newsgroup, > but > a query of the online Documentation Center just refers me to Apply > (@@). > What does it do and where can I read about it? > Kevin > -- Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 > === Subject: Re: What is @@@? You'll find this in the tutorial Input Syntax. -- tutorial/InputSyntax. (You can get to that from the main Documentation Center > Core Language > Syntax >tutorials. Or if in Mathematica 6.0.2 you open the built-in Virtual Book, then from Core Language > Appendix:Language Structure > Input Syntax > Types of Input Syntax.) On that tutorial page, search for @@@. You'll see that expr1 @@@ expr2 is a special input form that means Apply[expr1, expr2, {1}] So the effect is to replace heads in the parts of expr2 at level {1} by expr1. For example: Remove[f,g,a,b] Apply[f, g[List[1, 2], List[a, b]], {1}] g[f[1,2],f[a,b]] f@@@g[List[1,2],Lis[a,b]] (* same thing *) g[f[1,2],f[a,b]] More concrete example: Apply[Plus, {{1, 2}, {a, b}}, {1}] {3,a+b} Plus @@@ {{1, 2}, {a, b}} (* same thing *) {3,a+b} Contrast that with, e.g.: Plus @@ {{1, 2}, {a, b}} {1+a,2+b} that is, Apply[Plus,{{1,2},{a,b}}] (* same thing as preceding *) {1+a,2+b} > I have seen several references to the command @@@ in this newsgroup, but > a query of the online Documentation Center just refers me to Apply (@@). > What does it do and where can I read about it? > > > Kevin -- 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: What is @@@? and *if* you would have the text about Apply[] you have seen that f@@@expr is equivalent to Apply[f,expr,{1}]. Jens > I have seen several references to the command @@@ in this newsgroup, but > a query of the online Documentation Center just refers me to Apply (@@). > What does it do and where can I read about it? > > > Kevin === Subject: Re: What is @@@? > I have seen several references to the command @@@ in this newsgroup, but > a query of the online Documentation Center just refers me to Apply (@@). > What does it do and where can I read about it? > Kevin > -- Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 It's hidden away in the documentation: In version 6.02 ... under the documentation for Apply (@@) in the section Examples/Scope/Level Specifications The short form @@@ is equivalent to applying at level 1: In[2]:= f @@@ {{a, b, c}, {d, e}} Out[2]= {f[a, b, c], f[d, e]} === Subject: Re: What is @@@? > I have seen several references to the command @@@ in this newsgroup, but > a query of the online Documentation Center just refers me to Apply (@@). > What does it do and where can I read about it? > Hi Kevin, @@@ is apply at level 1. f @@@ expr is equivalent to Apply[f, expr, {1}]. This is under more information on the doc page of Apply[]. It is easy to remember the sytax: each of @, @@, and @@@ act at a deeper level: In[1]:= f@{{1, 2}, {3, 4}} Out[1]= f[{{1, 2}, {3, 4}}] In[2]:= f @@ {{1, 2}, {3, 4}} Out[2]= f[{1, 2}, {3, 4}] In[3]:= f @@@ {{1, 2}, {3, 4}} Out[3]= {f[1, 2], f[3, 4]} But there is no @@@@, it only goes until @@@. Szabolcs === Subject: How to display parameter in animation? How do I display the parameter in an animation? For example, I would like to see the values of the parameter 'a' in the following example from the mathematica documentation: Animate[Plot[Sin[x+a],{x,0,10}],{a,0,5}] In particular, if I pause the animation I would like to see what the value of the parameter is. === Subject: Re: How to display parameter in animation? > How do I display the parameter in an animation? For example, I would like to see the values of the parameter 'a' in the following example from the mathematica documentation: Animate[Plot[Sin[x+a],{x,0,10}],{a,0,5}] In particular, if I pause the animation I would like to see what the value of the parameter is. > One can also use PlotLabel, this will print the values dynamically as the animation is running. Animate[Plot[Sin[x + a], {x, 0, 10}, PlotLabel -> a], {a, 0, 5}] Hope this helps, Pratik Desai Wolfram Research === Subject: Re: How to display parameter in animation? Manipulate is probably the function of choice, even for animations. Manipulate[ Plot[Sin[x + a], {x, 0, 10}], {a, 0, 5, Appearance -> Labeled}] The Appearance option puts the slider value on the right of the slider control. If you click on the little gray square just to the right of the slider you can show the animation controls and run the display as an animation. The value of the slider is also shown in the animation controls and you can move the slider when the animation is stopped so in this mode the Appearance option might not be necessary. But one feature of Mathematica 6 that I find annoying is that animations, for me at least, sometimes just stop when they should run indefinitely. I do know how to control this behavior. I've tried many of the Animate options. Sometimes the problem is cured if I just click the 'Faster' button. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > How do I display the parameter in an animation? For example, I would like to see the values of the parameter 'a' in the > following example from the mathematica documentation: Animate[Plot[Sin[x+a],{x,0,10}],{a,0,5}] In particular, if I pause the animation I would like to see what the value > of the parameter is. > === Subject: Re: How to display parameter in animation? One way is to use Epilog to stick text right on the plot: Animate[Plot[Sin[x + a], {x, 0, 10}, Epilog -> Text[a = <> ToString[a], Scaled[{0.8, 0.8}]]], {a, 0, 5} ] Hope that helps! C.O. > How do I display the parameter in an animation? For example, I would like to see the values of the parameter 'a' in the > following example from the mathematica documentation: Animate[Plot[Sin[x+a],{x,0,10}],{a,0,5}] In particular, if I pause the animation I would like to see what the value > of the parameter is. -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: How to display parameter in animation? Animate[Plot[Sin[x + a], {x, 0, 10}, Epilog -> {Text[a, Scaled[{0.8, 0.9}]]}], {a, 0, 5}] ?? Jens > How do I display the parameter in an animation? > > For example, I would like to see the values of the parameter 'a' in the following example from the mathematica documentation: > > Animate[Plot[Sin[x+a],{x,0,10}],{a,0,5}] > > In particular, if I pause the animation I would like to see what the value of the parameter is. > === Subject: Colored Output I would like to have evaluated expression with some costants painted in a particular color, just to make reading easier. Say my input is D[a*Sin[x]] and the output should be a*Cos[x] with colored a, say magenta. Is this achievable, and how? which kind of attributed of the constant a should I set? Best Roberto === Subject: Re: Colored Output > I would like to have evaluated expression with some costants painted > in a particular color, just to make reading easier. > Say my input is > > D[a*Sin[x]] > > and the output should be > > a*Cos[x] > > with colored a, say magenta. > > Is this achievable, and how? which kind of attributed of the constant > a should I set? I don't know much about expression formatting. While this appears to work in a few simple tests, I do not know how robust it is: MakeBoxes[a, StandardForm] = StyleBox[a, FontColor -> Red] After this line has been evaluated, the symbol 'a' will be printed in red (when output is set to StandardForm). The formatting rule can be removed with MakeBoxes[a, StandardForm] =. Szabolcs === Subject: Re: Colored Output A possible way to achieve this result is the following: << Graphics`Colors` Format[a] := StyleForm[SymbolName[a], FontColor -> Magenta] working with 5.2 on winxp. -- enzotib === Subject: Re: Colored Output I have been told I can use MakeBoxes: MakeBoxes[a, StandardForm] := StyleBox[a, Green] Then, evaluate D[a Sin[x], x] If you're default output format type is TraditionalForm, then just substitute TraditionalForm for StandardForm in the MakeBoxes rule. === Subject: Re: Colored Output a /: MakeBoxes[a, fmt_] := StyleBox[a, FontColor -> RGBColor[1, 0, 0]] for red. Jens > I would like to have evaluated expression with some costants painted > in a particular color, just to make reading easier. > Say my input is > > D[a*Sin[x]] > > and the output should be > > a*Cos[x] > > with colored a, say magenta. > > Is this achievable, and how? which kind of attributed of the constant > a should I set? > > Best > Roberto > === Subject: Re: Colored Output > I would like to have evaluated expression with some costants painted > in a particular color, just to make reading easier. > Say my input is > > D[a*Sin[x]] > > and the output should be > > a*Cos[x] > > with colored a, say magenta. > > Is this achievable, and how? which kind of attributed of the constant > a should I set? Depending on the complexity of your actual expressions, the easiest way to color some parts of them might be using replacement rules (and possibly some *Cases* statements) to apply the desired *Style* commands to the constants. For instance, D[a*Sin[x]] /. a -> Style[a, Magenta] -- === Subject: Re: Colored Output > I would like to have evaluated expression with some costants painted > in a particular color, just to make reading easier. > Say my input is > > D[a*Sin[x]] > > and the output should be > > a*Cos[x] > > with colored a, say magenta. > > Is this achievable, and how? which kind of attributed of the constant > a should I set? > > Best > Roberto > Try this: MakeBoxes[a, StandardForm] := StyleBox[a, Red] David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Colored Output >I would like to have evaluated expression with some costants painted >in a particular color, just to make reading easier. >Say my input is D[a*Sin[x]] and the output should be a*Cos[x] with colored a, say magenta. Is this achievable, and how? which kind of attributed of the constant >a should I set? Best >Roberto > > You can use MakeBoxes: MakeBoxes[a, StandardForm] := StyleBox[a, Green] Then, evaluate D[a Sin[x], x] If you're default output format type is TraditionalForm, then just substitute TraditionalForm for StandardForm in the MakeBoxes rule. Carl Woll Wolfram Research === Subject: Re: Colored Output You could try something like: a := Interpretation[Style[a, Magenta], a] D[a Sin[x], x] -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ >I would like to have evaluated expression with some costants painted > in a particular color, just to make reading easier. > Say my input is > > D[a*Sin[x]] > > and the output should be > > a*Cos[x] > > with colored a, say magenta. > > Is this achievable, and how? which kind of attributed of the constant > a should I set? > > Best > Roberto > === Subject: contouring It's been a blast dwelving into Mathematica, and I am fairly impressed how nice it is to work without loops! ;-) Now I've got some plotting issues. In the example below, specifically for the ListContourPlot: a) can I invert the colors (so for the case of Lake colors that deep blue is at the 50-value? b) can I change the contouring so that the the square with the corners {0,1},{1,0} is contoured? XYZDATA = {{0.9, 0.9, 50}, {0.8, 0.9, 30}, {0.9, 0.8, 30}, {0.5, 0.5, 15}, {0.2, 0.1, 1}, {0.1, 0.2, 1}} ListPlot[Transpose[{XYZDATA[[All, 1]], XYZDATA[[All, 2]]}] , PlotRange -> {{0, 1}, {0, 1}} , AspectRatio -> 1] ListContourPlot[XYZDATA , AspectRatio -> 1 , PlotRange -> {{0, 1}, {0, 1}} , ColorFunction -> LakeColors] It seems as if things get worse if there are more extreme values, like this: XYZDATA2 = {{0.95, 0.95, 150}, {0.9, 0.9, 50}, {0.8, 0.9, 30}, {0.9, 0.8, 30}, {0.5, 0.5, 15}, {0.2, 0.1, 1}, {0.1, 0.2, 1}} Dots = ListPlot[Transpose[{XYZDATA2[[All, 1]], XYZDATA2[[All, 2]]}] , PlotRange -> {{0, 1}, {0, 1}} , AspectRatio -> 1] ShadedPlot = ListContourPlot[XYZDATA2 , AspectRatio -> 1 , PlotRange -> {{0, 1}, {0, 1}} , ColorFunction -> LakeColors] Show[Dots, ShadedPlot] In the second case, the interpolation does not extent to the point at {0.95, 0.95}. Is there a way to set somehow limits for contouring, for the given example, say all z-values >50 should be contoured with the darkest shade of blue? I played around with creating a ColorScheme, like GreyColor[ z_ ] := GrayLevel[1 - z] and ShadedPlot2 = ListContourPlot[XYZDATA2 , AspectRatio -> 1 , PlotRange -> {{0, 1}, {0, 1}} , ColorFunction -> GreyColor ] which sort of solves my problems, because now all z-values >1 are black, which I verified by this code MaxCont = 1; MinCont = 0.1; DeltaCont = 0.1; Graphics[{ Table[{ GreyColor[i] , Rectangle[{i - DeltaCont, DeltaCont}, {i, 2*DeltaCont}] , Black, Text[Style[i, 20], {i - (DeltaCont/3), MinCont}, {i, 1.5*MaxCont}] }, {i, MinCont, MaxCont, DeltaCont}] }] However, the point at {0.95, 0.95} is still not included in the shading. So I guess my questions a) and b) from above are still my problems... ;-) Claus === Subject: Re: contouring Use PlotRange->All, or ClippingStyle->Automatic -Ulises Cervantes WRI === Subject: Re: reaction diffusion equation ! Hi Khaled, Mathematica uses Numerical method of lines and the number of independent variables must be restricted to atmost 2.However,Mathematica has exceptional symbolic computational abilities and it will not be difficult to rephrase your problem to a form that is solvable.Please provide further details like the form of f(U) and boundary conditions so that we can proceed further. Nabeel > Can NDSolve in Mathematica solves the nonlinear reaction diffusion > equation in two dimensions > (Tt-Uxx-Uyy=f(U) with Drichlit B.C.). I ask u kindly to send me the > mathematica program solves the transient heat equation in two dimension or > the heat diffusion equation if u already have it. > khaled sayed > Khaled Sayed Mahmoud Ibrahim Department of MathematicsFaculty of > ScienceHelwan University Helwan, Cairo, EgyptTel.: (+20)18-25-35-272 > Fax: (+20)-2-25588-586k_s_mahmoud@hotmail.com -- We have not succeeded in answering all our problems.The answers we have found only serve to raise a whole set of new questions.In some ways we feel that we are as confused as ever,but we believe we are confused on a higher level and about more important things. Nabeel Butt UWO,London Ontario, Canada === Subject: reaction diffusion equation ! Can NDSolve in Mathematica solves the nonlinear reaction diffusion equation in two dimensions (Tt-Uxx-Uyy=f(U) with Drichlit B.C.). I ask u kindly to send me the mathematica program solves the transient heat equation in two dimension or the heat diffusion equation if u already have it. khaled sayed Khaled Sayed Mahmoud Ibrahim Department of MathematicsFaculty of ScienceHelwan University Helwan, Cairo, EgyptTel.: (+20)18-25-35-272 Fax: (+20)-2-25588-586k_s_mahmoud@hotmail.com === Subject: mathematica on macbook... hangs on 5-4 Hi all, I have installed Mathematica 6.0.2.0 onto a macbook 2.2 GHz Intel Core 2 Duo running OS X 10.5.2 (2GB of ram). The program (as the version 6.0.0) hangs in evaluating even the simplest cells such as addition 2+2. It just hangs for minutes without giving any message. Mathematica 10.5.2 works fine... I have noticed that if I run it as admin it gives me these problems while if I run it as ROOT user it doesn't. Suggestions? === Subject: Derivative of a Conjugate Hi All, My first posting here, so please forgive me if I am being a bit stupid. I'm entering the following input: D[f[t0, t1], t0, t1] /. {f -> ((#1^2)*Conjugate[a[#2]] &)} and Mathematica gives the following output: 2 t0 a'[t1] Conjugate'[a[t1]] I would have expected: 2 t0 Conjugate[a'[t1]] i.e. the derivative of a conjugate is the conjugate of the derivative. Any idea how a force Mathematica to give the result I am expecting? In the above, I am assuming the variables t0 and t1 are real and the variable a is complex, although I have not explicitly told Mathematica this. David === Subject: Re: Derivative of a Conjugate > Hi All, My first posting here, so please forgive me if I am being a bit > stupid. I'm entering the following input: D[f[t0, t1], t0, t1] /. {f -> ((#1^2)*Conjugate[a[#2]] &)} and Mathematica gives the following output: 2 t0 a'[t1] Conjugate'[a[t1]] I would have expected: 2 t0 Conjugate[a'[t1]] i.e. the derivative of a conjugate is the conjugate of the derivative. Any idea how a force Mathematica to give the result I am expecting? > In the above, I am assuming the variables t0 and t1 are real and > the variable a is complex, although I have not explicitly told > Mathematica this. > David > Mathematica always assumes that the derivative is computed in the complex plane and it automatically applies the chain rule. It certianly would be wrong to assume that the derivative commutes with conjugation, as that is not true in general in the complex plane, so if Mathematica did not automatically apply the chain rule it would have to return your input unevaluated. One way to avoing your problem is to write your function a[x] explicitly as a sum of its real and imaginary parts, say c[x] and d[x]. First make a list of replacement rules for getting the output back in terms of a[x]: rules = {c[x_] :> Re[a[x]], d[x_] :> Im[a[x]], Derivative[n_][c][x_] :> Re[Derivative[n][a][x]], Derivative[n_][d][x_] :> Im[Derivative[n][a][x]]}; Now, we differentiate usign c[x]+I d[x] in place of a[x], apply rules and FullSimplify: FullSimplify[D[f[t0, t1], t0, t1] /. {f -> (#1^2*(c[#2] - I*d[#2]) & )} /. rules] 2*t0*Conjugate[Derivative[1][a][t1]] Andrzej Kozlowski === Subject: Re: Derivative of a Conjugate Hi David, Conjugate is not an analytic function. Consider: r=x+I y; z[r]= x+I y; Conjugate[z[r]]= x-I y; dz= dx + I dy; dConjugate[z]= dx -I dy now take the differential quotient and you see that the derivative depends on the direction. That is why Mathematica does not evaluate Conjugate'. If dr is real you may e.g. use a rule to get what you want: expression /. Conjugate'[y_[x_]]:= Conjugate[y'[x]] hope this helps, Daniel > Hi All, > > My first posting here, so please forgive me if I am being a bit stupid. > > I'm entering the following input: > > D[f[t0, t1], t0, t1] /. {f -> ((#1^2)*Conjugate[a[#2]] &)} > > and Mathematica gives the following output: > > 2 t0 a'[t1] Conjugate'[a[t1]] > > I would have expected: > > 2 t0 Conjugate[a'[t1]] > > i.e. the derivative of a conjugate is the conjugate of the derivative. > > Any idea how a force Mathematica to give the result I am expecting? In the above, I am assuming the variables t0 and t1 are real and the variable a is complex, although I have not explicitly told Mathematica this. > > > David > === Subject: Label vertices in Graph to display with GraphPlot I'm using some Combinatorica functions to create graphs where I do not specify individually the vertices -- and hence do not individually specify the vertex labels I want, e.g.: g = RotateVertices[Cycle[5], [Pi]/10]; g = AddEdge[g, {2, 5}]; g = SetGraphOptions[g, VertexLabel -> Characters[abcde]]; If I use Combinatorica`ShowGraph, then I'll see the vertex labels: ShowGraph[g] However, if I use Mathematica 6's kernel function GraphPlot, I don't see these individual labels, but rather the entire list {a,b,c,d,e} of labels at each vertex! GraphPlot[g,Method->None,VertexRenderingFunction->(Text[#2,#1]&) How do I coerce GraphPlot to reproduce the behavior of ShowGraph, so that it labels the individual vertices with a, b, c, d, e? (The interaction between Combintorica's graph-creating functions, on the one hand, and GraphPlot, on the other hand, remains mysterious and severely underdocumented for me. It seems there's a clear attempt to migrate display of graphs to the kernel function GraphPlot and thereby discourage use of ShowGraph, yet in almost everything I've attempted so far, GraphPlot does not so readily or gracefully reproduce the functionality of Combinatorica'a ShowGraph. This is most especially the case as it affects relative newcomers to Mathematica like my students.) -- 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: What is @@@? With the help for Apply (@@) expand out the MORE INFORMATION to see the statement: f@@@expr is equivalent to Apply[f,expr,{1}] f @@@ {{x1, x2, x3}, {y1, y2, y3}} {f(x1,x2,x3),f(y1,y2,y3)} Apply[f, {{x1, x2, x3}, {y1, y2, y3}}, {1}] {f(x1,x2,x3),f(y1,y2,y3)} Apply[f, {{x1, x2, x3}, {y1, y2, y3}}, 1] {f(x1,x2,x3),f(y1,y2,y3)} f @@ # & /@ {{x1, x2, x3}, {y1, y2, y3}} {f(x1,x2,x3),f(y1,y2,y3)} Map[f @@ # &, {{x1, x2, x3}, {y1, y2, y3}}] {f(x1,x2,x3),f(y1,y2,y3)} Map[Apply[f, #] &, {{x1, x2, x3}, {y1, y2, y3}}] {f(x1,x2,x3),f(y1,y2,y3)} Bob Hanlon > I have seen several references to the command @@@ in this newsgroup, but > a query of the online Documentation Center just refers me to Apply (@@). > What does it do and where can I read about it? > > > Kevin > -- > > Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 > === Subject: Re: How to display parameter in animation? Manipulate[Plot[Sin[x + a], {x, 0, 10}], {a, 0, 5}] Then expand control Bob Hanlon > How do I display the parameter in an animation? > > For example, I would like to see the values of the parameter 'a' in the following example from the mathematica documentation: > > Animate[Plot[Sin[x+a],{x,0,10}],{a,0,5}] > > In particular, if I pause the animation I would like to see what the value of the parameter is. > === Subject: Mathematica to Tex I am trying to export to Tex. My idea is to paste parts of notebooks on my mediawiki, which can accept Tex. I am sure there is a good way to do this. Let's say I write the following as a Text cell in Mathematica: P(A) = 1-e^-[Lambda]t P(A)+P(B) Can I do TeXForm on a text cell? What would be the best way to export just that? If I save the file as .Tex I get: (P(A) = 1-e^{-text{$lambda $t}} P(A)+P(B)) but what I want is something along the lines of P(A) = 1-e^{-lambda t} P(A)+P(B) There might be an easier solution. Any suggestions? Ramiro === Subject: Re: Mathematica to Tex > If I save the file as .Tex I get: > > (P(A) = 1-e^{-text{$lambda $t}} > P(A)+P(B)) > > but what I want is something along the lines of > > P(A) = 1-e^{-lambda t} > P(A)+P(B) This is because you forgot to put a space between [Lambda] and t, so mathematica interprets [Lambda]t as text (a single word) and not as two mathematical symbols. === Subject: Re: Mathematica to Tex > > I am trying to export to Tex. My idea is to paste parts of notebooks > on my mediawiki, which can accept Tex. I am sure there is a good way > to do this. > Have you tried selecting the text, right clicking and choosing Copy As -> LaTeX? (This works in Mathematica 6.) === Subject: Re: Mathematica to Tex > If I save the file as .Tex I get: > > (P(A) = 1-e^{-text{$lambda $t}} > P(A)+P(B)) me too. i just edit that.... > > but what I want is something along the lines of > > P(A) = 1-e^{-lambda t} > P(A)+P(B) > .... because i want pretty much the same thing you do. you can see the results at rip94550.wordpress.com/ vale, rip -- NB eddress is r i p 1 AT c o m c a s t DOT n e t === Subject: Re: Mathematica to Tex > I am trying to export to Tex. My idea is to paste parts of notebooks > on my mediawiki, which can accept Tex. I am sure there is a good way > to do this. > > Let's say I write the following as a Text cell in Mathematica: > > P(A) = 1-e^-[Lambda]t > P(A)+P(B) > > Can I do TeXForm on a text cell? What would be the best way to export > just that? If I save the file as .Tex I get: > > (P(A) = 1-e^{-text{$lambda $t}} > P(A)+P(B)) > > but what I want is something along the lines of > > P(A) = 1-e^{-lambda t} > P(A)+P(B) > > There might be an easier solution. Any suggestions? Note that you should use valid Mathematica syntax (as if you were going to evaluate the expressions, say, given in Input syntax) and if you want to use Text Cell, the formulae should be entered as *inline cell*. In[1]:= TeXForm[P[A] == 1 - E^(-[Lambda] t)] Out[1]//TeXForm= P(A)=1-e^{-t lambda } In[2]:= TeXForm[P[A] + P[B]] Out[2]//TeXForm= P(A)+P(B) HTH, -- === Subject: Re: solving a system of polynomial equations >I'm pretty new to Mathematica. I want to numerically solve a system >of N polynomial equations with N unknowns. I've heard that >Mathematica was able to find all the real/complex solutions due to >the fact that equations only involve polynomials. Is that correct? >If yes, what is the command/method? The command to get a numerical solution to N polynomials with N unknowns is NSolve. In general, Mathematica commands that return numerical solutions start with a capital N such as NMinimize, NIntegrate etc. Also, while NSolve intended primarily for polynomials, Mathematica is not limited to solving polynomial equations. And in fact, NSolve will solve some non-polynomial equations. === Subject: Re: solving a system of polynomial equations > Also, while NSolve intended primarily for polynomials, > Mathematica is not limited to solving polynomial equations. And > in fact, NSolve will solve some non-polynomial equations. but only one solution with non polynomial equations, right? The one closest to the starting guess? Do you know if Nsolve use any of the Groebner Theory? Pluton === Subject: Re: What is @@@? >I have seen several references to the command @@@ in this newsgroup, >but a query of the online Documentation Center just refers me to >Apply (@@). What does it do and where can I read about it? When you have the page for Apply open, click the triangle beside More Information. There you will find a short blurb stating f@@@expr is equivalent to Apply[f, expr, {1}]. I seem to remember @@@ as being short for MapApply. But I see there is no MapApply function any longer in version 6. === Subject: Re: Solve inconsistant actions? Can someone enlighten me as to what discriminators Solve uses in providing some solutions while disdaining others in the attached simple code? Is it an operator or Mathematica bug? I am running 6.0.1 under win xp. newrent = Table[125000 [ExponentialE]^(r 14), {r, .01, .04, .005}] // N Table[Solve[newrent[[i]]/rate == 1894000 , rate], {i, 1, 7}] Table[Solve[newrent[[i]]/rate == 1894000. , rate], {i, 1, 7}] Table[Reduce[newrent[[i]]/rate == 1894000 , rate], {i, 1, 7}] Table[Solve[newrent[[i]] == 1894000 rate, rate], {i, 1, 7}] Marlyn Hicks mhicks@san.rr.com === Subject: Re: Solve inconsistant actions? > Can someone enlighten me as to what discriminators Solve uses in > providing some solutions while disdaining others in the attached simple > code? > > Is it an operator or Mathematica bug? I am running 6.0.1 under win xp. > > > newrent = Table[125000 [ExponentialE]^(r 14), {r, .01, .04, .005}] // N > > Table[Solve[newrent[[i]]/rate == 1894000 , rate], {i, 1, 7}] > > Table[Solve[newrent[[i]]/rate == 1894000. , rate], {i, 1, 7}] > > Table[Reduce[newrent[[i]]/rate == 1894000 , rate], {i, 1, 7}] > > Table[Solve[newrent[[i]] == 1894000 rate, rate], {i, 1, 7}] > This happens because Solve was designed to work with exact values and you are using it with approximate (floating point) values. When it verifies the solutions, it finds some of the solutions to be incorrect (because of precision issues). With VerifySolutions -> False Solve will return all solutions: Solve[#/rate == 1894000, rate, VerifySolutions -> False] & /@ newrent However, it is generally a very bad idea to mix exact and approximate values in calculations (or to use approximate values in symbolic calculations). Either use exact values in newrent: Solve[#/rate == 1894000, rate] & /@ Rationalize[newrent, 0] or use NSolve if you only need approximate solutions: NSolve[#/rate == 1894000, rate] & /@ newrent Szabolcs === Subject: Re: Solve inconsistant actions? > Can someone enlighten me as to what discriminators Solve uses in > providing some solutions while disdaining others in the attached simple > code? > > Is it an operator or Mathematica bug? I am running 6.0.1 under win xp. > > > newrent = Table[125000 [ExponentialE]^(r 14), {r, .01, .04, .005}] // N > > Table[Solve[newrent[[i]]/rate == 1894000 , rate], {i, 1, 7}] > > Table[Solve[newrent[[i]]/rate == 1894000. , rate], {i, 1, 7}] > > Table[Reduce[newrent[[i]]/rate == 1894000 , rate], {i, 1, 7}] > > Table[Solve[newrent[[i]] == 1894000 rate, rate], {i, 1, 7}] Keep in mind that *Solve* is a symbolic solver and it usually works better when fed with exact numbers, as you can see below. (Sorry not to be able to comment more on the internal algorithm of *Solve*.) newrent = Table[125000 E^(r 14), {r, 1/100, 4/100, 5/1000}] rate /. N@ Table[Solve[newrent[[i]]/rate == 1894000, rate], {i, 1, 7}] // Flatten rate /. Table[ Solve[newrent[[i]]/rate == 1894000., rate], {i, 1, 7}] // Flatten rate /. Table[ NSolve[newrent[[i]]/rate == 1894000, rate], {i, 1, 7}] // Flatten rate /. Table[ Solve[newrent[[i]]/rate == 1894000., rate], {i, 1, 7}] // Flatten rate /. ToRules /@ N@Table[Reduce[newrent[[i]]/rate == 1894000, rate], {i, 1, 7}] rate /. N@ Table[Solve[newrent[[i]] == 1894000 rate, rate], {i, 1, 7}] // Flatten {125000 E^(7/50), 125000 E^(21/100), 125000 E^(7/25), 125000 E^(7/20), 125000 E^(21/50), 125000 E^(49/100), 125000 E^(14/25)} {0.0759156, 0.0814201, 0.0873238, 0.0936555, 0.100446, 0.107729, 0.115541} {0.0759156, 0.0814201, 0.0873238, 0.0936555, 0.100446, 0.107729, 0.115541} {0.0759156, 0.0814201, 0.0873238, 0.0936555, 0.100446, 0.107729, 0.115541} {0.0759156, 0.0814201, 0.0873238, 0.0936555, 0.100446, 0.107729, 0.115541} {0.0759156, 0.0814201, 0.0873238, 0.0936555, 0.100446, 0.107729, 0.115541} {0.0759156, 0.0814201, 0.0873238, 0.0936555, 0.100446, 0.107729, 0.115541} HTH, -- === Subject: Re: How to put text on a curved surface? >I would like to put Mathematica on a curved surface, e.g. a torus. > Can anyone help here? > with friendly greetings, > P_ter Brute force. Not much slower than MeshShading. Make raster of text, compose Polygons on the flat raster grid, apply FaceForm[RGBColor] to each Polygon, and display with Graphics3D: w = 160; h = 40; map = Rasterize[**** Mathematica **** , RGBColor , RasterSize -> {w, h} , Background -> White]; Graphics3D[{EdgeForm[], Table[{FaceForm[map[[i, j]]], Polygon[{{i, j, 0}, {i, j + 1, 0}, {i + 1, j + 1, 0}, {i + 1, j, 0}}]} , {i, 1, h - 1} , {j, 1, w - 1}]} Next, map the 2D raster grid onto the 3D coordinates to on a torus: r = 1.0; r0 = 0.3; fx[i_, j_] := (r - r0 Cos[2 Pi i/40]) Cos[(2 Pi j)/160]; fy[i_, j_] := (r - r0 Cos[2 Pi i/40]) Sin[(2 Pi j)/160]; fz[i_, j_] := r0 Sin[2 Pi i/40]; w = 160; h = 40; map = Rasterize[**** Mathematica **** , RGBColor , Background -> White , RasterSize -> {w, h}]; Graphics3D[{EdgeForm[] , Table[{FaceForm[map[[i, j]]], Polygon[{{fx[i, j], fy[i, j], fz[i, j]} , {fx[i, j + 1], fy[i, j + 1], fz[i, j + 1]} , {fx[i + 1, j + 1], fy[i + 1, j + 1], fz[i + 1, j + 1]} , {fx[i + 1, j], fy[i + 1, j], fz[i + 1, j]}}]} , {i, 1, h - 1} , {j, 1, w - 1}]} ] It could be prettied up some, but it'd still be a pig. Fred Klingener === Subject: Re: How to put text on a curved surface? Here is a really nice demo from Michael Trott: http://www.mathematicaguidebooks.org/ Kevin > I would like to put Mathematica on a curved surface, e.g. a torus. > Can anyone help here? > with friendly greetings, > P_ter > -- Kevin J. McCann Research Associate Professor JCET/Physics Physics Building University of Maryland, Baltimore County 1000 Hilltop Circle Baltimore, MD 21250 === Subject: Re: How to put text on a curved surface? The Presentations package, at my web site below, has true 3D text that can be fitted to a curved surface. The package has many other features and is aimed both to making custom graphics and to extending Mathematica to make it easier to work with textbooks and research papers in a natural style. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ >I would like to put Mathematica on a curved surface, e.g. a torus. > Can anyone help here? > with friendly greetings, > P_ter > === Subject: Re: How to put text on a curved surface? here is a first attempt: a) define a 2dim parameter space. E.g. for a Torus {0,2Pi} x {0,2Pi} b) write your characters into the flat parameter space c) map the 2dim parameter space into 3D here is an example where we write two A characters onto a torus: R=10;r=3; map[p1_,p2_]:={R Sin[p1]+ r Cos[p2] Sin[p1],R Cos[p1]+ r Cos[p2] Cos[p1],r Sin[p2]}; charA2D[p_,pos_,size_]:=Plus[#,pos]&/@{{0.5 p,p},{0.5+0.5p,1-p},{0.25+0.5p,0.5}}; txt[p_]:=Join[charA2D[p,{0,-.5},1],charA2D[p,{1.1,-.5},1]]; g1={Graphics3D[Thickness[0.02]],ParametricPlot3D[map@@@txt[p],{p,0,1}]}//Sho w; g2=ParametricPlot3D[map[p1,p2],{p1,0,2Pi},{p2,0,2Pi}]; Show[g2,g1] hope thsi helps, Daniel > I would like to put Mathematica on a curved surface, e.g. a torus. > Can anyone help here? > with friendly greetings, > P_ter > === Subject: Re: How to put text on a curved surface? >I would like to put Mathematica on a curved surface, e.g. a torus. > Can anyone help here? > with friendly greetings, My response is a reprise of my post of a couple of weeks ago on texture mapping, for which there were helpful responses, but no satisfying resolution. One straightforward approach is to map an image of the text onto a mesh generated on a torus. Applying the earlier method to your case, I'll use Rasterize to generate an RGBColor array directly from the text: map = Rasterize[ ttMathematicatt , RGBColor , ImageSize -> {160, 30} , ImageResolution -> 20]; grid = Take[Dimensions[map, 2] - 1]; r = 1; r0 = 0.3; ParametricPlot3D[{ (r1 = (r + r0 Cos[phi])) Cos[theta] , r1 Sin[theta] , r0 Sin[phi]} , {phi, -Pi, Pi} , {theta, 0, 2 Pi} , Mesh -> Reverse[grid] , MeshStyle -> None , MeshFunctions -> {#5 &, -#4 &} , MeshShading -> map ,ViewPoint -> {-1, 2, 1} ] On the one hand, the technique evidently produces a useful result, but on the other, it's so bog-slow that it can't possibly be the right way to do it. On my WinXP 6.0.1, the timing (huge difference between Timing[] report and meat clock time elapsed) and memory (inexorable rise in page file usage) puzzles remain when I work with meshshading. Hth, Fred Klingener === Subject: Re: How to put text on a curved surface? > I would like to put Mathematica on a curved surface, e.g. a torus. > Can anyone help here? > with friendly greetings, > P_ter You mean the projected/mapped letters should be curved ? Try projecting stencil slots onto the torus from a suitable bright point as light source, which can be even at infinity.. as intersection with the conical rays. === Subject: Re: How to put text on a curved surface? > I would like to put Mathematica on a curved surface, e.g. a torus. > Can anyone help here? > with friendly greetings, > P_ter You mean the projected/mapped letters should be curved ? Try > projecting stencil slots onto the torus from a suitable bright point > as light source, which can be even at infinity.. as intersection with > the conical rays. It should be mentioned that the mapping can never be faithful ( per isometric mappings between flat to flat or curvrd to curved surfaces ) as there is bound to be alteration due to: 1) magnification/reduction ( strain of tension or compression), 2) distortion ( angle changes in shear). It is in other words so stated by Gauss Egregium theorem. After writing or printing the text on a flat label when you try to stick it on a torus of suitable size, a tendency to tear on areas outside the crown (Gauss Curvature > 0) and some folds/frills on the inside ( G.C < 0) is inevitable. The most faithful reproduction takes place at the crown ( G.C ~ 0). === Subject: Re: How to put text on a curved surface? I followed the link. I discovered that the Presentations Package of David Park is needed. I found in that a reason to buy it. I already wanted to do that a long time. Still, I am interested in other solutions. with friendly greetings, P_ter === Subject: Re: How to put text on a curved surface? I got help from Michael Trott. He suggested one could use:mText2D = ImportString[ExportString[Cell[TextData[StyleBox[Mathematica, FontWeight -> Bold]], Section], PDF]][[1]] I changed the text to A, the format to JPEG and the size to 24. After that I used Best way to draw a raster image onto a curved surface from Andrew Moylan. It worked. === Subject: Re: Fitting a inverse function from complicated integral I need to Fit this experimental data {x, OOT}: data = { > {1, 444.6}, > {3, 455.15}, > {5, 464.81}, > {7, 467.79}, > {10, 469.01}, > {15, 480.28}} But there is a big problem with model equation: x = Integrate[A*Exp[-B/T], {T, 0, OOT}, Assumptions -> A > 0 && B > 0 > && OOT > 0] So, after integration: x = A (Exp[-B/OOT] OOT - B Gamma[0, B/OOT]) I need to obtain a INVERSE function, i.e. OOT = f(x) and then find > (e.g. via FindFit) best fitting parameters A, B. I have tried Series expansion, PadeApproximant etc., but every > approximation of mentioned > model contain A*Exp[-B/T], so I cannot find inverse function. Can Somebody help me with this problem? > ***************** > $Version > 6.0 for Microsoft Windows (32-bit) (February 7, 2008) Assuming you are really just after the parameter estimates and attempting to symbolically invert the function is just a means to an end, one possibility is to define the model as a black box function that solves the equation numerically. This can be done using FindRoot. In[1]:= data = {{1, 444.6}, {3, 455.15}, {5, 464.81}, {7, 467.79}, {10, 469.01}, {15, 480.28}}; In[2]:= model[A_?NumericQ, B_?NumericQ, x_?NumericQ] := Module[{OOT}, (OOT /. FindRoot[ x == A (Exp[-B/OOT] OOT - B Gamma[0, B/OOT]), {OOT, 450, 500}])] In[3]:= FindFit[data, model[A, B, x], {{A, 7*10^13}, {B, 15000}}, x] 14 Out[3]= {A -> 3.23774 10 , B -> 15914.5} For the starting values for A and B, I took values close to those obtained by plugging the first and last data points into the equation and solving for A and B. Darren Glosemeyer Wolfram Research === Subject: Re: Fitting a inverse function from complicated integral > > I need to Fit this experimental data {x, OOT}: > > data = { > {1, 444.6}, > {3, 455.15}, > {5, 464.81}, > {7, 467.79}, > {10, 469.01}, > {15, 480.28}} > > But there is a big problem with model equation: > > x = Integrate[A*Exp[-B/T], {T, 0, OOT}, Assumptions -> A > 0 && B > 0 > && OOT > 0] > > So, after integration: > > x = A (Exp[-B/OOT] OOT - B Gamma[0, B/OOT]) > > I need to obtain a INVERSE function, i.e. OOT = f(x) and then find > (e.g. via FindFit) best fitting parameters A, B. > > I have tried Series expansion, PadeApproximant etc., but every > approximation of mentioned > model contain A*Exp[-B/T], so I cannot find inverse function. > > Can Somebody help me with this problem? Can be done by reversing data coordinates, specifying a function that only works for numeric input (to disable symbolic processing), and giving a large number of iterations. data = {{1, 444.6}, {3, 455.15}, {5, 464.81}, {7, 467.79}, {10, 469.01}, {15, 480.28}}; func[a_?NumberQ, b_?NumberQ, oot_?NumberQ] := NIntegrate[a*Exp[-b/t], {t, 0, oot}] ff = FindFit[Map[Reverse,data], func[a,b,oot], {a,b}, oot, MaxIterations->500] Or could do: xx[a_,b_,oot_] := Integrate[a*Exp[-b/t], {t,0,oot}, Assumptions->{a>0,b>0,oot>0}] ff2 = FindFit[Map[Reverse,data], xx[a,b,oot], {a,b}, oot, MaxIterations->500] Both give pretty much the same results: In[17]:= ff = FindFit[Map[Reverse,data], func[a,b,oot], {a,b}, oot, MaxIterations->500] Out[17]= {a -> 1.99859*10^11, b -> 12547.7} Here are the residuals: gg = xx /. ff; In[19]:= (gg /. OOT -> data[[All, 2]]) - data[[All, 1]] Out[19]= {0.63067, 0.282454, 1.0629, 0.29016, -2.14352, 0.410461} Daniel Lichtblau Wolfram Research === Subject: Fitting a inverse function from complicated integral I need to Fit this experimental data {x, OOT}: data = { {1, 444.6}, {3, 455.15}, {5, 464.81}, {7, 467.79}, {10, 469.01}, {15, 480.28}} But there is a big problem with model equation: x = Integrate[A*Exp[-B/T], {T, 0, OOT}, Assumptions -> A > 0 && B > 0 && OOT > 0] So, after integration: x = A (Exp[-B/OOT] OOT - B Gamma[0, B/OOT]) I need to obtain a INVERSE function, i.e. OOT = f(x) and then find (e.g. via FindFit) best fitting parameters A, B. I have tried Series expansion, PadeApproximant etc., but every approximation of mentioned model contain A*Exp[-B/T], so I cannot find inverse function. Can Somebody help me with this problem? ***************** $Version 6.0 for Microsoft Windows (32-bit) (February 7, 2008) === Subject: Re: How to put text on a curved surface? Remarkable enough I did not get sent to me all the responses . I also observed that not always my questions are in the forum -- although I have the impression they are normal. with friendly greetings, P_ter === Subject: Simple Q: How to give computed results from NSolve to a new I am new to Mathematica. And I just have a simple question for you: I have solved a system of equations by NSolve. And for instance, it returns the results as Root={{x->1,y->2}}. And now I want to use the computed results, say x & y to define a new variable Z=x^2+sqrt(xy). How should I use computed x and y to define the new variable Z? === Subject: Re: Label vertices in Graph to display with GraphPlot Hello Murray, when I take the last example in the documentation of GraphPlot3D (basic examples: the rendering) and use the following graph the labels do not show up. (the text comes from an application of Formal Concept Analysis to a consumer table for mobile phones). Anyway, they do now show up. gr1 = {Gesprekken -> Gebruik-+, Gesprekken -> Duurzaamheid-+, Gebruik-+ -> Draagbaarheid++,Gebruik-+ -> SMS-+, Gebruik-+ -> Lege knoop, Duurzaamheid-+ -> Accu++, Duurzaamheid-+ -> Lege knoop, Draagbaarheid++ -> Duurzaamheid++, Draagbaarheid++ -> SMS--, Lege knoop -> SMS--, SMS-+ -> Duurzaamheid++, SMS-+ -> 9, Lege knoop -> 9, Accu++ -> 9, Accu++ -> Gebruik+, Duurzaamheid++ -> Earth, SMS-- -> Earth, 9 -> Earth, Gebruik+ -> Earth}; === Subject: Inconsistent behavior? Binomial[n,4] yields 1/24 (-3+n) (-2+n) (-1+n) n Binomial[n,5] yields 1/120 (-4+n) (-3+n) (-2+n) (-1+n) n Binomial[n,6] yields Binomial[n,6] Binomial[n,7] yields Binomial[n,7] Is some setting doing this. Angela === Subject: same input ... different results??? hi, i'm trying to solve the following equation with mathematica. why are there different results depending on whether or not i factor x out (see the two def. for f1)? Sum[f1[n1, n2, x, m, i, j, k], {i, 0, n1}, {j, 0, n2}, {k, 0, n2 + i - j}] f1[n1_, n2_, x_, m_, i_, j_, k_] := Exp[I*2*Pi*(m/3*(n1 + n2 - i - 2 j - k) + x*(n2 + i - j - 2 k))] f1[n1_, n2_, x_, m_, i_, j_, k_] := Exp[I*2*Pi*(m/3*(n1 + n2 - i - 2 j - k) + x*n2 + x*i - x*j - 2 x*k)] and still, both results do not match the sum if i enter specific values. so there must be something wrong, but what? thx in advance. === Subject: Help with Check Function Arguments & Options I would like to thank everyone who has previously responded to my posts. Your advice has helped greatly. I have a couple of final questions. I am writing a package file and would like to do some argument and option checking if possible; that is check the number of arguments and see if there are unknown options. If my function has no options I think I can do this. f[x_,y_] := x + y f[args___] := If[Length[{args}] != 2, Message[f::argrx, f, Length[{args}], 2]; Return[$Failed]] This type of check has been posted to the message board before. My question is assume that f[x,y] has multiple options, that is Options[f] = {opt1 -> 1, opt2 -> True}, etc How do I check if the user entered the correct options? Andrew Andrew C Beveridge MS M888 Los Alamos National Laboratory Los Alamos, NM 87545 505-665-2092 e-mail: acbev@lanl.gov === Subject: Re: Solve inconsistant actions? newrent = Table[125000 E^(r 14), {r, .01, .04, .005}]; The only case with a problem (its algorithms couldn't find a solution) is Solve[#/rate == 1894000, rate] & /@ newrent // Column {{rate->0.0759156}} {} {} {{rate->0.0936555}} {} {{rate->0.107729}} {{rate->0.115541}} I find that simplifying an expression can sometimes help. Solve[Simplify[#/rate == 1894000], rate] & /@ newrent // Column {{rate->0.0759156}} {{rate->0.0814201}} {{rate->0.0873238}} {{rate->0.0936555}} {{rate->0.100446}} {{rate->0.107729}} {{rate->0.115541}} This is equivalent to what you did with Solve[# == 1894000 rate, rate] & /@ newrent Alternatively, use only exact or only approximate numbers (as in one of your examples). Hence, either Solve[Simplify[#/rate == 1894000.], rate] & /@ newrent // Column or Solve[#/rate == 1894000, rate] & /@ Rationalize[newrent, 0] // N // Column And Reduce has more robust capabilities than Solve Bob Hanlon > Can someone enlighten me as to what discriminators Solve uses in > providing some solutions while disdaining others in the attached simple > code? > > Is it an operator or Mathematica bug? I am running 6.0.1 under win xp. > > > newrent = Table[125000 [ExponentialE]^(r 14), {r, .01, .04, .005}] // N > > Table[Solve[newrent[[i]]/rate == 1894000 , rate], {i, 1, 7}] > > Table[Solve[newrent[[i]]/rate == 1894000. , rate], {i, 1, 7}] > > Table[Reduce[newrent[[i]]/rate == 1894000 , rate], {i, 1, 7}] > > Table[Solve[newrent[[i]] == 1894000 rate, rate], {i, 1, 7}] > > > > Marlyn Hicks > > mhicks@san.rr.com > > === Subject: Re: Import .xlsx files > Is Import capable of reading Excel files stored in the new MSXML file > format (.xslx)? A quick trial shows that it is not, but maybe I am > not doing something right. > > I am aware that I could write a function to dig into the .xslx as a > zip archive, retrieve the .xml files, and try to extract the cell > values, but I am lazy and hoping somebody else did that for me already. > Why don't you export to CSV instead? Excel uses an extremely complex format, not really suitable for data exchange (unless Excel is the only software used for analysing the data), while implementing a CSV reader is trivial in any general purpose language. And Mathematica reads CSVs reliably out of the box. === Subject: Re: basic questions 3,1,4 > 1,5,9 > 2,6,5 > ..,.,. Hi Markus, The following examples should be of interest. First, we build a list of points pts that contains triple made of the first twenty-four digits of pi. Then we use several built-in functions to visualize and interact with the list (or dynamically build a new list). pts = Partition[First@RealDigits[Pi, 10, 24], 3] ListPlot3D[pts] ListContourPlot@pts Manipulate[ ListContourPlot@Partition[First@RealDigits[Pi, 10, n], 3], {n, 9, 192, 3}] Animate[ListContourPlot@Partition[First@RealDigits[Pi, 10, n], 3], {n, 9, 192, 3}] Animate[ListDensityPlot[Partition[First@RealDigits[Pi, 10, n], 3], ColorFunction -> SunsetColors], {n, 9, 384, 3}] -- === Subject: Re: noob questions :) > hi everyone! > > first of all i would like to introduce myself. being an artist i am mainly engaged in the visualization of chaotic systems such as iterated function systems or strange attractors from experimental data. i consider myself a completely mathematica noob (willing to learn ::)) i got introduced to mathematica by a friend who works in the math institute at our local university (hence, that's where i spent most of my recent time ... lol). to get myself started with the project i have in mind i could use some help, which i have not found in the databases yet: > > - how can i tell mathematica to import a three-column (x,y,z) txt file and do a 3d plot from the values. i already messed with the ListPlot3D command , unfortunately to no avail. the file containing the experimental data looks something like this: > point,x,y,z > 1,34,21,45 > 2,32,53,76 > 3,12,23,43 > 4,45,21,87 > 5,65,76,87 > etc Say that you have imported (Import[...]) your experimental data into the variable impt. impt {{1, 34, 21, 45}, {2, 32, 53, 76}, {3, 12, 23, 43}, {4, 45, 21, 87}, {5, 65, 76, 87}} Since the first column of the matrix (or the first entry of each quadruple if you want) contains only a line number, we can safely discard it to keep only the {x, y, z} values. data = impt[[All, 2 ;; 4]] {{34, 21, 45}, {32, 53, 76}, {12, 23, 43}, {45, 21, 87}, {65, 76, 87}} We can, now, use ListPlot3D. ListPlot3D[data] > - how can i then tell mathematica to color certain values from this data list with a color from my choice? eg: color the values X red (X could be something like the mean value of the entire list) You could use option such as *Epilog*. -- === Subject: Re: A small syntax error causing Kernel crash, Version 6.0.1 >> Fyi; >> This below causes Kernel crash >> Solve[Integrate[f[x]*Exp[x], {x}] == 1, r] >> Mathematica 6.0.1, on XP (the {x} is the problem). >> Nasser > > I forgot to mention that one might have to run the above command 2 times to > see the crash. The first time you might not see the crash. Hi Nasser, FWIW, with Mathematica 6.0.2 on Mac OS X Leopard 1.5.2 Intel 64-bit, the kernel crashes quietly each time the above expression is being evaluated. -- === Subject: Re: A small syntax error causing Kernel crash, Version 6.0.1 On my machine (Intel MacBook Pro) running 6.0.2.1, I get an error message: Integrate::ilim : Invalid integration variable or limit(s) in {x}. ButtonBox[, BaseStyle->Link, ButtonData:>paclet:ref/message/Integrate/ilim, ButtonFrame->None, ButtonNote->Integrate::ilim] So I guess the function now knows to do nothing when the limits are not correctly specified. george > Hi Nasser, this also happens with version 6.0.2 Daniel >> Fyi; >> This below causes Kernel crash >> Solve[Integrate[f[x]*Exp[x], {x}] == 1, r] >> Mathematica 6.0.1, on XP (the {x} is the problem). >> Nasser > === Subject: Path, Get, etc. I'm trying to read in ConvexHull.m with the line << ConvexHull3D`; but it always says Get::noopen: Cannot open ConvexHull3D`. >> Checking $Path, it includes paths to several folders which definitely have a copy of ConvexHull.m, including C:Documents and SettingsAll UsersApplication DataMathematica Autoload, and there's a copy in the same folder as the file that calls it. I don't understand why the file isn't found. I'd appreciate any tips. Steve Gray === Subject: Re: Path, Get, etc. > I'm trying to read in ConvexHull.m with the line << ConvexHull3D`; but it always says Get::noopen: Cannot open ConvexHull3D`. Checking $Path, it includes paths to several folders which definitely >have a copy of ConvexHull.m, including C:Documents and SettingsAll UsersApplication DataMathematica >Autoload, and there's a copy in the same folder as the file that calls it. >I don't understand why the file isn't found. I'd appreciate any tips. Steve Gray === Subject: Re: Path, Get, etc. > I'm trying to read in ConvexHull.m with the line > > << ConvexHull3D`; but it always says > > Get::noopen: Cannot open ConvexHull3D`. >> Steve, If the package you want to load is called ConvexHull.m (no 3D in the name) then you must use the exact name of the file without its extension. Any of the following expressions should work: << ConvexHull` << ConvexHull` Needs[ConvexHull`] > Checking $Path, it includes paths to several folders which definitely > have a copy of ConvexHull.m, including > > C:Documents and SettingsAll UsersApplication DataMathematica > Autoload, If the file ConvexHull.m is located in this directory, you should not to have to load it manually since it must be already there (it is automatically loaded whenever Mathematica starts). > and there's a copy in the same folder as the file that calls it. > I don't understand why the file isn't found. I'd appreciate any tips. > > Steve Gray > HTH, -- === Subject: Re: Path, Get, etc. > I'm trying to read in ConvexHull.m with the line > > << ConvexHull3D`; but it always says > > Get::noopen: Cannot open ConvexHull3D`. > > Checking $Path, it includes paths to several folders which definitely > have a copy of ConvexHull.m, including > > C:Documents and SettingsAll UsersApplication DataMathematica > Autoload, > If you want to load ConvexHull.m, use << ConvexHull` and not << ConvexHull3D` > and there's a copy in the same folder as the file that calls it. The location of the notebook has no significance. The working directory (returned by Directory[]) is what matters. To set the working directory to the notebook's directory, use SetDirectory[NotebookDirectory[]] > I don't understand why the file isn't found. I'd appreciate any tips. === Subject: Re: Path, Get, etc. I suppose that < I'm trying to read in ConvexHull.m with the line > > << ConvexHull3D`; but it always says > > Get::noopen: Cannot open ConvexHull3D`. > > Checking $Path, it includes paths to several folders which definitely > have a copy of ConvexHull.m, including > > C:Documents and SettingsAll UsersApplication DataMathematica > Autoload, > > and there's a copy in the same folder as the file that calls it. > I don't understand why the file isn't found. I'd appreciate any tips. > > Steve Gray > === Subject: Re: Bug in ExportString? > > using FullForm on ImportString[ExportString[{1,1}, PDF], PDF] > > //FullForm it is clear that the output is quite different from the > > input: {1,1}. Is any documetation available or is this a bug? > > Daniel > > I did not formulate a good question about: > ImportString[ExportString[ , PDF], PDF] > My point is that this gives an image, while > ImportString[ExportString[t, PDF], PDF] > gives with Inputform a polygon. > I think a space is also text ( ). It has an ASCII place. So, there should be no difference in structure with the letter t. > with friendly greetings, > P_ter > Hi Peter and Daniel, Why do you think that there is a bug in ImportString or ExportString? For all of , t, or {1,1} I get a result that is an image (Graphics object) and looks the same as the input. This is what I expect. The PDF format (unless it is a tagged PDF) does not preserve the structure of text, e.g. it does not preserve spaces and newlines as characters, or the exact order of lines of text (think about multicolumn layouts). What it does preserve exactly is what the document /looks/ like. PDF readers can work around these limitations partially, and they make it possible to copy text from untagged PDFs, but the results are usually not perfect ... It is possible to extract text from PDFs with Mathematica too, but just like copying with a PDF reader, this is not very reliable ... Try ImportString[ExportString[abc, PDF], {PDF, Plaintext}]. Now try ImportString[ExportString[{1,1}, PDF], {PDF, Plaintext}] and see how { and } are mangled. I get the same result even if I export the PDF to disk and copy the text with Adobe Reader. To avoid misunderstandings caused by e.g. version differences, here's the output of the two original examples: In[1]:= ImportString[ExportString[ , PDF], PDF] // InputForm Out[1]//InputForm= {Graphics[{Thickness[0.1203858530857692]}, ImageSize -> {6., 12.}, PlotRange -> {{0., 5.75}, {0., 12.}}, AspectRatio -> Automatic]} In[2]:= ImportString[ExportString[t, PDF], PDF] // InputForm Out[2]//InputForm= {Graphics[{Thickness[0.1203858530857692], Style[{Polygon[{{2.091796875, 8.509033203125}, {4.220947265625, 8.509033203125}, {4.421722625851167, 8.451835899501459}, {4.482421875, 8.303589152176556}, {4.421722625851167, 8.156801263831468}, {4.220947265625, 8.09814453125}, {2.091796875, 8.09814453125}, {2.091796875, 5.495071589250973}, {2.108850370770762, 5.332197101756292}, {2.1600108580830497, 5.183257225422544}, {2.2452783369368614, 5.0482519602497264}, {2.364652807332199, 4.927181306237841}, {2.516930475494741, 4.827340876360347}, {2.7009075476501696, 4.75602628359071}, {2.9165840237984852, 4.713237527928927}, {3.1639599039396877, 4.698974609375}, {3.366194069710223, 4.7067809227375665}, {3.5765993348355423, 4.730199862825267}, {3.7951756993156462, 4.7692314296381015}, {4.021923163150536, 4.82387562317607}, {4.239915941290354, 4.888295938810949}, {4.4322282486852504, 4.956655871914518}, {4.5988600853352235, 5.028955422486776}, {4.739811451240271, 5.105194590527724}, {4.893894204462548, 5.1688121276143}, {5.0240478515625, 5.107528935888862}, {5.080078125, 4.963367506687742}, {5.019378875851167, 4.8262102535262645}, {4.762354584333962, 4.657900419123906}, {4.553572510003116, 4.568766279999848}, {4.291277149957441, 4.476312659593871}, {4.005271056653925, 4.3939634686778035}, {3.72535678254955, 4.335142618023468}, {3.4515343276443184, 4.299850107630867}, {3.1838036919382304, 4.2880859375}, {3.016159801260507, 4.293133587967097}, {2.8572888622951877, 4.3082765393683875}, {2.565865839501763, 4.368848344973554}, {2.309534623557955, 4.469801354315495}, {2.0882952144637645, 4.6111355673942125}, {1.9100633970030552, 4.78668620781212}, {1.7827549559596911, 4.990288499171632}, {1.706369891333673, 5.221942441472747}, {1.680908203125, 5.481648034715468}, {1.680908203125, 8.09814453125}, {0.940258124088035, 8.09814453125}, {0.7345219593567602, 8.15621760624392}, {0.67236328125, 8.305923782526751}, {0.7345219593567602, 8.450960413120136}, {0.940258124088035, 8.509033203125}, {1.680908203125, 8.509033203125}, {1.680908203125, 9.6669921875}, {1.7389812781189207, 9.867767547726167}, {1.8840181937013618, 9.928466796875}, {2.0337240849951357, 9.867767547726167}, {2.091796875, 9.6669921875}, {2.091796875, 8.509033203125}}]}, Thickness[0.1203858530857692]]}, ImageSize -> {6., 12.}, PlotRange -> {{0., 5.75}, {0., 12.}}, AspectRatio -> Automatic]} === Subject: Re: Bug in ExportString? I interpret this as: for Input PDF can only be used for pictures. The manual is rather misleading here, because it says: Stores text, fonts, images, and 2D vector graphics in a device- and resolution-independent way. We can only hope that a furure version of import will work better. Daniel >> using FullForm on ImportString[ExportString[{1,1}, PDF], PDF] >> //FullForm it is clear that the output is quite different from the >> input: {1,1}. Is any documetation available or is this a bug? >> Daniel > > > > I did not formulate a good question about: > > ImportString[ExportString[ , PDF], PDF] > > My point is that this gives an image, while > > ImportString[ExportString[t, PDF], PDF] > > gives with Inputform a polygon. > > I think a space is also text ( ). It has an ASCII place. So, there > should be no difference in structure with the letter t. > > with friendly greetings, > > P_ter > > > Hi Peter and Daniel, > > Why do you think that there is a bug in ImportString or ExportString? > For all of , t, or {1,1} I get a result that is an image (Graphics > object) and looks the same as the input. This is what I expect. > > The PDF format (unless it is a tagged PDF) does not preserve the > structure of text, e.g. it does not preserve spaces and newlines as > characters, or the exact order of lines of text (think about multicolumn > layouts). What it does preserve exactly is what the document /looks/ > like. PDF readers can work around these limitations partially, and they > make it possible to copy text from untagged PDFs, but the results are > usually not perfect ... > > It is possible to extract text from PDFs with Mathematica too, but just > like copying with a PDF reader, this is not very reliable ... Try > ImportString[ExportString[abc, PDF], {PDF, Plaintext}]. Now try > ImportString[ExportString[{1,1}, PDF], {PDF, Plaintext}] and see > how { and } are mangled. I get the same result even if I export the PDF > to disk and copy the text with Adobe Reader. > > To avoid misunderstandings caused by e.g. version differences, here's > the output of the two original examples: > > In[1]:= ImportString[ExportString[ , PDF], PDF] // InputForm > > Out[1]//InputForm= > {Graphics[{Thickness[0.1203858530857692]}, ImageSize -> {6., 12.}, > PlotRange -> {{0., 5.75}, {0., 12.}}, AspectRatio -> Automatic]} > > In[2]:= ImportString[ExportString[t, PDF], PDF] // InputForm > > Out[2]//InputForm= > {Graphics[{Thickness[0.1203858530857692], > Style[{Polygon[{{2.091796875, 8.509033203125}, {4.220947265625, > 8.509033203125}, {4.421722625851167, 8.451835899501459}, > {4.482421875, 8.303589152176556}, {4.421722625851167, > 8.156801263831468}, {4.220947265625, 8.09814453125}, > {2.091796875, 8.09814453125}, {2.091796875, 5.495071589250973}, > {2.108850370770762, 5.332197101756292}, {2.1600108580830497, > 5.183257225422544}, {2.2452783369368614, 5.0482519602497264}, > {2.364652807332199, 4.927181306237841}, {2.516930475494741, > 4.827340876360347}, {2.7009075476501696, 4.75602628359071}, > {2.9165840237984852, 4.713237527928927}, {3.1639599039396877, > 4.698974609375}, {3.366194069710223, 4.7067809227375665}, > {3.5765993348355423, 4.730199862825267}, {3.7951756993156462, > 4.7692314296381015}, {4.021923163150536, 4.82387562317607}, > {4.239915941290354, 4.888295938810949}, {4.4322282486852504, > 4.956655871914518}, {4.5988600853352235, 5.028955422486776}, > {4.739811451240271, 5.105194590527724}, {4.893894204462548, > 5.1688121276143}, {5.0240478515625, 5.107528935888862}, > {5.080078125, 4.963367506687742}, {5.019378875851167, > 4.8262102535262645}, {4.762354584333962, 4.657900419123906}, > {4.553572510003116, 4.568766279999848}, {4.291277149957441, > 4.476312659593871}, {4.005271056653925, 4.3939634686778035}, > {3.72535678254955, 4.335142618023468}, {3.4515343276443184, > 4.299850107630867}, {3.1838036919382304, 4.2880859375}, > {3.016159801260507, 4.293133587967097}, {2.8572888622951877, > 4.3082765393683875}, {2.565865839501763, 4.368848344973554}, > {2.309534623557955, 4.469801354315495}, {2.0882952144637645, > 4.6111355673942125}, {1.9100633970030552, 4.78668620781212}, > {1.7827549559596911, 4.990288499171632}, {1.706369891333673, > 5.221942441472747}, {1.680908203125, 5.481648034715468}, > {1.680908203125, 8.09814453125}, {0.940258124088035, > 8.09814453125}, {0.7345219593567602, 8.15621760624392}, > {0.67236328125, 8.305923782526751}, {0.7345219593567602, > 8.450960413120136}, {0.940258124088035, 8.509033203125}, > {1.680908203125, 8.509033203125}, {1.680908203125, 9.6669921875}, > {1.7389812781189207, 9.867767547726167}, {1.8840181937013618, > 9.928466796875}, {2.0337240849951357, 9.867767547726167}, > {2.091796875, 9.6669921875}, {2.091796875, 8.509033203125}}]}, > Thickness[0.1203858530857692]]}, ImageSize -> {6., 12.}, > PlotRange -> {{0., 5.75}, {0., 12.}}, AspectRatio -> Automatic]} > === Subject: Re: Bug in ExportString? >I did not formulate a good question about: > ImportString[ExportString[ , PDF], PDF] > My point is that this gives an image, while > ImportString[ExportString[t, PDF], PDF] > gives with Inputform a polygon. > I think a space is also text ( ). It has an ASCII place. So, there > should be no difference in structure with the letter t. Here's my take: Doing first img = First@ImportString[ExportString[ , PDF], PDF] and looking at img//InputForm shows img to be a Graphics with no displayed object but an ImageSize of {6, 12} (presumably printer's points). You can convince yourself of this by looking at: Framed[img] Compare this to imgM = First[ImportString[ExportString[M, PDF], PDF]] and imgM//InputForm shows a Graphics[] of the same size with a Polygon specification to represent the image of the character. So the form offers the prospect of doing primitive composition with something like imgList = (First@First[ImportString[ExportString[#, PDF], PDF]]) & /@ Characters[Mathematica]; Graphics[Table[Translate[imgList[[i]], {6 (i - 1), 0}], {i, Length[imgList]}]] The uniform Translate inside a Table seems to work well enough for monospaced fonts (and you can probably obfuscate the code and otherwise show off with the corresponding Nest construct), and a separate rendering of each character would seem to be a useful approach if you're on your way to mapping text onto a curved surface. The PDF I/O form evidently uses long straight lines where possible in its rendering of many popular fonts. These lines won't map properly onto a curved surface, so they'll have to be filled in with interpolated points before transformation. So the conclusions seem to be that the idiom produces consistent results with a variety of characters, but, because the returned images are the same size, compositions or typesetting probably won't look right unless you use monospaced fonts or your Translate values come . Hth, Fred Klingener === Subject: Trace'ing Gradient in FindMinimum Can I track Gradient computations in FindMinimum using Trace? Here, tr is empty though df is evaluated several times: f[x_List] := (x.x - 10)^2 df[x : {__?NumericQ}] := 4 (x.x - 10) x init = RandomReal[1, {1000}]; tr = Trace[ FindMinimum[f[x], {x, init}, Gradient -> df[x]], df[x_] -> Norm[x] ] But Tracing the evaluation of f[] is possible and yields the same as EvaluationMonitor: ev = {}; tr = ReleaseHold /@ Flatten@Trace[ FindMinimum[f[x], {x, init}, Gradient -> df[x], EvaluationMonitor :> AppendTo[ev, Norm[x]] ], f[x_] -> Norm[x]]; Here, tr == ev. It looks like FindMinimum eats the function df and doesn't ever explicitly call it, but it doesn't eat f. I am trying to resolve an error where FindMinimum immediately complains my Gradient doesn't evaluate to a vector of reals for init and returns. Placing a Print inside df shows that FindMinimum does actually call df with init and when I separately evaluate df[init], there is no problem. I know I am doing something wrong so I was hoping to figure it out with Trace on df. I would also like to learn to use Trace. Second question: Is there a way to specify that FindMinimum should not try to find symbolic derivatives and such for it's arguments other than using patterns like x:{__?NumericQ}, which probably take time to compute. It would be nice for something like f[x_ /; And@@(MatrixQ[#,NumericQ]&/@x)] not to be evaluated each iteration. Is there a global $TrustUserUnconditionally = True option? === Subject: Re: Trace'ing Gradient in FindMinimum try f[x_List] := (x.x - 10)^2 df[x : {__?NumericQ}] := (Sow[x]; 4 (x.x - 10) x) init = RandomReal[1, {3}]; Reap[FindMinimum[f[x], {x, init}, Gradient -> df[x]]] Jens > Can I track Gradient computations in FindMinimum using Trace? Here, tr > is empty though df is evaluated several times: > > f[x_List] := (x.x - 10)^2 > df[x : {__?NumericQ}] := 4 (x.x - 10) x > init = RandomReal[1, {1000}]; > > tr = > Trace[ > FindMinimum[f[x], {x, init}, Gradient -> df[x]], > df[x_] -> Norm[x] > ] > > But Tracing the evaluation of f[] is possible and yields the same as > EvaluationMonitor: > > ev = {}; > tr = > ReleaseHold /@ > Flatten@Trace[ > FindMinimum[f[x], {x, init}, Gradient -> df[x], > EvaluationMonitor :> AppendTo[ev, Norm[x]] ], > f[x_] -> Norm[x]]; > > Here, tr == ev. > > It looks like FindMinimum eats the function df and doesn't ever > explicitly call it, but it doesn't eat f. > > I am trying to resolve an error where FindMinimum immediately > complains my Gradient doesn't evaluate to a vector of reals for init > and returns. Placing a Print inside df shows that FindMinimum does > actually call df with init and when I separately evaluate df[init], > there is no problem. I know I am doing something wrong so I was hoping > to figure it out with Trace on df. I would also like to learn to use > Trace. > > Second question: Is there a way to specify that FindMinimum should not > try to find symbolic derivatives and such for it's arguments other > than using patterns like x:{__?NumericQ}, which probably take time to > compute. It would be nice for something like f[x_ /; > And@@(MatrixQ[#,NumericQ]&/@x)] not to be evaluated each iteration. Is > there a global $TrustUserUnconditionally = True option? > > === Subject: Re: question on player pro There is no compiling process...we're just dealing with regular notebooks here. Simply opening and evaluating the notebook (or using dynamic interfaces) in Player Pro should work fine. There are some limitations, but not many...we're really talking about a full Mathematica kernel. A useful table is here... http://www.wolfram.com/solutions/interactivedeployment/compare.html As an executive summary for the kinds of things I suspect you might be interested in, I'd note most specifically, that Player Pro users can not... * Type in notebooks, except in InputFields. * Use GUIKit or .NET/Link (they're simply not included in Player Pro) * Use any alternative front end to the kernel; for example, writing your own J/Link interface to the kernel. * Load plain-text packages, although .mx files and packages encoded with Encode[] are perfectly okay. Note that Premier Service subscribers get three free Player Pro license, which you may use for your own experimentation or distribute to other users as you see fit. More info about that here... http://www.wolfram.com/products/playerpro/developerkit.html If you have any other questions, ask away. I know from experience that the Player Pro concept can generate a lot of questions, since there are a lot of unusual ways people might want to use it which we may not have considered or clearly outlined in our case studies... http://www.wolfram.com/solutions/interactivedeployment/casestudies.html I'm not the best person to answer detailed licensing issues, but I'm happy to address any technical or conceptual issues. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > I have a simple question on the new Mathematica player pro. If person X, who has Mathematica, makes a Mathematica notebook (.nb > file), what are then the steps needed so that person Y can run the same > notebook if Y do not have Mathematica? Does Y need to buy player pro to run X's notebook? Or is it that only X needs to buy player pro, and use it to 'convert' or > 'compile' the notebook to a new file (what is the extension?) which I > assume will contain the Mathematica kernel in it, and send that file to > person Y. But then how will Y run it if they do not have player pro nor > Mathematica? use the free player? What about any licensing issue in sending playerpro files to someone else > to run? Nasser === Subject: a workaround for large EPS files from ContourPlot As others have noticed in previous posts, if one exports an EPS from a ContourPlot produced by Mathematica6, the result is far from being satisfactory. The EPS is one order of magnitude larger in size than the one generated by Math5 in similar situations, and displays ugly artefacts when viewed on screen. The problem comes from the fact that the plot is generated internally by a recursive method, producing a dense mesh of triangles even where the function is flat and there is a large monochromatic surface. I think this approach is incredibly inefficient, and I hope that future versions will fix this issue. In the meantime I came up with a package to heal the problem. Basically, the triangles are iteratively collapsed forming larger polygons and deleting useless segments. The function is rather slow, as a lot of complex pattern substitutions must be performed. If someone is able to make it faster, it would be great. However, it works. I experienced savings in EPS size from a factor of 5 up to 50, depending on the complexity of the initial plot. If you need an EPS of reasonable size, this is a viable workaround. I hope someone will benefit of this. Michele Ceriotti Package source code follows, the syntax is simply cp=ContourPlot[ ..... ] scp=ClearCP[cp] ***************************************************************** (* ::Package:: *) BeginPackage[ClearCP`, {Utilities`FilterOptions`,StatusBar`}] Options[ClearCP]={MaxRecursion->10000, Debug->True}; ClearCP::usage = ClearCP[contourplot,options] recursively simplify the mesh used internally to draw the fillup of the contours, reducing greatly the size of exported EPS; Begin[Private`] Module[{ patjoin,rulejoin,ruleclean,w1,w2,z1,z2,p1,p2,k1,k2, zl,pl,i,j,pair,tpair, ol,nl,ip}, patjoin=({{p2_,___,p1_},{p1_,___,p2_}}|{{___,p1_,p2_,___}, {p1_,___,p2_}}| {{p2_,___,p1_},{___,p2_,p1_,___}}|{{___,p1_,p2_,___}, {___,p2_,p1_,___}}); rulejoin={{{w1___,p1_,p2_,w2___},{z1___,p2_,p1_,z2___}}- >{w1,p1,z2,z1,p2,w2},{{w1___,p1_,p2_,w2___},{p1_,z1___,p2_}}- >{w1,p1,z1,p2,w2}, {{p2_,w1___,p1_},{z1___,p2_,p1_,z2___}}->{w1,p1,z2,z1,p2}, {{p2_,w1___,p1_},{p1_,z1___,p2_}}->{w1,p1,z1,p2}}; ruleclean={{k1___,p1_,p2_,p1_,k2___}->{k1,p1,k2}, {p1_,k1___,p1_}->{k1,p1}, {p2_,p1_,k1___,p1_}->{k1,p1}, {p1_,k1___,p1_,p2_}->{k1,p1} }; purify[l_]:=( zl=l; pl={};Replace[If[Length[zl]==1,zl, i=1;j=2; pl=Reap[ While[i1 && MatchQ[pair,patjoin], Sow[(pair/.rulejoin)]; zl=Delete[zl,{{i},{j}}];i=1;j=1;]; j++;If[j>Length[zl],i++;j=i+1] ]]; pl=Flatten[pl[[2]],1]; Join[pl,zl]//.ruleclean],{{k1__},{k2__}}->Sequence[{k1},{k2}],1] ); ]; Module[ { i,j,k,,w1,w2,w3, cl, clr,clp, clsimp, pl, plr, plp, plsimp,ppos, pnp, lpnp }, SimplifyGC[gc_GraphicsComplex,OptionsPattern[ClearCP]]:=( cl=gc[[2,2]]; clr=Union[Flatten[Cases[cl,Line[k__]:>k,Infinity]]]; clp=gc[[1,clr]]; clr=Table[clr[[i]]->i,{i,1,Length[clr]}]; clsimp=GraphicsComplex[clp,cl/.clr]; (*first simplification of polygon, we take only the relevant points*) pl=gc[[2,1]]; plr=Union[Flatten[Cases[pl,Polygon[k_List,___]:>k,Infinity]]]; plp=gc[[1,plr]]; plr=Table[plr[[i]]->i,{i,1,Length[plr]}]; (*then we collapse polygons.*) (*first we get rid of graphicsgroups*) pl=pl//. {GraphicsGroup[{Polygon[w1_List,___],Polygon[w2_List,___],w3___}]- >GraphicsGroup[{Polygon[Join[w1,w2]],w3}], GraphicsGroup[{Polygon[w1_List,___]}]->Polygon[w1]}; (*then we simplify the vertex lists of the polygons*) ppos=Position[pl,_Polygon]; Do[ pnp=pl[[Sequence@@ppos[[i]]]][[1]]; If[OptionValue[Debug]==True, Print[Simplifying contour ,i, of ,Length[ppos],. N. segs: ,Length[pnp]]]; Do[ lpnp=Length[pnp]; pnp=purify[pnp]; If[Length[pnp]==lpnp,Break[]],{j,1,OptionValue[MaxRecursion]}]; pl[[Sequence@@ppos[[i]]]]=Polygon[pnp]; ,{i,1,Length[ppos]}]; (*final removal of extra points*) plsimp=GraphicsComplex[plp,pl/.plr]; {plsimp,clsimp} ); ]; Module[{h}, ClearCP[cp__Graphics,OptionsPattern[ClearCP]]:=( cp/.(h_GraphicsComplex:> SimplifyGC[h, MaxRecursion->OptionValue[MaxRecursion],Debug->OptionValue[Debug]]) ) ] End[]; EndPackage[]; === Subject: Re: a workaround for large EPS files from ContourPlot Hi Michele, > If you need an EPS of reasonable size, this is a viable workaround. I > hope someone will benefit of this. Mathematica code :) I just read over my original code and it doesn't make much sense even to me. I've taken a closer look at your package, although I haven't yet tested against the edge cases that fail with my own FixPolygons function. I really love the debug output you do. Gives a much better user interface for cases that take a long time. After removing the StatusBar` dependence in ClearCP, I get a warning when the package is loaded but it seems to work fine. Here are the numbers on my 2.2GHz Core 2 Duo comparing your function to mine: SetDirectory@NotebookDirectory[] << FixPolygons` << ClearCP` g = ContourPlot[a^2 + b^2, {a, -10, 10}, {b, -5, 5}]; Export[polygons.pdf, g]; Show[Import[polygons.pdf]] g2 = FixPolygons@ContourPlot[ x^2 + y^2, {x, -2, 2}, {y, -1, 1}] // Timing g3 = ClearCP[ContourPlot[ x^2 + y^2, {x, -2, 2}, {y, -1, 1}], Debug -> False] // Timing My function takes 15.8606s Yours takes 106.889s Obviously this is totally dependent on the contour plot originally chosen. In my opinion, both are too slow! If it's any consolation, my original code was orders of magnitude slower than yours :) It required a complete re-write to get it useable. (Pattern matching those HUGE lists of co=F6rdinates was the problem.) I'd be interested to hear from others who may have looked at similar things. I hope we can work together to improve our respective packages. Who knows; if we do a good enough job, we may have solved Wolfram's own problem for them and they can just stick our code inside ContourPlot :) (The licence of my package was specifically chosen to allow this rather unlikely outcome.) Will === Subject: Re: a workaround for large EPS files from ContourPlot I looked more in-depth at tour code. It is definitely cleaner than mine :-). I think I understood both why your code is faster, and why it fails sometimes. I still have to come out with a solution, merging the best of the two approaches. What you do is breaking the polygons into segments, then deleting all the segments which appear more than once, then build back a closed contour. What I do is working on the polygons, merging any *couple of polygons* having a side in common. Of course this makes the pattern matching more complicated, hence the slowdown. If you look at a complicated plot simplifyed by my algorithm, and plot it prepending an EdgeForm directive so as to show the boundaries of the polygons, you'll notice that shapes with holes are in fact closed polygon, as there are always creeps connecting the outside to the inner holes. In this way, arbitrarily complicated shapes can be simplified withoud losing the holes. I don't know how this can be done with yout break and rebuild approach. I'll think to it, and in any case I'll try to make my code look more similar to yours :D. After all, I don't care too much about speed: when I need graphics for publication I can very well wait one night for simplifying and exporting. The guys at Wolfram should have much easier life, as I think we are basically trying to undo a recursive refinement they are doing themselves. After all, they just could revert to Math05 code, which was doing a pretty good job! anyway, I'll work on this and send you updates. can I use your private address, or do you know ho I can add attachments to these posts? michele === Subject: Re: a workaround for large EPS files from ContourPlot amyway, I am glad to see that others this mesh thing a bad regression in math 6. these are the thinks keeping me away from closed-source software, too bad that os mathematica alternatives don't quite compare yet to the original. sorry for the statusbar dependece, it is a package of my own to show progress in the status bar. I changed the debug option to display progress as print statements, but I forgot the dependence in the package. given your numbers, I think your package is the way to go... the size of the EPS was the same? you also mention artefacts in some cases, can you provide some example to test against? I will download your package and see if I can help in solving those. === Subject: Re: a workaround for large EPS files from ContourPlot > Basically, the triangles are iteratively > collapsed forming larger polygons and deleting useless segments. Awesome! You might be happy or annoyed to find out that I've done exactly the same thing: I think you've gone about things much differently than me; my code is also slow, but I haven't compared yours to mine yet. Hopefully with the two different techniques we'll be able to improve things. (I've found odd bugs in my output for very finely-meshed contours, so yours might be better than mine from the very beginning.) I look forward to investigating, at any rate. The output from Mathematica is simply unsuitable for use in publication graphics. Will === Subject: Documentation - what is the big secret? Given Mathematica 6 has been out for several months, why is there still no information about how to write documentation for 6? I see plenty of references to this on the web, including some on this mailing list very recently. But there seems to be no official information. I'm puzzled where there is so little information. Lin === Subject: Re: Documentation - what is the big secret? the secret is called Wolfram Workbench 1.2 .. Jens > Given Mathematica 6 has been out for several months, why is there still no > information about how to write documentation for 6? I see plenty of > references to this on the web, including some on this mailing list very > recently. But there seems to be no official information. > > I'm puzzled where there is so little information. > > Lin > > === Subject: Re: Documentation - what is the big secret? On 10 Apr, 07:16, Jens-Peer Kuska the secret is called Wolfram Workbench 1.2 .. Jens But Workbench 1.2 is no excuse for not documentating the method to produce documentation (there is a certain irony here). It is about a year ago that 6.0 was released and to leave it a year and still not have the information publically available seems bizare to me. There are 1001 tools designed specifically for creating web pages, yet many people, myself included, prefer to use a text editor and write PHP and HTML. At least give us that choice. And of course, 1.2 is not out, there is not even a link to download a beta of 1.2. === Subject: Re: Documentation - what is the big secret? > Given Mathematica 6 has been out for several months, why is there still no > information about how to write documentation for 6? I see plenty of > references to this on the web, including some on this mailing list very > recently. But there seems to be no official information. > > I'm puzzled where there is so little information. > > the secret is called Wolfram Workbench 1.2 .. > > Jens And a Google search just now for Wolfram Workbench 1.2 brought up exactly _two_ (2) hits, both of which seemed to be complaints about Mathematica's documentation, and neither of which actually pointed to Wolfram Workbench 1.2. So I guess the secret is safe! === Subject: Re: Documentation - what is the big secret? On Apr 10, 2:16 am, Jens-Peer Kuska the secret is called Wolfram Workbench 1.2 .. or the coming A WorkLife FrameWork 3.0 which I am trying to find time to get out the door :-) (http://scientificarts.com/worklife/ ) --David Jens > Given Mathematica 6 has been out for several months, why is there still = no > information about how to write documentation for 6? I see plenty of > references to this on the web, including some on this mailing list very > recently. But there seems to be no official information. > I'm puzzled where there is so little information. > Lin === Subject: Re: What is @@@? The link presented earlier in this thread, starts off with: A.2.7 Operator Input Forms Characters that are not letters, letter-like forms or structural elements are treated by Mathematica as operators. Since letters are not numbers (i.e., numerals); the formal documentation on letter-like forms makes no mention of numbers; and I don't think that numbers are structural elements (didn't look that one up, actually), does this mean that Mathematica treats 3 as an operator, so that inputs like a 3 b or a3b are taken as some kind of operator connecting a and b, or operating on b? === Subject: Pattern problem: How to count from a long list of numbers all occurrences of 2 numbers next to each others? Hello; I think using Pattern is my weakest point in Mathematica. I have this list, say this: (it is all a list of integers, no real numbers). x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} And I want to count how many say a 3 followed immediately by 3. So in the above list, there will be 4 such occurrences. And if I want to count how many 1 followed by a 3, there will be 2 such cases, etc... I tried Count[] but I do not know how to set the pattern for 3 followed by a comma followed by 3 or just 3 followed immediately by 3. I tried few things, such as the following In[68]:= Count[x, {3, 3}_] Out[68]= 0 Also tried Cases, but again, I am not to good with Patterns, so not sure how to set this up at this moment. Any ideas will be appreciated. Nasser I really need to sit down and study Patterns in Mathematica really well one day :) === Subject: Re: Pattern problem: How to count from a long list of numbers all Hi Nasser, ReplaceList does not quit what you want, but you can fix it up: Length@ReplaceList[x,{___,3,3,___}->0] hope this helps, Daniel > Hello; > > I think using Pattern is my weakest point in Mathematica. > > I have this list, say this: (it is all a list of integers, no real numbers). > > x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} > > And I want to count how many say a 3 followed immediately by 3. So in the > above list, there will be 4 such occurrences. And if I want to count how > many 1 followed by a 3, there will be 2 such cases, etc... > > I tried Count[] but I do not know how to set the pattern for 3 followed by > a comma followed by 3 or just 3 followed immediately by 3. > > I tried few things, such as the following > > In[68]:= Count[x, {3, 3}_] > Out[68]= 0 > > Also tried Cases, but again, I am not to good with Patterns, so not sure how > to set this up at this moment. > > Any ideas will be appreciated. > > Nasser > I really need to sit down and study Patterns in Mathematica really well one > day :) > > === Subject: Re: Pattern problem: How to count from a long list of numbers all no patterns Count[Partition[x, 2, 1], {3, 3}] will do it Jens > Hello; > > I think using Pattern is my weakest point in Mathematica. > > I have this list, say this: (it is all a list of integers, no real numbers). > > x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} > > And I want to count how many say a 3 followed immediately by 3. So in the > above list, there will be 4 such occurrences. And if I want to count how > many 1 followed by a 3, there will be 2 such cases, etc... > > I tried Count[] but I do not know how to set the pattern for 3 followed by > a comma followed by 3 or just 3 followed immediately by 3. > > I tried few things, such as the following > > In[68]:= Count[x, {3, 3}_] > Out[68]= 0 > > Also tried Cases, but again, I am not to good with Patterns, so not sure how > to set this up at this moment. > > Any ideas will be appreciated. > > Nasser > I really need to sit down and study Patterns in Mathematica really well one > day :) > > === Subject: Re: Pattern problem: How to count from a long list of numbers all > Hello; > > I think using Pattern is my weakest point in Mathematica. > > I have this list, say this: (it is all a list of integers, no real numbers). > > x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} > > And I want to count how many say a 3 followed immediately by 3. So in the > above list, there will be 4 such occurrences. And if I want to count how > many 1 followed by a 3, there will be 2 such cases, etc... This is something that patterns are paticularly *not* suited for. Patterns don't work for these kinds of things because a pattern will always be tested against a single expression at a time. Of course there is __, ___, and .., but these are used as part of a larger pattern, which is tested against single expressions only. (Actualy this is not strictly true when matching with Flat, OneIdentity or Orderless functions ... I don't understand completely how those work ...) For example, it is not possible to get the __ pattern to match more than one expression when used on its own (and not as part of a larger pattern at a deeper level). However, there does exist a way to accomplish this with patterns. The trick is to count in how many different ways can the {___, 3, 3, ___} pattern match the entire list: In[1]:= x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} Out[1]= {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} In[2]:= ReplaceList[x, {___, 3, 3, ___} -> Null] Out[2]= {Null, Null, Null, Null} In[3]:= Length[%] Out[3]= 4 > > I tried Count[] but I do not know how to set the pattern for 3 followed by > a comma followed by 3 or just 3 followed immediately by 3. > > I tried few things, such as the following > > In[68]:= Count[x, {3, 3}_] > Out[68]= 0 {3,3}_ means {3,3} * _ Note that even in a pattern written as x_, it is _ that matches something (it can match any single expression), and not x. x is just a name used to refer to the expression that matches _ > > Also tried Cases, but again, I am not to good with Patterns, so not sure how > to set this up at this moment. > > Any ideas will be appreciated. > > Nasser > I really need to sit down and study Patterns in Mathematica really well one > day :) Here are two alternative ways (without patterns): Count[Partition[x, 2, 1], {3, 3}] === Subject: Re: Pattern problem: How to count from a long list of numbers all > Hello; I think using Pattern is my weakest point in Mathematica. I have this list, say this: (it is all a list of integers, no real numbers). x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} And I want to count how many say a 3 followed immediately by 3. So in the > above list, there will be 4 such occurrences. And if I want to count how > many 1 followed by a 3, there will be 2 such cases, etc... I tried Count[] but I do not know how to set the pattern for 3 followed by > a comma followed by 3 or just 3 followed immediately by 3. I tried few things, such as the following In[68]:= Count[x, {3, 3}_] > Out[68]= 0 Also tried Cases, but again, I am not to good with Patterns, so not sure how > to set this up at this moment. Any ideas will be appreciated. Nasser > I really need to sit down and study Patterns in Mathematica really well one > day :) I don't think you can solve this problem using only Count with a pattern. The pattern only gets to look at one element at a time. You can set things up using Partition, though. In[20]:= x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} Out[20]= {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} In[21]:= Partition[x, 2, 1] Out[21]= {{1, 3}, {3, 3}, {3, 3}, {3, 2}, {2, 3}, {3, 3}, {3, 1}, {1, 3}, {3, 3}} Now you can count how many times {3,3} occurs: In[32]:= Count[Partition[x, 2, 1], {3, 3}] Out[32]= 4 If you wanted to count how many times any element is repeated, you could do In[33]:= Count[Partition[x, 2, 1], {y_, y_}] Out[33]= 4 Jason === Subject: Re: Pattern problem: How to count from a long list of numbers all > Hello; I think using Pattern is my weakest point in Mathematica. I have this list, say this: (it is all a list of integers, no real numbers). x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} And I want to count how many say a 3 followed immediately by 3. So in the > above list, there will be 4 such occurrences. And if I want to count how > many 1 followed by a 3, there will be 2 such cases, etc... I tried Count[] but I do not know how to set the pattern for 3 followed by > a comma followed by 3 or just 3 followed immediately by 3. I tried few things, such as the following In[68]:= Count[x, {3, 3}_] > Out[68]= 0 Also tried Cases, but again, I am not to good with Patterns, so not sure how > to set this up at this moment. Any ideas will be appreciated. Hi Nasser, the following way uses Partition... In[1]:= x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3}; In[4]:= y = Partition[x, 2, 1] Out[4]= {{1, 3}, {3, 3}, {3, 3}, {3, 2}, {2, 3}, {3, 3}, {3, 1}, {1, 3}, {3, 3}} In[5]:= Count[y, {3, 3}] Out[5]= 4 In[6]:= Count[y, {1, 3}] Out[6]= 2 Oleksandr Nasser > I really need to sit down and study Patterns in Mathematica really well one > day :) === Subject: Linking mathematica graphs It is usual to paste mathematica graphs in MS Word. Lots of programs are able to embed their graphics in word as an OLE object (Origin,Excel) in MS Word. Is it possible in mathematica? === Subject: Re: Linking mathematica graphs > > It is usual to paste mathematica graphs in MS Word. Lots of programs are able to embed their graphics in word as an OLE object (Origin,Excel) in MS Word. Is it possible in mathematica? > > No, it is not. You can copy graphics as metafile and paste them into Word. For some types of graphics the quality might be reduced, but it works pretty well in Mathematica version 6. (It works in earlier versions too, but the results are not as pretty ...) === Subject: Frametick Orientation (2 Questions) I'm plotting a stackedbarchart with some large numbers on the x-axis of the frame. Right now they are all jammed in horizontally. How do I get a slanted orientation? Second question: How do I get the Frameticks to show outside the frame rather than inside? Is it possible to only do this on one side? === Subject: Re: Frametick Orientation (2 Questions) it can be done, but the implementation in mathematica is complicated and not really bug free. Therefore, it is not satisfying. Slanted labels: StackedBarChart[{{1,1,1},{1,1,1},{1,2,3}},BarLabels->{Graphics@Text[Style[ asasasasa,Medium],{-10,-0},{0,0},{.5,.5}]}] Ticks outside: StackedBarChart[{{1,1,1},{1,1,1},{1,2,3}},Ticks->{{},{{1,label1,{-.01,0} },{2,label2,{-.01,0}},{3,label3,{-.01,0}},{4,label4,{-.01,0}}}}] hope this helps, Daniel > I'm plotting a stackedbarchart with some large numbers on the x-axis of the frame. Right now they are all jammed in horizontally. How do I get a slanted orientation? > > Second question: How do I get the Frameticks to show outside the frame rather than inside? Is it possible to only do this on one side? > > === Subject: Re: ListCorrelate on lists with different sampling rates I've been beating my head against this problem (only half an hour at a > time, though, which may well be my mistake) for a little while now, and was > wondering if people had some input. I'm basically looking at the cross-correlation (or sliding dot-product) of > two sampled (discrete) signals---one a drive signal and one a received > signal---to pick out various features. I'm doing this using Mathematica's > ListCorrelate, which is working admirably, and I can easily pick out echoes > and so on. However, my question concerns what to do when the sampled signals have > different time scales. As I understand it, the ListCorrelate function really > only works (for this application) when the input lists are one-dimensional. > If the sampling rates are different, I can go ahead and (for example) > resample the higher-sample-rate signal (via interpolation) to the same rate > as the lower-sample-rate signal, and then perform the ListCorrelation. It > seems to me, though, that I'm sort of throwing away some information that I > don't need to in the resampling procedure. Is that the recommended procedure, or is there something more clever I can > do? Curtis Osterhoudt > cfo@remove_this.lanl.and_this.gov > PGP Key ID: 0x4DCA2A10 > Please avoid sending me Word or PowerPoint attachments > Seehttp://www.gnu.org/philosophy/no-word-attachments.html Interpolate the data sampled at the lower rate up to the higher rate? === Subject: Re: ListCorrelate on lists with different sampling rates Hi Curtis, downsampling will lead to aliasing (folding of high frequencies to low frequencies) if your original signal contains high frequencies. Therefore, either you are sure that your signal contains no high frequencies or you should apply a low pass filter before downsampling. Upsampling by an integer factor can be done by introducing zeros and applying a low pass filter. Downsampling by a integer factor can be done by low pass filtering and decimation. Sample rate changes by a rational factor can be done by first upsampling, then downsampling. All this stuff can be found in many books about digital signal processing. hope this helps, Daniel > > I've been beating my head against this problem (only half an hour at a > time, though, which may well be my mistake) for a little while now, and was > wondering if people had some input. > > I'm basically looking at the cross-correlation (or sliding dot-product) of > two sampled (discrete) signals---one a drive signal and one a received > signal---to pick out various features. I'm doing this using Mathematica's > ListCorrelate, which is working admirably, and I can easily pick out echoes > and so on. > > However, my question concerns what to do when the sampled signals have > different time scales. As I understand it, the ListCorrelate function really > only works (for this application) when the input lists are one-dimensional. > If the sampling rates are different, I can go ahead and (for example) > resample the higher-sample-rate signal (via interpolation) to the same rate > as the lower-sample-rate signal, and then perform the ListCorrelation. It > seems to me, though, that I'm sort of throwing away some information that I > don't need to in the resampling procedure. > > Is that the recommended procedure, or is there something more clever I can > do? > > Curtis Osterhoudt > cfo@remove_this.lanl.and_this.gov > PGP Key ID: 0x4DCA2A10 > Please avoid sending me Word or PowerPoint attachments > See http://www.gnu.org/philosophy/no-word-attachments.html > === Subject: Re: Problems with recursive function frank > Hello Frank, try this: > > test[0, _] = test[0] = test0 > > test[0, foo] > > >> I'm in trouble with a recursive function. the functios looks similar to >> test[a_, b_] := test[a - 1, b]*b. A is the index b should just be an >> argument of test. >> for any calculation i need to tell mathematica the first value of the >> function, e.g. test[0, 5]=5. The problem is the following: the first >> object is independent of b. does anyone know a way to tell mathematica >> the following thing: >> test[0,b]=5 => test[0]=5 regardless to b. >> Frank > > === Subject: Re: Problems with recursive function hi daniel, for. You?re right, it would be better, to store each intermediate value. frank > Hi Frank, > > if I understand correctly, you need to define a recursion with a stop > > criterion. You can do this by e.g.: > > test[0,_]:=5; > > test[n_,b_]:=test[n-1,b] b; > > test[10,5] > > if you have many calculations, it may be advantageously to store > > intermediate results: > > test[n_,b_]:=test[n-1,b]=test[n-1,b] b; > > hope this helps, Daniel > > > > > > >> I'm in trouble with a recursive function. the functios looks similar to > >> test[a_, b_] := test[a - 1, b]*b. A is the index b should just be an > >> argument of test. > >> for any calculation i need to tell mathematica the first value of the > >> function, e.g. test[0, 5]=5. The problem is the following: the first > >> object is independent of b. does anyone know a way to tell mathematica > >> the following thing: > > >> test[0,b]=5 => test[0]=5 regardless to b. > > > > >> Frank > > > > === Subject: Re: Problems with recursive function > I'm in trouble with a recursive function. the functios looks similar to > test[a_, b_] := test[a - 1, b]*b. A is the index b should just be an > argument of test. > for any calculation i need to tell mathematica the first value of the > function, e.g. test[0, 5]=5. The problem is the following: the first > object is independent of b. does anyone know a way to tell mathematica > the following thing: > > test[0,b]=5 => test[0]=5 regardless to b. Hi Franck, You were almost there: just use the blank pattern (single underscore) in place of b. In the example below, I have added a test to prevent infinite recursion and also memoization to improve performances (in case of). Clear[test] test[a_Integer?Positive, b_] := test[a, b] = test[a - 1, b]*b test[0, _] = test[0] = 5; test[0] (* returns 5 *) test[0, 3] (* returns 5 *) test[2, 3] (* returns 45 *) test[0, 1, 2, 3] (* returns unevaluated test[0, 1, 2, 3] *) test[3] (* returns unevaluated test[3] *) test[-1, 3] (* returns unevaluated test[-1, 3] *) -- === Subject: Re: Filling problem in Plot3D Filling in 3D appears to work only if filling to a value is specified and not filling to another surface. One method might be to fill both surfaces to a constant intermediate value but that introduces an extra plane surface at the intermediate value! Plot3D[{.3 + .3 x, 2 + Sin[x y]}, {x, 0, 1}, {y, 0, 1}, BoxRatios -> 1, Mesh -> False, PlotStyle -> RGBColor[0, 1, 0, .5], PlotRange -> {{0, 1}, {0, 1}, {0, Automatic}}, PlotRangePadding -> 0.1, FillingStyle -> {RGBColor[1, 0, 0, .5]}, Filling -> {1 -> 1, 2 -> 1}] So there seems to be a lack of functionality in filling between two surfaces. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ consider the following 3D graphic in v6, with two surfaces: Plot3D[{.3, .7}, {x, 0, 1}, {y, 0, 1}, > BoxRatios -> 1, > Mesh -> False, > PlotStyle -> RGBColor[0, 1, 0, .5], > PlotRange -> {{0, 1}, {0, 1}, {0, 1}}, > FillingStyle -> {RGBColor[1, 0, 0, .5]}, > Filling -> {1 -> {2}} > ] There should be some filling between the two surfaces, but no filling > is displayed at all. > Of course I can fill with Filling -> {1 -> .7}, but what if the target > surface is not planar? > Any suggestions? Version: 6.0 for Microsoft Windows (32-bit) Istvan Zachar > === Subject: Re: Filling problem in Plot3D Hi Istavan, in my experience Filling for 3 D is either pretty bad described or pretty buggy (or both to say it nice). If you want to display regions between surfaces, you are better off with RegionPlot. Here an example: RegionPlot3D[0.3z>0.7x ,{x,0,1},{y,0,1},{z,0,1}] hope this helps, Daniel > > consider the following 3D graphic in v6, with two surfaces: > > Plot3D[{.3, .7}, {x, 0, 1}, {y, 0, 1}, > BoxRatios -> 1, > Mesh -> False, > PlotStyle -> RGBColor[0, 1, 0, .5], > PlotRange -> {{0, 1}, {0, 1}, {0, 1}}, > FillingStyle -> {RGBColor[1, 0, 0, .5]}, > Filling -> {1 -> {2}} > ] > > There should be some filling between the two surfaces, but no filling > is displayed at all. > Of course I can fill with Filling -> {1 -> .7}, but what if the target > surface is not planar? > Any suggestions? > > Version: 6.0 for Microsoft Windows (32-bit) > > Istvan Zachar > === Subject: Re: Just primitive ColorFunction > I think, that it must be something very simple, but I cannot find the > solution.... I need to fill the Plot so, that area above the axis will be red and ar= ea > below the axis will be blue. I tried it in a such way: Plot[Sin[x], {x, 0, 4 Pi} , > AxesOrigin -> {0, 0}, > Axes -> {True, True}, > PlotStyle -> Thick, > ColorFunction - If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]], > Filling -> Axis, > ImageSize -> {380, 280}] But Mathematica says, that If is not a valid Color. If I try it with Function (according to examples in ColorFunction help)= , ColorFunction - Function[x, If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]]], it is working, but the color of Filling is red allover the range. > Jakub Although others have given you a simpler solution to your particular problem, I thought it was worthwhile to fix your approach because it is obviously more general: Plot[Sin[x], {x, 0, 4 Pi}, AxesOrigin -> {0, 0}, Axes -> {True, True}, PlotStyle -> Thick, ColorFunction -> Function[{x, y}, If[y >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]]], Filling -> Axis, ImageSize -> {380, 280}, ColorFunctionScaling -> False] Without the option ColorFunctionScaling -> False, the {x,y} values are scaled 0-1 across the plot, regardless of the actual coordinates (seems a strange default to me!). David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Just primitive ColorFunction You could also use: Plot[Sin[x], {x, 0, 4 Pi}, AxesOrigin -> {0, 0}, Axes -> {True, True}, PlotStyle -> Thick, ColorFunction -> (If[Sin[#] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]] &), Filling -> Axis, ImageSize -> {380, 280}, ColorFunctionScaling -> False, FillingStyle -> Automatic] Note that the output will be much bigger since VertexColors are generated for each vertex. Also, segments crossing the x axis will have end vertices of different colors, so some color bleeding will occur. This kind of plots are useful to represent spectrum coloring as in: Plot[Sin[x], {x, 0, 4 Pi}, AxesOrigin -> {0, 0}, Axes -> {True, True}, PlotStyle -> Thick, ColorFunction -> (ColorData[VisibleSpectrum][ 380 + # (750 - 380)] &), Filling -> Axis, ImageSize -> {380, 280}, ColorFunctionScaling -> True, FillingStyle -> Automatic] -Ulises Cervantes WRI === Subject: Re: Just primitive ColorFunction > You could also use: > > Plot[Sin[x], {x, 0, 4 Pi}, AxesOrigin -> {0, 0}, Axes -> {True, True}, > PlotStyle -> Thick, > ColorFunction -> (If[Sin[#] >= 0, RGBColor[1, 0, 0], > RGBColor[0, 0, 1]] &), Filling -> Axis, ImageSize -> {380, 280}, > ColorFunctionScaling -> False, FillingStyle -> Automatic] > > Note that the output will be much bigger since VertexColors are > generated for each vertex. Also, segments crossing the x axis will > have end vertices of different colors, so some color bleeding will > occur. > What is a good way to avoid this colour bleeding problem? If we want to colour only the lines (but use no fillings), then this looks very ugly: Plot[Sin[x], {x, 0, 4 Pi}, PlotStyle -> Thick, ColorFunction -> (If[Sin[#] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]] &), ColorFunctionScaling -> False] One solution I found is the following: Plot[Sin[x], {x, 0, 4 Pi}, PlotStyle -> Thick, ColorFunction -> (If[Sin[#] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]] &), ColorFunctionScaling -> False, Exclusions -> {Pi, 2 Pi, 3 Pi}] But Exclusions was not designed for this. I am not confortable using it because I am afraid that it might skip a section of the curve as with Exclusions -> {Sin[x] == 0}. 1. Is there a more appropriate way to force Plot to calculate the function value at certain points? 2. Is there a way to avoid having to find the zeros of the function manually? (More generally: avoid having to calculate the points where the colouring changes abruptly.) Szabolcs Horv.87t === Subject: Re: Just primitive ColorFunction > I think, that it must be something very simple, but I cannot find the > solution.... > > I need to fill the Plot so, that area above the axis will be red and area > below the axis will be blue. Jakub, The option you need is *FillingStyle*. For instance, Plot[Sin[x], {x, 0, 4 Pi}, PlotStyle -> Thick, Filling -> Axis, FillingStyle -> {Blue, Red}] -- === Subject: Re: Just primitive ColorFunction Plot[Sin[x], {x, 0, 4 Pi}, ColorFunction -> (If[#2 > 0, Red, Blue] &), ColorFunctionScaling -> False, Filling -> Axis] Plot[Sin[x], {x, 0, 4 Pi}, FillingStyle -> {Blue, Red}, Filling -> Axis] Bob Hanlon > I think, that it must be something very simple, but I cannot find the > solution.... I need to fill the Plot so, that area above the axis will be red and area > below the axis will be blue. I tried it in a such way: Plot[Sin[x], {x, 0, 4 Pi} , > AxesOrigin -> {0, 0}, > Axes -> {True, True}, > PlotStyle -> Thick, > ColorFunction - If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]], > Filling -> Axis, > ImageSize -> {380, 280}] But Mathematica says, that If is not a valid Color. If I try it with Function (according to examples in ColorFunction help), ColorFunction - Function[x, If[Sin[x] >= 0, RGBColor[1, 0, 0], RGBColor[0, 0, 1]]], it is working, but the color of Filling is red allover the range. > Jakub === Subject: Re: How does NETLink find MathKernel.exe? >So...how does NETLink find MathKernel.exe? .NET/Link is provided with source code, which is very useful for determining implementation details like this. The code that finds MathKernel.exe is getDefaultLaunchString() in NativeLink.cs. Chris Hill Wolfram Research === Subject: How does NETLink find MathKernel.exe? I have a program that uses .NETLink to fire up a Mathematica Kernel to do calculations. The NETLink .dll sits next to the program's executable. On most of the machines I've run the program on, everything runs fine, but on one of our machines, NETLink doesn't automatically find the location of the MathKernel.exe file. I am having a heck of a time figuring out from the documentation how NETLink usually finds the location of this executable...but maybe I'm just blind. The documentation says that NETLink will automatically use the most recently installed instance of Mathematica, and I've seen reference in some of the forums to a registry key specifying the location, but I haven't been able to find which registry key that is by either browsing forums or comparing the registry of the problem machine with one that works. So...how does NETLink find MathKernel.exe? === Subject: A Problem with Simplify I have the following rather simple integral of two sines, which should evaluate to zero if m is not equal to n and to L/2 if they are the same. The following is just fine Imn = Simplify[Integrate[ Sin[(m*Pi*x)/L]* Sin[(n*Pi*x)/L], {x, 0, L}]] However, if I specify that m and n are integers, I only get the general solution of zero, i.e. when m and n are not equal. Imn = Simplify[Integrate[ Sin[(m*Pi*x)/L]* Sin[(n*Pi*x)/L], {x, 0, L}], Element[m, Integers] && Element[n, Integers]] The workaround is obvious in this case, but shouldn't mma give multiple answers? Perhaps something similar to what it already does with Integrate? Kevin -- Kevin J. McCann Research Associate Professor JCET/Physics Physics Building University of Maryland, Baltimore County 1000 Hilltop Circle Baltimore, MD 21250 === Subject: Re: A Problem with Simplify > Recently I also have found another strange bug in Simplfy (not so > dangerous): > FullSimplify[Sin[x]*Cos[x]] > gives Sin[x]*Cos[x] instead Sin[2*x]/2. The workaround is > FullSimplify[2*Sin[x]*Cos[x]]/2 This is not a bug! In[7]:= LeafCount[Sin[x]*Cos[x]] Out[7]= 5 In[8]:= LeafCount[Sin[2*x]/2] Out[8]= 8 In other words, Sin[x] Cos[x] is considered simpler by Simplify than Sin[2*x]/2, that's all. Indeed: In[9]:= Simplify[Sin[2*x]/2] Out[9]= Cos[x]*Sin[x] If you want Simplify to return Sin[2*x]/2 use a different complexity functions: Simplify[Sin[x]*Cos[x], ComplexityFunction -> (LeafCount[#1] + 10*Count[#1, _Cos, Infinity] & )] (1/2)*Sin[2*x] And, by the way, your other bug is also not a bug. A basic principle worth remembering: just because something seems wrong to you does not mean it is wrong. Andrzej Kozlowski === Subject: Re: A Problem with Simplify the problem is Integrate[] and not simplify because Integrate[Sin[(n*Pi*x)/L]*Sin[(n*Pi*x)/L], {x, 0, L}] is different from Integrate[Sin[(m*Pi*x)/L]*Sin[(n*Pi*x)/L], {x, 0, L}] and Mathematica should integrate twice. Jens > I have the following rather simple integral of two sines, which should > evaluate to zero if m is not equal to n and to L/2 if they are the same. > > The following is just fine > > Imn = Simplify[Integrate[ > Sin[(m*Pi*x)/L]* > Sin[(n*Pi*x)/L], > {x, 0, L}]] > > > However, if I specify that m and n are integers, I only get the > general solution of zero, i.e. when m and n are not equal. > > Imn = Simplify[Integrate[ > Sin[(m*Pi*x)/L]* > Sin[(n*Pi*x)/L], > {x, 0, L}], > Element[m, Integers] && > Element[n, Integers]] > > The workaround is obvious in this case, but shouldn't Mathematica give multiple > answers? Perhaps something similar to what it already does with Integrate? > > Kevin === Subject: Re: A Problem with Simplify > I have the following rather simple integral of two sines, which should > evaluate to zero if m is not equal to n and to L/2 if they are the same. That's right, assuming also that m and n are integers. > The following is just fine Imn = Simplify[Integrate[Sin[(m*Pi*x)/L]*Sin[(n*Pi*x)/L], {x, 0, L}]] Is it really just fine? The result of Integrate (on which Simplify has no effect here) is (L*n*Cos[n*Pi]*Sin[m*Pi] - L*m*Cos[m*Pi]*Sin[n*Pi])/(m^2*Pi - n^2*Pi) That result is indeed fine if m and n are different, but it is Indeterminate, which is surely not what you want, when m and n are equal. > However, if I specify that m and n are integers, I only get the > general solution of zero, i.e. when m and n are not equal. Imn = Simplify[Integrate[Sin[(m*Pi*x)/L]*Sin[(n*Pi*x)/L], {x, 0, L}], > Element[m, Integers] && Element[n, Integers]] The workaround is obvious in this case, but shouldn't Mathematica give multiple > answers? Perhaps something similar to what it already does with > Integrate? The reason that the above gave simply 0 is that, for integer m and n, the numerator is 0 and In[5]:= 0/x Out[5]= 0 _irrespective_ of x (which, for all we know, might be 0). Note that getting 0 for Out[5] did not even require an invocation of Simplify. But I do have a solution for your problem, assuming that you're using version 6, which introduced the function Sinc. Let's consider an indefinite integral: An antiderivative of Sin[p x] Sin[q x] wrt x is x/2 (Sinc[(p - q) x] - Sinc[(p + q) x]) _regardless_ of whether p and q are different or the same. Of course, it's easy then to use that antiderivative to evaluate your definite integral. It's L/2 (Sinc[(m - n) Pi] - Sinc[(m + n) Pi]) which is valid regardless of whether m and n are integer or whether they are equal or not. If you're interested in reading more about how Sinc can be used in such applications at David W. Cantrell === Subject: Re: A Problem with Simplify This seems to be very strange: Mathematica 6.0 for Microsoft Windows (32-bit) Copyright 1988-2008 Wolfram Research, Inc. In[1]:= Imn = Integrate[Sin[(m*Pi*x)/L]*Sin[(n*Pi*x)/L], {x, 0, L}]; In[2]:= Imn // InputForm Out[2]//InputForm= (L*n*Cos[n*Pi]*Sin[m*Pi] - L*m*Cos[m*Pi]*Sin[n*Pi])/ (m^2*Pi - n^2*Pi) In[3]:= Simplify[Imn, Assumptions -> n == m] L n Cos[n Pi] Sin[m Pi] - L m Cos[m Pi] Sin[n Pi] Simplify::infd: Expression ------------------------------------------------- simplified to 2 2 m Pi - n Pi Indeterminate. Out[3]= Indeterminate But: In[4]:= Integrate[Sin[(n*Pi*x)/L]*Sin[(n*Pi*x)/L], {x, 0, L}] // InputForm Out[4]//InputForm= (L*(2 - Sin[2*n*Pi]/(n*Pi)))/4 This is a bug! :( Recently I also have found another strange bug in Simplfy (not so dangerous): FullSimplify[Sin[x]*Cos[x]] gives Sin[x]*Cos[x] instead Sin[2*x]/2. The workaround is FullSimplify[2*Sin[x]*Cos[x]]/2. > I have the following rather simple integral of two sines, which should > evaluate to zero if m is not equal to n and to L/2 if they are the same. The following is just fine Imn = Simplify[Integrate[ > Sin[(m*Pi*x)/L]* > Sin[(n*Pi*x)/L], > {x, 0, L}]] > However, if I specify that m and n are integers, I only get the > general solution of zero, i.e. when m and n are not equal. Imn = Simplify[Integrate[ > Sin[(m*Pi*x)/L]* > Sin[(n*Pi*x)/L], > {x, 0, L}], > Element[m, Integers] && > Element[n, Integers]] The workaround is obvious in this case, but shouldn't Mathematica give multiple > answers? Perhaps something similar to what it already does with Integrate? Kevin > -- Kevin J. McCann > Research Associate Professor > JCET/Physics > Physics Building > University of Maryland, Baltimore County > 1000 Hilltop Circle > Baltimore, MD 21250 === Subject: Re: A Problem with Simplify dangerous): > FullSimplify[Sin[x]*Cos[x]] > gives Sin[x]*Cos[x] instead Sin[2*x]/2. The workaround is > FullSimplify[2*Sin[x]*Cos[x]]/2. This is not a bug, indeed. As a rule of thumb, *FullSimplify* tries to minimize the leaf count of the expression. For the case above, the original expression sin(x)cos(x) has a leaf count of 5 whereas the trigonometric identity sin(2x)/2 has a leaf count of 8. Therefore, *FullSimplify* returns the original form sin(x)cos(x) since it is deemed as simpler than sin(2x)/2 w.r.t. the lead count of each expression. Note that, in general, you can modify/tweak this default behavior to suit your needs by witting your own *ComplexityFunction*. However, when dealing with trigonometric expressions (especially when looking for some trigonometric identities) it is usually better and less cumbersome to use *TrigReduce* and the like (*TrigExpand*, *TrigFactor*, etc.). FullSimplify[Sin[x]*Cos[x]] (* returns Cos[x] Sin[x] *) % // LeafCount (* returns 5 *) TrigReduce[Sin[x]*Cos[x]] (* returns 1/2 Sin[2 x] *) % // LeafCount (* returns 8 *) LeafCount[Cosh[x] - Sinh[x]] (* returns 7 *) FullSimplify[Cosh[x] - Sinh[x]] (* returns E^-x *) % // LeafCount (* returns 5 *) -- === Subject: Re: A Problem with Simplify Hi Kevin, the culprit is Integrate not Simplify. In the manual one finds: For indefinite integrals, Integrate tries to find results that are correct for almost all values of parameters. I think this to be a trap for the unwary. hope this helps, Daniel > I have the following rather simple integral of two sines, which should > evaluate to zero if m is not equal to n and to L/2 if they are the same. > > The following is just fine > > Imn = Simplify[Integrate[ > Sin[(m*Pi*x)/L]* > Sin[(n*Pi*x)/L], > {x, 0, L}]] > > > However, if I specify that m and n are integers, I only get the > general solution of zero, i.e. when m and n are not equal. > > Imn = Simplify[Integrate[ > Sin[(m*Pi*x)/L]* > Sin[(n*Pi*x)/L], > {x, 0, L}], > Element[m, Integers] && > Element[n, Integers]] > > The workaround is obvious in this case, but shouldn't Mathematica give multiple > answers? Perhaps something similar to what it already does with Integrate? > > Kevin === Subject: exporting to multiple sheets in XLS format Is there a way to export to multiple worksheets in excel XLS format=3F When importing, you can choose which sheet to import from, for example: Import[sample.xls,{Data,2}] will import the data fields from worksheet 2. However, is there a way to do the same sort of thing with export=3F Or even better, write to many worksheets all at once (in the same XLS object ) or the ability to append worksheets to already created XLS document. === Subject: Re: Special Characters in Vista >> It seems so strange that you literally have to adjust system >> permissions >> in order save Special Language Characters in Windows Vista. Yes, I = >> know >> some people have grown weary of the all of the fretting over the >> Vista >> Operating System: http://www.youtube.com/watch?v=Vje5LVSJYQI >> But Still!!! >> Sylvia Hobbs > Think XP in the short term, and Ubuntu in the medium term! David Bailey > http://www.dbaileyconsultancy.co.uk For long term, just buy a Mac :) J=E1nos ---------------------------------------------- Trying to argue with a politician is like lifting up the head of a corpse. (S. Lem: His Master Voice) === Subject: Re: Special Characters in Vista > It seems so strange that you literally have to adjust system permissions > in order save Special Language Characters in Windows Vista. Yes, I know > some people have grown weary of the all of the fretting over the Vista > Operating System: http://www.youtube.com/watch?v=Vje5LVSJYQI > > Sylvia Hobbs > Think XP in the short term, and Ubuntu in the medium term! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Pattern problem: How to count from a long list of numbers >Hello; I think using Pattern is my weakest point in Mathematica. I have this list, say this: (it is all a list of integers, no real numbers). x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} And I want to count how many say a 3 followed immediately by 3. So in the >above list, there will be 4 such occurrences. And if I want to count how >many 1 followed by a 3, there will be 2 such cases, etc... I tried Count[] but I do not know how to set the pattern for 3 followed by >a comma followed by 3 or just 3 followed immediately by 3. I tried few things, such as the following In[68]:= Count[x, {3, 3}_] >Out[68]= 0 Also tried Cases, but again, I am not to good with Patterns, so not sure how >to set this up at this moment. Any ideas will be appreciated. Nasser >I really need to sit down and study Patterns in Mathematica really well one >day :) > If you have long lists and would like this to be very quick, I would do this by basically finding out the locations of the first and second elements, and seeing where the two line up. Here is a function that will do this: pairCount[data_, p1_, p2_] := Total @ BitAnd[ Clip[Clip[Most[data], {p1, p1}, {p1 - 2, p1 - 2}], {p1 - 1, p1 - 1}, {0, 1}], Clip[Clip[Rest[data], {p2, p2}, {p2 - 2, p2 - 2}], {p2 - 1, p2 - 1}, {0, 1}] ] A couple examples: In[146]:= pairCount[{1, 3, 3, 3, 2, 3, 3, 1, 3, 3}, 3, 3] Out[146]= 4 In[147]:= pairCount[{1, 3, 3, 3, 2, 3, 3, 1, 3, 3}, 1, 3] Out[147]= 2 Carl Woll Wolfram Research === Subject: Re: Pattern problem: How to count from a long list of numbers all occurrences of 2 numbers next to each others? I think this will work: ls = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} Total[ReplaceList[ls, {___, 3, 3, ___} -> 1]] 4 Total[ReplaceList[ls, {___, 1, 3, ___} -> 1]] 2 etc. Andrzej Kozlowski > Hello; I think using Pattern is my weakest point in Mathematica. I have this list, say this: (it is all a list of integers, no real > numbers). x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} And I want to count how many say a 3 followed immediately by 3. So > in the > above list, there will be 4 such occurrences. And if I want to count > how > many 1 followed by a 3, there will be 2 such cases, etc... I tried Count[] but I do not know how to set the pattern for 3 > followed by > a comma followed by 3 or just 3 followed immediately by 3. I tried few things, such as the following In[68]:= Count[x, {3, 3}_] > Out[68]= 0 Also tried Cases, but again, I am not to good with Patterns, so not > sure how > to set this up at this moment. Any ideas will be appreciated. Nasser > I really need to sit down and study Patterns in Mathematica really > well one > day :) === Subject: Re: Pattern problem: How to count from a long list of numbers all occurrences of 2 numbers next to each others? Hello Nasser, This is not the most elegant solution, but it works: Count[Thread[List[x, RotateLeft[x]]], {1, 3}] which would be convenient to write as a function CountMySeq[x_List, a_Integer, b_Integer] := Count[Thread[List[x, RotateLeft[x]]], {a,b}] To see what is going on here: x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} RotateLeft[x] is {3, 3, 3, 2, 3, 3, 1, 3, 3, 1} Thread[List[x,RotateLeft[x]]] is {{1,3}, {3,3}, etc] > Hello; I think using Pattern is my weakest point in Mathematica. I have this list, say this: (it is all a list of integers, no real > numbers). x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} And I want to count how many say a 3 followed immediately by 3. So in the > above list, there will be 4 such occurrences. And if I want to count how > many 1 followed by a 3, there will be 2 such cases, etc... I tried Count[] but I do not know how to set the pattern for 3 followed > by > a comma followed by 3 or just 3 followed immediately by 3. I tried few things, such as the following In[68]:= Count[x, {3, 3}_] > Out[68]= 0 Also tried Cases, but again, I am not to good with Patterns, so not sure > how > to set this up at this moment. Any ideas will be appreciated. Nasser > I really need to sit down and study Patterns in Mathematica really well > one > day :) > -- W. Craig Carter === Subject: Re: need help >> But the problem is, that for some numbers you need more than 4 squares: >> 96=9^2+3^2+2^2+1^2+1^2 A very famous theorem of Lagrange says that every positive integer is > a sum of at most 4 squares. This result can be found in virtually > every book on number theory (e.g. see K. Chandrasekharan, > Introduction to Analytic number theory). In the case of 96 we have PowersRepresentations[96, 4, 2] > {{0, 4, 4, 8}} in other words 96 = 0^2+4^2+4^2+8^2 so in fact you only need 3 squares. Of course if you allow more > squares you will get more representations: PowersRepresentations[96, 5, 2] > {{0, 0, 4, 4, 8}, {1, 1, 2, 3, 9}, {1, 1, 3, 6, 7}, > {1, 3, 5, 5, 6}, {2, 2, 4, 6, 6}, {2, 3, 3, 5, 7}} Also, the question of finding just one representation without > restriction on length is trivial since you can represent any number as > a sum of squares of 1's ! Andrzej Kozlowski You are right, I used a very bad algorithm and so I could not find a solution for even 96. But I think he want to use the function PowersRepresentations like that: Sumf[x_] := ( data = PowersRepresentations[x, 4, 2][[1]]; If[data[[1]] == 1, data[[1]] = 1]; If[data[[2]] == 1, data[[2]] = 1]; If[data[[3]] == 1, data[[3]] = 1]; If[data[[4]] == 1, data[[4]] = 1]; Row[{data[[1]]^2, data[[2]]^2, data[[3]]^2, data[[4]]^2}, +] ) And here is my better function: --------------------------------------------------- Sumf[x_] := ( s = x; m = x; s1 = x; s = m; While[ IntegerQ[Sqrt[s1]] == False, s1-- ]; s -= s1; s2 = s; While[ IntegerQ[Sqrt[s2]] == False, s2-- ]; s -= s2; s3 = s; While[ IntegerQ[Sqrt[s3]] == False, s3-- ]; s -= s3; s4 = s; While[ IntegerQ[Sqrt[s4]] == False, s4-- ]; s -= s4; While[ s != 0, { s2--; If[s2 == 0, {s1--, s2 = m - s1}]; s = m; While[ IntegerQ[Sqrt[s1]] == False, s1--]; s -= s1; While[ IntegerQ[Sqrt[s2]] == False, s2-- ]; s -= s2; s3 = s; While[ IntegerQ[Sqrt[s3]] == False, s3-- ]; s -= s3; s4 = s; While[ IntegerQ[Sqrt[s4]] == False, s4-- ]; s -= s4; } ] If[s1 == 1, s1 = 1, s1 = Sqrt[s1]]; If[s2 == 1, s2 = 1, s2 = Sqrt[s2]]; If[s3 == 1, s3 = 1, s3 = Sqrt[s3]]; If[s4 == 1, s4 = 1, s4 = Sqrt[s4]]; Print[Row[{s1^2, s2^2, s3^2, s4^2}, +], Remainder:, s, number: , x] ) ----------------------------------------------- I have tested it from 0 -10000 and only the number 7168 could not be expressed. I hope this could help. Patrick Klitzke === Subject: Re: need help > But the problem is, that for some numbers you need more than 4 squares: > 96=9^2+3^2+2^2+1^2+1^2 >> A very famous theorem of Lagrange says that every positive integer is >> a sum of at most 4 squares. This result can be found in virtually >> every book on number theory (e.g. see K. Chandrasekharan, >> Introduction to Analytic number theory). In the case of 96 we have >> PowersRepresentations[96, 4, 2] >> {{0, 4, 4, 8}} >> in other words >> 96 = 0^2+4^2+4^2+8^2 >> so in fact you only need 3 squares. Of course if you allow more >> squares you will get more representations: >> PowersRepresentations[96, 5, 2] >> {{0, 0, 4, 4, 8}, {1, 1, 2, 3, 9}, {1, 1, 3, 6, 7}, >> {1, 3, 5, 5, 6}, {2, 2, 4, 6, 6}, {2, 3, 3, 5, 7}} >> Also, the question of finding just one representation without >> restriction on length is trivial since you can represent any number as >> a sum of squares of 1's ! >> Andrzej Kozlowski > You are right, I used a very bad algorithm and so I could not find a > solution for even 96. > But I think he want to use the function PowersRepresentations like that: > Sumf[x_] := ( > data = PowersRepresentations[x, 4, 2][[1]]; > If[data[[1]] == 1, data[[1]] = 1]; > If[data[[2]] == 1, data[[2]] = 1]; > If[data[[3]] == 1, data[[3]] = 1]; > If[data[[4]] == 1, data[[4]] = 1]; > Row[{data[[1]]^2, data[[2]]^2, data[[3]]^2, data[[4]]^2}, > +] > ) Patrick, Just a side note: a more compact version of the function above could be written with *HoldForm* as in Sumf[x_Integer] := Row[First[PowersRepresentations[x, 4, 2]]^HoldForm[2], +] -- === Subject: Re: need help > But the problem is, that for some numbers you need more than 4 > squares: > 96=9^2+3^2+2^2+1^2+1^2 A very famous theorem of Lagrange says that every positive integer is a sum of at most 4 squares. This result can be found in virtually every book on number theory (e.g. see K. Chandrasekharan, Introduction to Analytic number theory). In the case of 96 we have PowersRepresentations[96, 4, 2] {{0, 4, 4, 8}} in other words 96 = 0^2+4^2+4^2+8^2 so in fact you only need 3 squares. Of course if you allow more squares you will get more representations: PowersRepresentations[96, 5, 2] {{0, 0, 4, 4, 8}, {1, 1, 2, 3, 9}, {1, 1, 3, 6, 7}, {1, 3, 5, 5, 6}, {2, 2, 4, 6, 6}, {2, 3, 3, 5, 7}} Also, the question of finding just one representation without restriction on length is trivial since you can represent any number as a sum of squares of 1's ! Andrzej Kozlowski === Subject: Re: need help Here is my solution for the function for any number of squares. Sumf[x_] := ( data = {}; s = x; s1 = x; i = 0; While[ s != 0, { s1 = s; While[MatchQ[Sqrt[s1], _Integer] == False, s1--]; i++; If[s1 == 1, AppendTo[data, 1^2], AppendTo[data, Sqrt[s1]^2]]; s -= s1; } ]; Row[data, +] ) By solving this problem I learned a lot of about how mathematica works. Patrick Klitzke email: philologos14@gmx.de === Subject: max and min How I can to obtain the maximum and minimum values in a function like a Sin, but that varying their frequency with the time. Ary -- For more information please visit http://linux.bitdefender.com/ === Subject: Re: max and min And, If instead of a function I have a List?, how I can to use the FindMaximum?. Ary > Your question is a bit difficult to interpret. Sin[x y] has maxmin = > {-1,1} > for x and y reals. > However, I believe this example my help you out. It will find some of > the > maxima, but not all. FindMaximum[(1 + Sin[x y])/(2 + Cos[y]), {{x, 1}, {y, 2}}] Here x and y will be real numbers. To find all max/min--inima, you could take derivatives symbolically and > Solve symbolically > How I can to obtain the maximum and minimum values in a function like a >> Sin, but that varying their frequency with the time. >> Ary >> -- >> For more information please visit http://linux.bitdefender.com/ > -- > W. Craig Carter > -- For more information please visit http://linux.bitdefender.com/ === Subject: Re: max and min > And, If instead of a function I have a List?, how I can to use the > FindMaximum?. For a list, assuming I have correctly understood your question, you should use *Max* (or *Min*). For instance, lst = {1, -2, 7, 3, 8, 2, -9, 5}; Max[lst] (* returns 8 *) -- === Subject: Re: max and min the Max[Sin[_]] is always 1 and the Min[Sin[_]] is always -1 independent of the frequency. Jens > > How I can to obtain the maximum and minimum values in a function like a > Sin, but that varying their frequency with the time. > > > Ary > > > === Subject: JLink Problem, Fixed More or Less Several months ago I reported a problem with Jlink that has become rampant on University-owned and home computers since approximately December or January. Basically what happens is that some / most of the time when launching Mathematica, Mathematica will hang, and eventually pops up an error about failing to connect to Jlink. Usually you can ignore the message and go on, but sometimes worse things happen unless you restart Mathematica. We have also had problems with Mathematica hanging when trying to open up the Documentation Center (though I think the Documentation Center issue may be a bit better with the 6.0.2 release). We never saw the Jlink problem until we began switching machines from Norton Antivirus to NOD32 in December/January, at which time the problem became rampant, even on quite speedy new machines. We were hightly suspicious that the problem was related to NOD32, but WRI Tech Support never was able to tell us what the issue was or how to fix it, and several people from WRI assured us that NOD32 was not the culprit. Well finally, the whole thing had become so aggravating that we tried temporarily disabling NOD32 on a few test machines. What we found was that the problem stopped when NOD32 was disabled, and returned when NOD32 was turned back on. We then tried adding the Mathematica installation directory to the NOD32 exclusions, which seems to fix the problem. All's well that ends well I guess, and I suppose we should have trusted our own instincts about NOD32 and tested it ourselves far sooner than this. -- Helen Read University of Vermont === Subject: Re: JLink Problem, Fixed More or Less > Several months ago I reported a problem with Jlink that has become > rampant on University-owned and home computers since approximately > December or January. Basically what happens is that some / most of the > time when launching Mathematica, Mathematica will hang, and eventually > pops up an error about failing to connect to Jlink. Usually you can > ignore the message and go on, but sometimes worse things happen unless > you restart Mathematica. We have also had problems with Mathematica > hanging when trying to open up the Documentation Center (though I think > the Documentation Center issue may be a bit better with the 6.0.2 release). > > We never saw the Jlink problem until we began switching machines from > Norton Antivirus to NOD32 in December/January, at which time the problem > became rampant, even on quite speedy new machines. We were hightly > suspicious that the problem was related to NOD32, but WRI Tech Support > never was able to tell us what the issue was or how to fix it, and > several people from WRI assured us that NOD32 was not the culprit. > > Well finally, the whole thing had become so aggravating that we tried > temporarily disabling NOD32 on a few test machines. What we found was > that the problem stopped when NOD32 was disabled, and returned when > NOD32 was turned back on. We then tried adding the Mathematica > installation directory to the NOD32 exclusions, which seems to fix the > problem. > > All's well that ends well I guess, and I suppose we should have trusted > our own instincts about NOD32 and tested it ourselves far sooner than this. > Great - I am glad that issue is resolved - anti virus software is inevitably very invasive because of the problem it is meant to combat. Many years ago, the company for which I worked received reports that one of our programs contained a virus. After a great deal of hassle, it turned out that the anti-virus software in question had tested just three bytes at the start of one file, and deduced that it had an infection! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: JLink Problem, Fixed More or Less Interesting. Here we have a related problem without the locking up of Mathematica. Every time a user uses F1 to get help a strange JLink error message hpops up, often in a super large font that eventually reverts to its usual. Happily I have ignored this without ill effect. It is annoying though. Kevin > Several months ago I reported a problem with Jlink that has become > rampant on University-owned and home computers since approximately > December or January. Basically what happens is that some / most of the > time when launching Mathematica, Mathematica will hang, and eventually > pops up an error about failing to connect to Jlink. Usually you can > ignore the message and go on, but sometimes worse things happen unless > you restart Mathematica. We have also had problems with Mathematica > hanging when trying to open up the Documentation Center (though I think > the Documentation Center issue may be a bit better with the 6.0.2 release). > > We never saw the Jlink problem until we began switching machines from > Norton Antivirus to NOD32 in December/January, at which time the problem > became rampant, even on quite speedy new machines. We were hightly > suspicious that the problem was related to NOD32, but WRI Tech Support > never was able to tell us what the issue was or how to fix it, and > several people from WRI assured us that NOD32 was not the culprit. > > Well finally, the whole thing had become so aggravating that we tried > temporarily disabling NOD32 on a few test machines. What we found was > that the problem stopped when NOD32 was disabled, and returned when > NOD32 was turned back on. We then tried adding the Mathematica > installation directory to the NOD32 exclusions, which seems to fix the > problem. > > All's well that ends well I guess, and I suppose we should have trusted > our own instincts about NOD32 and tested it ourselves far sooner than this. > -- Kevin J. McCann Research Associate Professor JCET/Physics Physics Building University of Maryland, Baltimore County 1000 Hilltop Circle Baltimore, MD 21250 === Subject: Re: JLink Problem, Fixed More or Less > Interesting. Here we have a related problem without the locking up of > Mathematica. Every time a user uses F1 to get help a strange JLink error > message hpops up, often in a super large font that eventually reverts to its > usual. Happily I have ignored this without ill effect. It is annoying > though. > > Kevin > >> Several months ago I reported a problem with Jlink that has become >> rampant on University-owned and home computers since approximately >> December or January. Basically what happens is that some / most of the >> time when launching Mathematica, Mathematica will hang, and eventually >> pops up an error about failing to connect to Jlink. Usually you can >> ignore the message and go on, but sometimes worse things happen unless >> you restart Mathematica. We have also had problems with Mathematica >> hanging when trying to open up the Documentation Center (though I think >> the Documentation Center issue may be a bit better with the 6.0.2 release). >> We never saw the Jlink problem until we began switching machines from >> Norton Antivirus to NOD32 in December/January, at which time the problem >> became rampant, even on quite speedy new machines. We were hightly >> suspicious that the problem was related to NOD32, but WRI Tech Support >> never was able to tell us what the issue was or how to fix it, and >> several people from WRI assured us that NOD32 was not the culprit. >> Well finally, the whole thing had become so aggravating that we tried >> temporarily disabling NOD32 on a few test machines. What we found was >> that the problem stopped when NOD32 was disabled, and returned when >> NOD32 was turned back on. We then tried adding the Mathematica >> installation directory to the NOD32 exclusions, which seems to fix the >> problem. >> All's well that ends well I guess, and I suppose we should have trusted >> our own instincts about NOD32 and tested it ourselves far sooner than this. > I would install Mathematica on a clean Windows machine, and check that it is glitch free, and then add back the other software piece by piece - starting with the antivirus code. I use J/Link a lot, and I have never seen any of these startup glitches, so I guess WRI were in the same state of unawareness when they decided it was safe enough to use for essential tasks such as displaying help! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Event when clicking one of many Disks in a Pane Can someone help me figure out how to use EventHandler to evaluate an expression when one of many Disk[] objects in a Graphics Pane is clicked. For example suppose I create a red and green disk in a graphic: Graphics[{Red, Disk[{1, 1}, 0.5], Green, Disk[{2, 2}, 0.5]}] Each disk is a separate and editable object in the graphics pane. Can I therefore associate an Event with a Mouseclick on each disk? To make matters simple lets say the disk change color from Red to Yellow and Green to Brown. Robert Prince-Wright Houston TX, 77006 USA __________________________________________________ Do You Yahoo!? http://mail.yahoo.com === Subject: Re: Event when clicking one of many Disks in a Pane Hi Robert, here is an example with 2 Disks: colorDisk[pos_,col1_,col2_]:=DynamicModule[{col=col1}, EventHandler[Graphics[{Dynamic[col],Disk[pos]}],{MouseClicked:>(col=col/ .{col1->col2,col2->col1})}]]; Grid[{{colorDisk[{0,0},Red,Green],colorDisk[{2,0},Blue,Magenta]}}] hope this helps, Daniel > Can someone help me figure out how to use EventHandler > to evaluate an expression when one of many Disk[] > objects in a Graphics Pane is clicked. > > For example suppose I create a red and green disk in a > graphic: > > Graphics[{Red, Disk[{1, 1}, 0.5], Green, Disk[{2, 2}, > 0.5]}] > > Each disk is a separate and editable object in the > graphics pane. Can I therefore associate an Event with > a Mouseclick on each disk? To make matters simple lets > say the disk change color from Red to Yellow and Green > to Brown. > > > > > Robert Prince-Wright > Houston > TX, 77006 > USA > > __________________________________________________ > Do You Yahoo!? > http://mail.yahoo.com > === Subject: Re: Event when clicking one of many Disks in a Pane (* I have two suggestions for you: Button[] and Mouseover[] *) (* First using Button[] and Dynamic[] *) even1 = True; even2 = True; Graphics[{ Button[{Dynamic[If[even1, Red, Yellow]], Disk[{1, 1}, 0.5]}, even1 = Not[even1]], Button[{Dynamic[If[even2, Green, Brown]], Disk[{2, 2}, 0.5]}, even2 = Not[even2]] }] (* Second using Mouseover[]. It is not exactly what you asked for, but it might be useful for you *) Mouseover[ Graphics[{Red, Disk[{1, 1}, 0.5]}], Graphics[{Yellow, Disk[{1, 1}, 0.5]}] ] (* I hope it helps *) (* Jose *) (* Mexico *) -----Mensaje original----- De: robert prince-wright [mailto:robertprincewright@yahoo.com] Enviado el: Jueves, 10 de Abril de 2008 01:15 a.m. Para: mathgroup@smc.vnet.net Asunto: Event when clicking one of many Disks in a Pane Can someone help me figure out how to use EventHandler to evaluate an expression when one of many Disk[] objects in a Graphics Pane is clicked. For example suppose I create a red and green disk in a graphic: Graphics[{Red, Disk[{1, 1}, 0.5], Green, Disk[{2, 2}, 0.5]}] Each disk is a separate and editable object in the graphics pane. Can I therefore associate an Event with a Mouseclick on each disk? To make matters simple lets say the disk change color from Red to Yellow and Green to Brown. Robert Prince-Wright Houston TX, 77006 USA __________________________________________________ Do You Yahoo!? http://mail.yahoo.com === Subject: Re: Event when clicking one of many Disks in a Pane InDiskTest[pos_, Disk[c_, r_]] := Sqrt[#.#] &[pos - c] < r InDisk[pos : {_?NumericQ, _?NumericQ}, disks : {_Disk ..}] := Position[disks, d_Disk /; InDiskTest[pos, d]] DynamicModule[{disks, pos = {}, k, where = {}, shape}, disks = {Disk[{1, 1}, 0.5], Disk[{2, 2}, 0.5]}; EventHandler[ Dynamic[shape = disks; If[where =!= {}, k = where[[1, 1]]; shape[[k]] = shape[[k]] /. Disk -> Circle ]; Graphics[{MapThread[List, {{Red, Green}, shape}]}]], { MouseDown :> (where = InDisk[MousePosition[Graphics], disks]) } ] ] ?? Jens > Can someone help me figure out how to use EventHandler > to evaluate an expression when one of many Disk[] > objects in a Graphics Pane is clicked. > > For example suppose I create a red and green disk in a > graphic: > > Graphics[{Red, Disk[{1, 1}, 0.5], Green, Disk[{2, 2}, > 0.5]}] > > Each disk is a separate and editable object in the > graphics pane. Can I therefore associate an Event with > a Mouseclick on each disk? To make matters simple lets > say the disk change color from Red to Yellow and Green > to Brown. > > > > > Robert Prince-Wright > Houston > TX, 77006 > USA > > __________________________________________________ > Do You Yahoo!? > http://mail.yahoo.com > === Subject: Re: What is @@@? >The link presented earlier in this thread, >A.2.7 Operator Input Forms >Characters that are not letters, letter-like forms or structural >elements are treated by Mathematica as operators. >Since letters are not numbers (i.e., numerals); the formal >documentation on letter-like forms makes no mention of numbers; >and I don't think that numbers are structural elements (didn't >look that one up, actually), does this mean that Mathematica treats >3 as an operator, so that inputs like >a 3 b or a3b >are taken as some kind of operator connecting a and b, or operating >on b? No, Mathematica does not treat the 3 in either expression above as some kind of operator. The comments you quote above doesn't apply to a3b since this is a string of characters covered by other parts of the documentation covering naming rules. And in the case of a 3 b, the operator is the space character, i.e., the implied multiplication not the 3. Again, there are other parts of the documentation covering what is regarded as a number, expression, variable etc that takes precedence over the portion you quoted. === Subject: Re: What is @@@? >A.2.7 Operator Input Forms > >Characters that are not letters, letter-like forms or structural >elements are treated by Mathematica as operators. > >So Mathematica treats 3 as an operator??? > > No, Mathematica does not treat the 3 in either expression > above as some kind of operator. . . . . . . . . . . . there are > other parts of the documentation covering what is regarded as a > number, expression, variable etc that takes precedence over the > portion you quoted. Look, after using Mathematica extensively since, literally, version 1.0, I know full well that 3 is not an operator! But, it sure seems to me that the quote given above unambiguously implies that it is -- otherwise the sentence would have (and could have, and should have) said something like Characters that are not letters, NUMBERS, letter-like forms, or structural elements are treated by Mathematica as operators. This is, after all, supposedly Wolfram's precise, detailed, absolutely complete and accurate documentation for its product -- right? This branch of this thread started with my query about where in the documentation I could learn about all the non-alphameric operators that are so ubiquitous, and confusing, in Mathematica. I use and understand some of these; I know that I don't know all of them; I would like to have a brief overview (3 or 4 pages max) giving a quick list of all of them (or least the most important of them) and a brief (few sentence), so that I might learn what the rest of them are, and perhaps improve my skills. I was pointed to Section A 2.7. It doesn't really do what I want -- and seems to be inaccurate (or at least imprecise) to boot. Finally, you mention precedence for Mathematica's documentation. Precedence implies _precedence rules_ (otherwise it's meaningless). So, if you'll pardon a little sarcasm: Where in the Mathematica documentation are these precedence rules for the Mathematica documentation itself given? My bottom lines: 1) Writing totally precise, complete, detailed, absolutely accurate _reference_ documentation, of the sort needed by experts, for any system as massive and complex as Mathematica, is very hard -- a very difficult task. Wolfram works hard, I believe, at providing this kind of reference documentation -- as they more or less have to -- but don't do a perfect job, as the opening sentence of A 2.7 illustrates in an admittedly pretty minor way. 2) Writing less precise, less complete, much shorter, simpler, less detailed, and very differently organized and structured _user_ documentation, for the benefit of beginners and/or ordinary non-expert users of a system like Mathematica is at least equally hard -- in fact, perhaps an even more difficult task. Wofram has thus far, at least in my view, _totally_ failed at performing this task and providing this kind of _user-oriented_ documentation for version 6.0; and deserves severe criticism for this failure. Their product is superb and in many ways amazing. But the ordinary user oriented documentation that they provide for it is not so much lousy as essentially nonexistent -- and I can't believe they've done this. === Subject: Directory of Mathematica Add-Ons Is there a directory of available Mathematica Add-Ons (including commercial ones) anywhere? I'm looking for productive ways to advertise our own commercial Mathematica Add-On for time-frequency analysis: http://www.ffconsultancy.com/products/CWT/?mma If we can sell that product more effectively then I'd like to create more add-ons for Mathematica in the future... -- Dr Jon D Harrop, Flying Frog Consultancy http://www.ffconsultancy.com/products/?u === Subject: Re: Directory of Mathematica Add-Ons Contact the Wolfram Partnerships group... http://partnerships.wolfram.com/ --David > Is there a directory of available Mathematica Add-Ons (including commercia= l > ones) anywhere? I'm looking for productive ways to advertise our own commercial Mathematic= a > Add-On for time-frequency analysis: http://www.ffconsultancy.com/products/CWT/?mma If we can sell that product more effectively then I'd like to create more > add-ons for Mathematica in the future... -- > Dr Jon D Harrop, Flying Frog Consultancyhttp://www.ffconsultancy.com/produ= cts/?u === Subject: Re: Directory of Mathematica Add-Ons > Is there a directory of available Mathematica Add-Ons (including commercial > ones) anywhere? I'm looking for productive ways to advertise our own commercial Mathematica > Add-On for time-frequency analysis: http://www.ffconsultancy.com/products/CWT/?mma If we can sell that product more effectively then I'd like to create more > add-ons for Mathematica in the future... -- > Dr Jon D Harrop, Flying Frog Consultancyhttp://www.ffconsultancy.com/products/?u This product sounds very ionteresting, but does it work with V6.0 of Mathematica. This was unclear from your link. Gary === Subject: Re: Pattern problem: How to count from a long list of x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3}; Count[Partition[x, 2, 1], {3, 3}] 4 Count[Partition[x, 2, 1], {1, 3}] 2 Bob Hanlon > Hello; > > I think using Pattern is my weakest point in Mathematica. > > I have this list, say this: (it is all a list of integers, no real numbers). > > x = {1, 3, 3, 3, 2, 3, 3, 1, 3, 3} > > And I want to count how many say a 3 followed immediately by 3. So in the > above list, there will be 4 such occurrences. And if I want to count how > many 1 followed by a 3, there will be 2 such cases, etc... > > I tried Count[] but I do not know how to set the pattern for 3 followed by > a comma followed by 3 or just 3 followed immediately by 3. > > I tried few things, such as the following > > In[68]:= Count[x, {3, 3}_] > Out[68]= 0 > > Also tried Cases, but again, I am not to good with Patterns, so not sure how > to set this up at this moment. > > Any ideas will be appreciated. > > Nasser > I really need to sit down and study Patterns in Mathematica really well one > day :) > > === Subject: Re: Frametick Orientation (2 Questions) Dh, your example works but it just puts the same value at each point. Here's an example that doesn't work for me. I want the FrameTick values to be oriented vertically rather than horizontally. arbitrary = {3, 5, 9, 12, 5, 4, 2}; StackedBarChart[arbitrary, Frame -> True, FrameLabel -> {None, Frequency, None, None}, LabelStyle -> {FontFamily -> Helvetica, FontSize -> 10}, BarStyle -> {Black, Gray, Gray}, BarSpacing -> 0, BarEdges -> False, FrameTicks -> {{{1, -0.1216}, {2, -0.1013}, {3, -0.0810}, {4, -0.0607}, {5, -0.0403}, {6, -0.0200}, {7, 0.0003}}, Automatic, None, None}, FrameTicksStyle -> {FontFamily -> Helvetica, FontSize -> 8}, PlotRange -> {Automatic, {0.00, 16}}, ImageSize -> 500] === Subject: Re: Frametick Orientation (2 Questions) Hi Ouadad, I tried to make the example simple and gave only one label. If you want several labels, you must specify them like e.g.: StackedBarChart[{{1,1,1},{1,1,1},{1,2,3}},BarLabels-> {Graphics@Text[Style[text1,Medium],{-10,-0},{0,0},{.5,.5}], Graphics@Text[Style[text2,Medium],{-10,-0},{0,0},{.5,.5}], Graphics@Text[Style[text3,Medium],{-10,-0},{0,0},{.5,.5}]}] hope this helps, Daniel > Dh, your example works but it just puts the same value at each point. > > Here's an example that doesn't work for me. I want the FrameTick values to be oriented vertically rather than horizontally. > > arbitrary = {3, 5, 9, 12, 5, 4, 2}; > StackedBarChart[arbitrary, Frame -> True, > FrameLabel -> {None, Frequency, None, None}, > LabelStyle -> {FontFamily -> Helvetica, FontSize -> 10}, > BarStyle -> {Black, Gray, Gray}, BarSpacing -> 0, BarEdges -> False, > FrameTicks -> {{{1, -0.1216}, {2, -0.1013}, {3, -0.0810}, {4, > -0.0607}, {5, -0.0403}, {6, -0.0200}, {7, 0.0003}}, > Automatic, None, None}, > FrameTicksStyle -> {FontFamily -> Helvetica, FontSize -> 8}, > PlotRange -> {Automatic, {0.00, 16}}, ImageSize -> 500] > === Subject: ContourPlot, etc.: not every point a Real I just discovered something a little strange and hoped someone here might be able to shed some light on the matter. (I'm using Mathematica 6.0.1.) Take this following code. It defines a function and uses it in a contour plot; the trick is that every value is intercepted on the way through (I use this in ColorbarPlot to extract max/min values): fn := #1^3 + #2^2 & everyNonReal = {}; Eval[x__] := Module[{val = Evaluate@fn@x}, If[Head@val =!= Real, AppendTo[everyNonReal, val]]; val] ContourPlot[Eval[x, y], {x, -2, 2}, {y, -2, 2}] Union@everyNonReal If every evaluation of fn resulted in a Real (as I would expect), then the output should be {} as the if statement would never evaluate. But there's a point in there that's *not* being evaluated, as you can see. What's going on? Working around this problem results in an extra If statement for every single evaluated point, a state of affairs I'm not so fond of. Will === Subject: Re: ContourPlot, etc.: not every point a Real Hi Will, ContourPlot first calls Eval with symbolic arguments in order to check if it can simplify the expression. This is done to improve speed. You can suppress this, by specifying that the arguments must be numeric, e.g.: Eval[x__?NumericQ] take care to clear first the old definitions of Eval. hope this helps, Daniel > > I just discovered something a little strange and hoped someone here > might be able to shed some light on the matter. (I'm using Mathematica 6.0.1.) > > Take this following code. It defines a function and uses it in a > contour plot; the trick is that every value is intercepted on the way > through (I use this in ColorbarPlot to extract max/min values): > > fn := #1^3 + #2^2 & > everyNonReal = {}; > Eval[x__] := Module[{val = Evaluate@fn@x}, > If[Head@val =!= Real, AppendTo[everyNonReal, val]]; val] > ContourPlot[Eval[x, y], {x, -2, 2}, {y, -2, 2}] > Union@everyNonReal > > If every evaluation of fn resulted in a Real (as I would expect), then > the output should be {} as the if statement would never evaluate. But > there's a point in there that's *not* being evaluated, as you can see. > > What's going on? Working around this problem results in an extra If > statement for every single evaluated point, a state of affairs I'm not > so fond of. > > Will > === Subject: Product Silly beginner's question: is there a function to multiply all elements of a list, like Total does for addition? 'fraid I can't find it. TIA === Subject: Re: Product Hi Steven, Times@@list will do. Daniel > Silly beginner's question: is there a function to multiply all elements of a > list, like Total does for addition? > 'fraid I can't find it. > TIA > > === Subject: Re: Product > Silly beginner's question: is there a function to multiply all elements of a > list, like Total does for addition? > 'fraid I can't find it. > TIA Hallo Steven, Apply[Times, {a, b, c}] will do. It works not only for Times, but for any function f: Apply[f, {a, b, c}] gives f[a, b, c] Apply[Plus, {a, b, c}] gives a + b + c Udo === Subject: Re: Product > Silly beginner's question: is there a function to multiply all elements of a > list, like Total does for addition? No, there isn't. But it would be redundant anyway because it is very easy to build your own: In[1]:= Times @@ {1, 2, 3, 4, 5} Out[1]= 120 Look up Apply in the documentation. === Subject: Appearance of DendrogramPlot I am finding that the leaves of my DendrogramPlot are too short: Example: Needs[HierarchicalClustering`] DendrogramPlot[{1, 2, 10, 4, 8, -100, -101, -102}, LeafLabels -> (# &), Orientation -> Left] I am getting the lowest level clusters are not being resolved graphically. -- W. Craig Carter === Subject: Re: pdf and accents I am on a Mac, so I go to System Preferences -> International -> Input Menu, and I check in U.S. Extended. For that keyboard the script is Unicode. Then I check a little checkbox that says: Show input menu in menu bar. Then on my menubar on the top of the screen I can select U.S.Extended. I see that there is no Unicode script fro Hungarian, and net even for Sweedish on the Mac - I am still using 10.4.11 -, but there is for Finnish and many other accented languages. J=E1nos U.I. I do not know PC > I am sorry to admit but I do not know > how to change the encoding :(, could you help me please? J=E1nos Saving notebooks in PDF form I get an unreadable result if the text > is, say, in Hungarian, probably the same problem arises with other > languages with diacritical signs. Any idea? > Will that happen if you change your encoding from let say western >> iso to >> Unicode UTF(8) or something similar ? >> J=E1nos >> ------ >> ..because Annushka has already bought sunflower oil, and not >> only bought >> it, but spilled it too. >> Bulgakov: Master and Margarita > > -- > http://www.math.bme.hu/~jtoth ----------------------------------------------------- So, while openness provides a couple of security advantages in itself, the chief reason why Linux and BSD offer superior security is not so much because they're open source, but because they're not Windows. http://www.theregister.co.uk/content/55/36029.html === Subject: Re: pdf and accents I am sorry to admit but I do not know how to change the encoding :(, could you help me please? J=E1nos > Saving notebooks in PDF form I get an unreadable result if the text > is, say, in Hungarian, probably the same problem arises with other > languages with diacritical signs. Any idea? > > Will that happen if you change your encoding from let say western iso to > Unicode UTF(8) or something similar ? J=E1nos > ------ > ..because Annushka has already bought sunflower oil, and not only bough= t > it, but spilled it too. > Bulgakov: Master and Margarita -- http://www.math.bme.hu/~jtoth === Subject: Re: pdf and accents > Saving notebooks in PDF form I get an unreadable result if the text > is, say, in Hungarian, probably the same problem arises with other > languages with diacritical signs. Any idea? Will that happen if you change your encoding from let say western iso to Unicode UTF(8) or something similar ? J=E1nos ------ ..because Annushka has already bought sunflower oil, and not only bought it, but spilled it too. Bulgakov: Master and Margarita === Subject: Re: pdf and accents > Will that happen if you change your encoding from let say western iso > to Unicode UTF(8) or something similar ? How we can do this? The following code: a = ToString[, CharacterEncoding -> Unicode] Export[C:1.pdf, a] where is in really text in Russian (cyrillic alphabet) generates just the same unreadable file. === Subject: pdf and accents Saving notebooks in PDF form I get an unreadable result if the text is, say, in Hungarian, probably the same problem arises with other languages with diacritical signs. Any idea? === Subject: Re: pdf and accents > Saving notebooks in PDF form I get an unreadable result if the text > is, say, in Hungarian, probably the same problem arises with other > languages with diacritical signs. Any idea? I have found some workaround but it is not fine: b = ImportString[ExportString[, PDF], PDF][[1]] Export[C:1.pdf, b] Import[C:1.pdf][[1]] All symbols will present as contours in the output file. === Subject: Re: pdf and accents > Saving notebooks in PDF form I get an unreadable result if the text > is, say, in Hungarian, probably the same problem arises with other > languages with diacritical signs. Any idea? Just the same happens if the text is in Russian. There is no way for exporting such text to PDF except printing notebook to PDF-printer. === Subject: Re: pdf and accents > Saving notebooks in PDF form I get an unreadable result if the text > is, say, in Hungarian, probably the same problem arises with other > languages with diacritical signs. Any idea? Yes, I can confirm the problem. An important thing that you did not mention in your post is that the problem does not occur with characters that are representable in latin1 encoding. So in Hungarian the two problematic characters are =FB and =F5 ([UDoubleAcute] and [ODoubleAcute] for those whose newreader does not like UTF8). Here's a test case: ImportString[ExportString[[UDoubleAcute] [ODoubleAcute],PDF],PDF] === Subject: Re: Dynamic Hi Gianluca, whow, what stamina! I can not explain all quircks, but what matters is: - if you have an expression that you want dynamically updated, you must wrap it with Dynamic. p+1 is not updated. Dynamic[p]+1 only updates p not the sum. Therefore, you need: Dynamic[p+1]. - FullForm sort of creates an inactive print form (sorry can not explain it better) hop this helps, Daniel > Hi! > > I am trying to learn how the new Dynamic features work. > > The following two Manipulate expressions give outputs that > make perfect intuitive sense to me: > > Manipulate[q = p + 1; > q, > {p, 0, 1}] > > Manipulate[q = p + 1; > FullForm@q, > {p, 0, 1}] > > (don't keep both outputs active at the same time > if you are short on battery power!) > > When I try to reproduce similar effects with > DynamicModule, I get all sorts of different behaviours. > Compare the following: > > DynamicModule[{p = 0, q}, > q = p + 1; > {Slider[Dynamic@p], q}] > > DynamicModule[{p = 0, q}, > q = p + 1; > {Slider[Dynamic@p], Dynamic@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], FullForm@Dynamic@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], Dynamic@FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q[[1, 1]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q[[1, 2]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic[q[[1, 1]]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic[q[[1, 2]]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic@FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], FullForm@Dynamic@q}] > > Right now all I need is a few kind words of encouragement > from somebody who has already mastered dynamic interactivity... > > Gianluca > > === Subject: Re: Dynamic > Hi! > > I am trying to learn how the new Dynamic features work. These may be useful links. Copy and paste the Hyperlink[] expressions into a notebook, evaluate them and then click on them: * This is a basic introduction to Dynamic: Hyperlink[Introduction to Dynamic, paclet:tutorial/IntroductionToDynamic] * This explains the more advanced features of Dynamic (it should help with understanding DynamicModule): Hyperlink[Advanced Dynamic Functionality, paclet:tutorial/AdvancedDynamicFunctionality] * Here are some screencasts (shows features being used in the frontend, with narration), which include Dynamic tutorials from Theodore Gray: Hyperlink[Screencasts, http://www.wolfram.com/broadcast/screencasts/] * Here are some (keyword) 'simple' demonstrations, which may help with understanding Manipulate: Hyperlink[Simple demonstrations, http://demonstrations.wolfram.com/search.html?query=simple] (Download a demonstrations, then click on the 'DOWNLOAD DEMONSTRATION SOURCE CODE' link in the notebook to download the source code notebook, then open the source code notebook). === Subject: Re: Dynamic > Hi! > > I am trying to learn how the new Dynamic features work. > > The following two Manipulate expressions give outputs that > make perfect intuitive sense to me: > > Manipulate[q = p + 1; > q, > {p, 0, 1}] > > Manipulate[q = p + 1; > FullForm@q, > {p, 0, 1}] > > (don't keep both outputs active at the same time > if you are short on battery power!) > > When I try to reproduce similar effects with > DynamicModule, I get all sorts of different behaviours. > Compare the following: > > DynamicModule[{p = 0, q}, > q = p + 1; > {Slider[Dynamic@p], q}] > > DynamicModule[{p = 0, q}, > q = p + 1; > {Slider[Dynamic@p], Dynamic@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], FullForm@Dynamic@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], Dynamic@FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q[[1, 1]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q[[1, 2]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic[q[[1, 1]]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic[q[[1, 2]]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic@FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], FullForm@Dynamic@q}] > > Right now all I need is a few kind words of encouragement > from somebody who has already mastered dynamic interactivity... > > Gianluca > > I think this will do what you want: DynamicModule[{p = 0, q}, { Slider[Dynamic@p], Dynamic[ q = p + 1; q ] } ] it might help to split things into controller and viewer parts, where in this case the controller is the slider, the viewer part is all the code that needs to be executed to show your results. Here this is (q=p+1;q) and needs to be entirely wrapped with Dynamic. To get a first working version you can always do this (enclose everything that's used to create the view with Dynamic), but for many realistic cases you will not need to recalculate everything that is shown (or part of the viewer). Then for performance reason you should only use Dynamic on those parts that need to be recalculated when one of the controller changes a variable. Here the explanation does not change, so no Dynamic is needed for it: DynamicModule[{p = 0, q}, Row[{ Slider[Dynamic@p], this is the value: ,Dynamic[p+1] }] ] hth, albert === Subject: Re: Dynamic > Hi! > > I am trying to learn how the new Dynamic features work. > > The following two Manipulate expressions give outputs that > make perfect intuitive sense to me: > > Manipulate[q = p + 1; > q, > {p, 0, 1}] > > Manipulate[q = p + 1; > FullForm@q, > {p, 0, 1}] > > (don't keep both outputs active at the same time > if you are short on battery power!) > > When I try to reproduce similar effects with > DynamicModule, I get all sorts of different behaviours. > Compare the following: > > DynamicModule[{p = 0, q}, > q = p + 1; > {Slider[Dynamic@p], q}] > > DynamicModule[{p = 0, q}, > q = p + 1; > {Slider[Dynamic@p], Dynamic@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], FullForm@Dynamic@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], Dynamic@FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q[[1, 1]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q[[1, 2]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic[q[[1, 1]]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic[q[[1, 2]]]}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic@FullForm@q}] > > DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], FullForm@Dynamic@q}] > > Right now all I need is a few kind words of encouragement > from somebody who has already mastered dynamic interactivity... Note that Dynamic is used for *displaying* an expression (and reevaluating it before displaying it if necessary). So q = Dynamic[p+1] cannot be used as a value in calculations. Here's an example: 1 + Dynamic[a] a = 1 After setting 'a' to 1, 1+1 will be displayed and not 2. This is one way to implement something similar to the original Module[] example: DynamicModule[{p = 0, q}, {Slider[Dynamic[p]], Dynamic[q = p + 1; q]}] Each time 'p' changes, the complete expression 'q=p+1; q' will be re-evaluated. I hope this helps, Szabolcs === Subject: Re: Dynamic Hi Gianluca, I think what you are missing is the use of a second argument in Dynamic. See the 'Introduction To Dynamic' tutorial and scroll down toe 'The Second Argument of Dynamic'. So I think you want: DynamicModule[{p = 0}, {Slider[Dynamic[p]], Dynamic[p + 1, (p = # - 1) &]}] This is always a little difficult to get used to but # is the value that you want displayed (p+1) so the pure function is the inverse function. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hi! I am trying to learn how the new Dynamic features work. The following two Manipulate expressions give outputs that > make perfect intuitive sense to me: Manipulate[q = p + 1; > q, > {p, 0, 1}] Manipulate[q = p + 1; > FullForm@q, > {p, 0, 1}] (don't keep both outputs active at the same time > if you are short on battery power!) When I try to reproduce similar effects with > DynamicModule, I get all sorts of different behaviours. > Compare the following: DynamicModule[{p = 0, q}, > q = p + 1; > {Slider[Dynamic@p], q}] DynamicModule[{p = 0, q}, > q = p + 1; > {Slider[Dynamic@p], Dynamic@q}] DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], q}] DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], FullForm@q}] DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], FullForm@Dynamic@q}] DynamicModule[{p = 0, q}, > q = Dynamic[p] + 1; > {Slider[Dynamic@p], Dynamic@FullForm@q}] DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q}] DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q[[1, 1]]}] DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], q[[1, 2]]}] DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic@q}] DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic[q[[1, 1]]]}] DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic[q[[1, 2]]]}] DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], FullForm@q}] DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], Dynamic@FullForm@q}] DynamicModule[{p = 0, q}, > q = Dynamic[p + 1]; > {Slider[Dynamic@p], FullForm@Dynamic@q}] Right now all I need is a few kind words of encouragement > from somebody who has already mastered dynamic interactivity... Gianluca === Subject: Extracting information from Agglomerate. I am beginning to explore Agglomerate. I'd like to extract information about which elements of a cluster are indicated by the dissimilarity measure. (I am fairly new to discrete math) For example, alist = RandomReal[{0, 100}, {5, 3}]; Agglomerate[alist, Linkage -> Single] For any cluster with non-trivial subclusters, is it possible to extract the particular points of the subclusters that are producing the nearest two points? It seems it must be computed, but hidden. I'd like to get those points and not have to traverse the subclusters to find them. -- W. Craig Carter === Subject: Re: How to put text on a curved surface? > I would like to put Mathematica on a curved surface, e.g. a torus. > Can anyone help here? > with friendly greetings, > P_ter > You mean the projected/mapped letters should be curved ? Try > projecting stencil slots onto the torus from a suitable bright point > as light source, which can be even at infinity.. as intersection with > the conical rays. It should be mentioned that the mapping can never be faithful ( per > isometric mappings between flat to flat or curvrd to curved surfaces ) > as there is bound to be alteration due to: 1) magnification/reduction ( strain of tension or compression), 2) distortion ( angle changes in shear). It is in other words so stated by Gauss Egregium theorem. After > writing or printing the text on a flat label when you try to stick it > on a torus of suitable size, a tendency to tear on areas outside the > crown (Gauss Curvature > 0) and some folds/frills on the inside ( G.C > < 0) is inevitable. The most faithful reproduction takes place at the > crown ( G.C ~ 0). Continued... Simple example below is for a faithful map from a flat label to a cone in 3D plot 'drape' : t=0; umin=1;umax=16;vmin=3;vmax=5; (* before draping flatstrip on cone ; can be rasterized as suggested by Fred Klingener *) Strp={u Cos[t]-v Sin[t],u Sin[t]+v Cos[t],0}; aa=ParametricPlot3D[Strp,{u,umin,umax}, {v,vmin,vmax},PlotPoints=AE{17,4}]; th[u_,v_,gt_]:=ArcTan[u Cos[gt]-v Sin[gt],u Sin[gt]+v Cos[gt]]; gt=Pi/4; bb=ParametricPlot3D[Sqrt[u^2+v^2] {Cos[th[u,v,gt]],Sin[th[u,v,gt]],0}, {u,umin,umax},{v,vmin,vmax},PlotPoints=AE{17,4}] Show[aa,bb] (* PlotPoints=AE4 is partly does not come through, bb is also not Shown in full*) al=Pi/12; cone=ParametricPlot3D[RHO {Sin[al] Cos[t],Sin[al] Sin[t],Cos[al]} +{0,0,.03},{RHO,2,17},{t,0,2 Pi},PlotPoints=AE{41,55}] (*after rotating gt in the plane,Drape/Bend/Roll the flat strip into a cone of semi vertex angle al*) t=1.4; rho=Sqrt[u^2+v^2]; STRP=rho*{Sin[al] Cos[th[u,v,t]/Sin[al]],Sin[al] Sin[th[u,v,t]/ Sin[al]],Cos[al]} ; drape=ParametricPlot3D[STRP,{u,umin,umax}, {v,vmin,vmax},PlotPoints=AE{65,11}] Show[cone,drape] Narasimham === Subject: Grade calculation tool for students.... Hi folks, I've been trying to develop a grade calculation tool for my students that will run within the free Mathematica Player now offered. The program is supposed to query the students for the number of grades they currently have, and then place a dynamically updating table for them to enter their current grades in the Controller area within Manipulate. While it seems that the table is being created (as judged by some debugging statements), for some reason Mathematica is placing a slider, rather than the actual table in the control area. I feel like I am close to figuring the problem out.....but I also felt that way 10 hours ago. :-) If you have time to try the code below, and could suggest a course of action, I would certainly appreciate your help. Manipulate[gradata = Range[12]; weidata = Range[12]; Dynamic[Item[Your current grade is:, gradeentry, Head[gradeentry], InputForm[gradeentry]]], Item[Style[Grade Calculation Tool, 20, Bold, Black], Alignment -> Center], Item[Style[Powered by Mathematica (www.wolfram.com), 12, Bold, Black], Alignment -> Center], Delimiter, {{totcoursegrades, 1, Style[How many individual grades will be used to calculate your entire course grade?, 14, Bold, Red]}, Range[12], ControlType -> PopupMenu} , Delimiter, {{gradesnow, 1, Style[How many of these individual grades do you know at this time?, 14, Bold, Red]}, Range[totcoursegrades], ControlType -> PopupMenu}, Delimiter, {gradeentry, {Table[ With[{i = i}, {Style[Grade[i], 14, Bold, Blue], PopupMenu[Dynamic[gradata[[i]]], Range[0, 105, 0.5]], Style[Weight[i], 14, Bold, Blue], PopupMenu[Dynamic[weidata[[i]]], Range[0, 100, 0.5]]}], {i, 1, gradesnow}] // TableForm}}] __________________________________________________ Do You Yahoo!? http://mail.yahoo.com === Subject: Re: Bug in ExportString? when I do mText2D = ImportString[ExportString[Cell[TextData[StyleBox[BCD E, FontWeight -> Bold]], Section], PDF]][[1]] Show[mText2D /. Polygon[l_] :> {Thickness[0.001], Line[l]}, Frame -> True,ImageSize -> 240] Such a small code and so informative! I get an impression what happens to the text. All the outlines are visible under these conditions. Indeed, spaces are transformed in images. However one can also observe that letters are connected with a line. With a polygon such a line falls away. So, I asked myself: why not with ? It would be easy to connect to a next letter. === Subject: Re: REMINDER--Advanced Mathematica Summer School I do agree with Savvas (message included below). I am Mexican, I am the adviser of a new student-group of Mexican Mathematica fans ( http://www.matecmatica.blogspot.com/ ) and I would love to send at least one of my brilliant students to this school. They do have great projects. However our student-group is totally new, we are just finishing the administrative procedure in our university (http://www.cem.itesm.mx ) for registering as an official group, therefore we do not have any money yet, and we cannot send a student this summer. Jose Mexico -----Mensaje original----- De: psycho_dad [mailto:s.nesseris@gmail.com] Enviado el: Jueves, 10 de Abril de 2008 01:10 a.m. Para: mathgroup@smc.vnet.net Asunto: Re: REMINDER--Advanced Mathematica Summer School this idea about a summer school seems great! However, I have a couple of questions: 1) Why does the school cost $2500? 2) There seem to be some scholarships available, but sending an email to Wolfram Research I was told that they are offering a student rate of (only) $1000, thus barely covering the expenses and that does not cover the plane tickets I guess. This amount is prohibitive for international participants, even for EU citizens (due to the strong euro), therefore I don't think I will even consider applying, despite the fact I would really love to participate ... :-( Any comments on this (especially from Wolfram Research) are welcome. Savvas > This is a reminder that you can still apply for our first > Advanced Mathematica Summer School. Taking place July 6-18, 2008, in Champaign, Illinois, the Summer > School is intended for students and professionals with > significant Mathematica projects. Attendees will work directly > with senior developers and managers at Wolfram Research to > advance those projects. Applications are being accepted now; a limited number of slots > are available. For more details and to apply, see:http://www.wolfram.com/summerschool === Subject: Re: REMINDER--Advanced Mathematica Summer School this idea about a summer school seems great! However, I have a couple of questions: 1) Why does the school cost $2500? 2) There seem to be some scholarships available, but sending an email to Wolfram Research I was told that they are offering a student rate of (only) $1000, thus barely covering the expenses and that does not cover the plane tickets I guess. This amount is prohibitive for international participants, even for EU citizens (due to the strong euro), therefore I don't think I will even consider applying, despite the fact I would really love to participate ... :-( Any comments on this (especially from Wolfram Research) are welcome. Savvas > This is a reminder that you can still apply for our first > Advanced Mathematica Summer School. Taking place July 6-18, 2008, in Champaign, Illinois, the Summer > School is intended for students and professionals with > significant Mathematica projects. Attendees will work directly > with senior developers and managers at Wolfram Research to > advance those projects. Applications are being accepted now; a limited number of slots > are available. For more details and to apply, see:http://www.wolfram.com/summerschool === Subject: Re: max and min >How I can to obtain the maximum and minimum values in a function >like a Sin, but that varying their frequency with the time. The most direct way to find the minimum and maximum of any function is to use Minimize. Using Sin as an example, a minimum is: In[4]:= Minimize[Sin[x], x] Out[4]= {-1, {x -> (3*Pi)/2}} and a maximum is: In[5]:= Minimize[-Sin[x], x] Out[5]= {-1, {x -> Pi/2}} Alternatively, you can compute the derivative of your function and use FindRoot, Reduce, Solve etc. Again using Sin as an example: In[6]:= Reduce[D[Sin[x], x] == 0, x] Out[6]= Element[C[1], Integers] && (x == 2*Pi*C[1] - Pi/2 || x == 2*Pi*C[1] + Pi/2) finds all of the minima/maxima === Subject: Re: exporting to multiple sheets in XLS format >Is there a way to export to multiple worksheets in excel XLS >format Yes. If your expression is say a m X n X k array you will find k worksheets in the file resulting from Export[filename.xls,array,XLS] >When importing, you can choose which sheet to import from, for >example: >Import[sample.xls,{Data,2}] >will import the data fields from worksheet 2. >However, is there a way to do the same sort of thing with export=3F I am not aware of a way to write to a given worksheet. Possibly, a similar command syntax will work with Export. >Or even better, write to many worksheets all at once (in the same >XLS object ) Export does this by default >or the ability to append worksheets to already created XLS document. I don't know whether this is possible or not but I strongly doubt that it is. One thing to keep in mind. The limits for the size of arrays in Mathematica greatly exceed those allowed in some versions of Excel. Obviously, there is no way for Export to fix this. Also, the amount of time Mathematic uses (at least on my system) to export to XLS format gets to be quite significant for large files. Simply put, XLS is not a native Mathematica format and a lot has to be done to convert things into this format. === Subject: what does Method->HighDimensionalEmbedding actually do for GraphPlot? What, exactly, is the HighDimensionalEmbeedding value for the GraphPlot option Method? And why does the following produce a display that seems to be wrong: the displayed graph has only 5 edges instead of the expected 6 for the complete graph on 4 vertices? GraphPlot[CompleteGraph[4], Method -> HighDimensionalEmbedding, VertexLabeling -> True] -- 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: PolarPlot Re 6.0.2 under WinXP. Bruce PolarPlot[{2 a Sqrt[Cos@t], -2 a Sqrt[Cos@t]}, {t, 0, 2 [Pi]}, PlotRange -> 7] === Subject: Intersection of lists of lists based on the first term There is something I've been doing inefficiently that I think might be done much better, and was hoping folks here could help. I am working with time series data in the form seriesA={{timestamp1A,data1A},{timestamp2A,data2A}....{timestampNA,dataNA}}; seriesB={{timestamp1B,data1A},{timestamp2B,data2B}....{timestampNB,dataNB}}; etc. where the many of the timestamps will be in common between the series, but not all. I frequently need to work with only those data which are available in all the time series, and I have written a function that does this, in the simplest case, by first working out the timestamps that all the series share in common timestampsincommon=Intersection @@ Map[Transpose[#][[1]] &, {seriesA,seriesB....seriesN}]; then running Select based on MemberQ Map[Select[#, MemberQ[timestampsincommon, #[[1]]] &] &, {seriesA,seriesB....seriesN}]; This works, but the completion time increases roughly linearly with the number of datapoints involved, and is slow when the number of points gets large, and it seems inelegant. I was hoping somebody on the list might suggest a better way. Michael === Subject: Re: Intersection of lists of lists based on the first term > There is something I've been doing inefficiently that I think might be done > much better, and was hoping folks here could help. > > I am working with time series data in the form > seriesA={{timestamp1A,data1A},{timestamp2A,data2A}....{timestampNA,dataNA}}; > seriesB={{timestamp1B,data1A},{timestamp2B,data2B}....{timestampNB,dataNB}}; > etc. > where the many of the timestamps will be in common between the series, but > not all. > > I frequently need to work with only those data which are available in all > the time series, and I have written a function that does this, in the > simplest case, by first working out the timestamps that all the series share > in common > > timestampsincommon=Intersection @@ Map[Transpose[#][[1]] &, > {seriesA,seriesB....seriesN}]; Here's a slightly simpler way to do this: timeStampsInCommon = Intersection @@ ({seriesA, ..., seriesN}[[All, All, 1]]) > > then running Select based on MemberQ > > Map[Select[#, MemberQ[timestampsincommon, #[[1]]] &] &, > {seriesA,seriesB....seriesN}]; > > This works, but the completion time increases roughly linearly with the > number of datapoints involved, and is slow when the number of points gets > large, and it seems inelegant. I was hoping somebody on the list might > suggest a better way. This is worse than linear time. It is proportional to (total number of datapoints) * (number of common timestamps). We can speed up the MemberQ[timeStampsInCommon, ...] part to faster than proportional to Length[timeStampsInCommon] like this: (isCommon[#] = True) & /@ timeStampsInCommon Select[seriesA, isCommon@First[#] &] Szabolcs === Subject: Ranks for an array of triplets I can create an array with x,y,z triplets. x,y are on a regularly spaced raster, z is a RandomReal. For sorting the array according to the z values, I found two options, the second of which is significantly faster. However, my goal is not to sort, but to calculate the rank of the z value within the triplet. For example: original array Ar: {0,0,9.8},{0,1,2.3},{1,1,12.6} convert to: {0,0,2},{0,1,1},{1,1,3} .89ºâ 2.3 is the smallest z-value, hence it gets assigned rank 1 In my case I can reach this converted array only with extra steps: - separating the z-values from Ar, - calculating the (standardized) RanksOfAr, - gluing the triplets back together. Is there a way to to this in one step? Claus Here is the mathematica code: ----------------------------- Make up an array with (x, y) being coordinates and z being a value at that (x, y) location Ar = Partition[Flatten[Table[{i, j, k}, {i, 1, 10} , {j, 1, 10} , {k, {RandomReal[]}} ]], 3]; Time two versions of Sorting the array Ar according to z Timing[SortBottomAATriples = Sort[Ar, #1[[3]] < #2[[3]] &]]; sll[ll_, elem_] := ll[[Ordering[ll[[All, elem]]]]] Timing[OrdBotAATrip = sll[Ar, 3]]; Create the Ranks of z at the original position from Ar those ranks are scaled between [0, 1] RanksOfAr = Ordering[SortBottomAATriples]/Length[SortBottomAATriples]; Procedure to put it all back together x = Ar[[All, 1]]; y = Ar[[All, 2]]; FinalAr = Transpose[{x, y, RanksOfAr}] // N; === Subject: Tilted decimals on the x-axis to avoid overlapping How can I see all the decimals on the x-axis **and** avoid overlapping ? Trivial example: Plot[x, {x, 123.45678, 123.45679}] I would like to rotate clockwise by an angle alpha (e.g.,Pi/6, or Pi/2+Pi/6) the values on the x-axis and translate them in order to see the starting point, i.e., the 1 of 123.45678 should be near to the relevant tick. Note: I cannot use the usual Options to reduce the **size** of the figures or increase the size of the image. Any hint ? PS The nice suggestion by Ruskeepaa (pag. 271) seems not applicable in this case. Gianfranco Zosi Dip. Fisica Generale Universita di Torino