A131 === Subject: Re: Imaginary numbers - most interesting points If you want something a little more ambitious ;-) you can get hold of the book Abel's Theorem in Problems and Solutions. Based on Lectures of Professor V.I. Arnold by V.B. Alekseev, published by Springer- V.I. Arnold in 1963-64 (for half a year) to Moscow school-children. The lectures start with the usual formula for solving quadratic equations and finish with a new proof of Abel's theorem on the impossibility of solving in terms of radicals of equations of degree 5 and higher. Chapter 2 is all about complex numbers. In the meantime they cover group theory, topology and in particular the theory of Riemann surfaces. I don't know how many of the children who listen to the original lectures understood it all, but at least one must have Andrzej Kozlowski its amazing to realise how bad maths teaching is. If you were taught > how multiplying by 'i' is effectively a 90 degree rotation and that > i squared added another 90 deg then Cauchy Riemann, stream and > potential functions all make more sense... ________________________________ > Cc: mathgroup@smc.vnet.net === > Subject: Re: Imaginary numbers - most > interesting points That this subject [imaginary numbers] has hitherto been surrounded > by mysterious obscurity, is to be attributed largely to an ill > adapted notation. If, for example, +1, -1, and the square root of -1 > had been called direct, inverse and lateral units, instead of > positive, negative and imaginary (or even impossible), such an > obscurity would have been out of the question. -Gauss Peter > 2009/4/15 robert prince-wright imagination .... or at least imaginary numbers. The audience are all > engineers with hazy recollection of undergrad maths. If you are not familiar with Pecha Kucha, then its worth checking > Youtube and doing some googling. Simplistically the concept is to > share understanding of something using 20 slides. Each slide should > convey as much as possible with as few words as possible, with the > message limited to 20 seconds! So, what is the most interesting thing about the imaginary number > 'i' that you can think of, and how can it most simply be conveyed > using Mathematica 7 in Slide presentation form? I've started with the notion of polynomial roots, de Moivre, > reflections etc. but would appreciate a wider view. R -- > Peter Lindsay > === Subject: Re: Replace Table[Sum...]...] with Functional code > I use the following two functions to analyze time series: mm[data_, period_] := Table[Sum[(Log[data[[t]]] - Log[data[[t - i]]]) / Sqrt[i], {i, 1, period}] / period, {t, period + 1, Length[data]}] mr[data_, period_] := Table[Sum[Log[data[[t - i]] / data[[-i + t - 1]]] * (Sqrt[i] - Sqrt[i - 1]), {i, 1, period}],{t, period + 2, Length[data]}] They have a similar structure, Table[Sum[...]...], which sums a bunch of stuff from the time series at each point in the series. I'd like to convert them into functional programing constructs, but as the increments in the Table function come into play in the Sum, I haven't been able to figure out a way to do it. I've tried Map with Partition and a bunch of other things, but I could use some pointers. Any help much appreciated. ListCorrelate is very fast, but generalized ListCorrelate like ListCorrelate[{1,1},data,{1,-1}, 1,Times,Log[#2/#1]&] is terribly slow. I don't know why. instead use these codes. Log[data/RotateRight[data]] Log[Rest[data]/Most[data]] Log[Ratios[data]] etc. ListConvolve's computational compexity is O(n log(n)), and it does not create intermediate list structure like Partition and Dot combination. so it is more suitable for this time series analysis. mm[data_, period_] := With[{kernel = (period Sqrt[Range[1., period]])^-1, list = Log [data]}, list[[period + 1 ;;]] Total[kernel] - ListConvolve[kernel, list[[;; -2]]]] mr[data_, period_] := With[{kernel = Differences[Sqrt[Range[0., period]]], list = Log[Ratios [data]]}, ListConvolve[kernel, list[[;; -2]]]] === Subject: Export / pipe problems using Mathematica Vers. 6 on Linux, I expected that fig = Plot[x, {x, 1, 10}] Export[!lpr, fig, EPS] should work like advertised in the Documentation Center, instead, I get an error message lpr: error - stdin is empty, so no job has been sent. The same happens with Export[!lpr, Hello World, Text] Does anybody have a idea why stdin could be empty? Of course, Export[fig.eps, fig, EPS] works fine and lpr also. The documentation says, Export[!prog,expr, ...] exports data to a pipe. Do I misunderstand something? Fred. PS: The purpose is to replace Display[!PSPrint, fig] as Display does not exist any more in v6. === Subject: Re: Passing arrays to MathLink without extra memory allocation a) MathLink is always buffered and b) it must copy the data into a memory area that bot programs can access c) your C-program can never access the memory space of an other program/process. The operating system is responsible to hinder/prevent such operations Jens When passing a list/array from mathematica to c using mathlink, eg > when calling MLReleaseInteger32List(), it seems mathlink allocates > some memory which later has to be freed, eg using > MLReleaseInteger32List(). The question is, how is it possible to pass > a list from mathematica to c without this c memory allocation? This example helps to make the question more clear: Assume MyFunction > [BigList] to be a function implemented in c using mathlink, where > BigList is a list of integers. Since BigList has been already created > in mathematica and its corresponding memory has been allocated, we do > not wish to allocate memory once again in c. It looks like one option > is to pass BigList by reference, that is: SetProperties[MyFunction, HoldAll] In this case, does mathlink still allocate memory and copy BigList in > the c side? > === Subject: Re: running mathematica notebooks without interface take your notebook, mark all cells as initialization and save it. The Frontend will as you to create a package with you code. Say yes and you will have a *.m file tha you can run with out the FrontEnd from the kernel. Jens > Hi mathematica people! > I have a notebook with some heavy numerics which is supposed to > produce several plots and output files. > I have been recently granted access to a server with two quad-cores > where mathematica 7.0 is installed, however I can access it only > through some tedious ssh sessions (which can't be really called > tunneling) and of course I will have troubles automatizing the ssh- > tunnel. > Since I would like to run a parallelized version of my code on this > new machine.. the question is: how can I run the notebook in the remote computer (using shell > commands such as math < notebook.nb I don't know) as if I was running > them on the local machine with the graphic interface? in such a way > that it loads the notebook, it evaluate cells and it saves it so > that I can download it and open it on another machine to watch the > plots and everything? thank you very much in advance, Davide === Subject: Re: getting data points instead of a plot in ListContourPlot ? Try FullForm on your Plot. You'll see it is all Graphics commands and stuff. With smart pattern matching you can isolate your coordinates. > Using Mathematica, I have determined the level zero of a 3D plot using ListContourPlot[ matrix , Contours -> {0}, ContourShading -> False ]. > Now I would like to exploit these data instead of making a plot of it, namely I would like to get the couples of points corresponding to the level zero of the 3D plot of matrix. > Is there any way to force mathematica to give data instead of making a plot, i.e. to change the nature of the output from a plot to data points ? > Or do you have any idea to get these ? === Subject: Re: Exporting animations about the resolution of the animation? Export[animation.avi, Table[Plot[Sin[x + a], {x, 0, 2 Pi}], {a, 0, Pi, Pi/20}], FrameRate -> 1, ImageSize -> Medium, ImageResolution -> 1024] I played with ImageResolution and also with RasterSize but could not get a descent resolution of the animated plot at full screen. A solution to this question is really appreciated. Hannes is there a possibility to adjust the animation rate or speed when > exporting a Manipulate / ControllerManipulate / Animate object with a > fixed number of plots to an .avi file? In Mathematica the > AnimationRate option of Animate works fine, but in the avi-player the > animation runs much too fast. Hannes Kessler > when exporting to a movie you can play with FrameRate option. Have a > look here: http://forums.wolfram.com/mathgroup/archive/2008/Nov/msg00197.html for some further details. > Success, Alexei -- > Alexei Boulbitch, Dr., habil. > Senior Scientist IEE S.A. > ZAE Weiergewan > 11, rue Edmond Reuter > L-5326 Contern > Luxembourg Phone: +352 2454 2566 > Fax: +352 2454 3566 Website:www.iee.lu This e-mail may contain trade secrets or privileged, undisclosed or other= wise confidential information. If you are not the intended recipient and ha= ve received this e-mail in error, you are hereby notified that any review, = copying or distribution of it is strictly prohibited. Please inform us imme= r your co-operation. === Subject: Re: Exporting animations I have a related question. When exporting a Manipulate, ControllerManipulate, or Animate to an AVI, no matter what I try, the resulting AVI always runs the animation forward then backward once. I'd like it to run the animation forward only, and repeat a specified number of times (say, 3). I've looked all over the documentation for Manipulate, ControllerManipulate, and Animate, and for AVI and SWF, and have done a great deal of experimentation, but have not succeeded in this. I have tried setting AnimationDirection and AnimationRepetitions in Animate, but these options are ignored when I export. I've also tried setting these options in Export (which accepts them as options provided you put quotes around them), but again they are ignored. Export to SWF has an option for RepeatAnimation, but as far as I can tell, it is only possible to set this to True (the default, which repeats *infinitely*, forward then backward), or False (which runs the animation once in each direction). -- Helen Read University of Vermont === Subject: Re: Exporting animations > is there a possibility to adjust the animation rate or speed when >> exporting a Manipulate / ControllerManipulate / Animate object with a >> fixed number of plots to an .avi file? In Mathematica the >> AnimationRate option of Animate works fine, but in the avi-player the >> animation runs much too fast. The Export of AVIs can make use of the FrameRate option. Have you > tried this? I have found that setting the AnimationDuration (to something longer) works better than setting the FrameRate. -- Helen Read University of Vermont === Subject: Re: Been doing real-time measurements with Mathematica! (Wii Balance > On Apr 15, 1:58 am, Sjoerd C. de Vries Just wanted to report that for the first time in my life I've been >> using Mathematica to do actual real-time measurements in an experiment >> that I'm currently performing. Jay! >> I'm using a Wii balance board (from the Wii fit game) to measure >> changes in my subjects' centre of gravity. >> The Wii Balance Board connects through bluetooth to my laptop. Using >> glovepie_download) and PPJoy (http://www.geocities.com/deonvdw/Docs/ >> converted to a virtual Windows joystick X,Y values which can be read >> directly and easily using Mathematica's ControllerState function. >> This gets me about 400 samples per second. A real-time plot of the >> user's motions reduces it to about 20 Hz. Still not bad at all, and >> very useful. Works for the Wiimote (acceleration sensors!) as well. > Anyone else find it a little limiting that one needs to virtualize > devices to a joystick before Mathematica can access it through > controller-state? Perhaps I've been looking in the wrong places, > but I'd very much appreciate documentation towards writing new Mathematica > drivers for unrecognized controllers. Barring that, anyone familiar with similar joystick virtualization > under mac os X? Best, JJ > Does your joystick come with a Java driver - if it does, it would be easy to interface that to Mathematica via J/Link. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Been doing real-time measurements with Mathematica! (Wii Balance Hi Sjoerd, Just to clarify, while I have no doubt that Mathematica is incredible at recognizing all sorts of devices, it would be nice to have documentation on how to get Mathematica's ControllerState to recognize devices that Mathematica doesn't out of the box. I assume this would require the device driver to implement a particular (standard?) protocol, and possibly a new controller to be defined within mathematica. It seems likely that Mathematica assumes some standard protocol that any input devices should implement. It would be nice to know what that protocol is: i.e. I'd love to see a statement Mathematica that will recognize any devices that implement the **** protocol. This way, when I build a fancy new input device, I can ensure that Mathematica will recognize it. You needed to virtualize the wiiboard as a joystick. This is a fine and a wonderful hack, but it what would an open-source wiiboard windows driver had to know to do, such that Mathematica could recognize it as a device in and of itself? I haven't really seen any documentation on this. Best, -JJ === Subject: Re: Axes in 3D? > I'm using Mathematica 7.0 and would like to put the axes at the origin in > a > 3D graph instead of showing them on a bounding box. I have the > 3D-Axes.nb (found on > http://library.wolfram.com/infocenter/MathSource/528/ ) > but would like a source that can determine the ranges automatically. This seems like an obvious option for any 3D plot--especially since > version 7.0 seems to be very receptive to making things look just > like students would expect to see them. HHulett > Plot3D[2*x + 7*y, {x, -4, 4}, {y, -4, 4}, AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}}, Boxed -> False, AxesLabel -> {x, y, z}] --Nasser === Subject: Re: Axes in 3D? As of version 7, 3D graphics and plotting commands accept the AxesOriginoption. Plot3D[Sin[x y], {x, -3, 3}, {y, -3, 3}, AxesOrigin -> {0, 0, 0}] One thing to note about how this works...the axes are always completely visible, regardless of whether equivalently placed primitives would have been obscured by objects in the scene. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > I'm using Mathematica 7.0 and would like to put the axes at the origin in > a 3D graph instead of showing them on a bounding box. I have the 3D- > Axes.nb (found on http://library.wolfram.com/infocenter/MathSource/528/) > but would like a source that can determine the ranges automatically. This seems like an obvious option for any 3D plot--especially since > version 7.0 seems to be very receptive to making things look just > like students would expect to see them. HHulett === Subject: Re: Axes in 3D? The Presentations package has the commands: DrawingWidths3D, DrawArrow3DAxes, DrawLabeled3DAxes and TickLine3D. DrawingWidths3D[{primitives}] will return the widths. center point and bounds of the bounding box that contains the list of primitives. DrawArrow3DAxes[location,size,headsize:0.35,colors:{Blue,Green,Orange}] will draw an orthogonal triad of 3D arrows at location, each arrow being of equal length size. The arrows will point in the x, y, and z directions. DrawLabeled3DAxes[location, size, fontsize, labels:{x, y ,z }, labelpositions:{1.15,1.15,1.15}, orientations:{{1,0},{0,1},{1,0}}] will draw an orthogonal set of lines in the x, y and z directions at location, each line being of length 2 * size. The lines will be labeled with Text3D at the positive ends. labelpositions specifies the position of the center of the label in terms of size measured from location. The orientations give the orientation of the plane of each label according to the Text3D tutorial example. The fontsize is in terms of plot coordinates TickLine3D[xtickline] uses an XTickLine specification to produce a corresponding tick line for Graphics3D. The resulting tick line can be rotated, translated and scaled so as to be positioned anywhere in 3-dimensional space. One problem with axes plots versus frame plots (in 2D and 3D) is that the axes and ticks (if you are using ticks) are often interfering with the objects you are drawing. If you wish to send me an example I will try a plot for you. This does not do everything automatically, although one could probably write a routine that would do much of it. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm using Mathematica 7.0 and would like to put the axes at the origin in a 3D graph instead of showing them on a bounding box. I have the 3D-Axes.nb (found on http://library.wolfram.com/infocenter/MathSource/528/ ) but would like a source that can determine the ranges automatically. This seems like an obvious option for any 3D plot--especially since version 7.0 seems to be very receptive to making things look just like students would expect to see them. HHulett === Subject: Re: Axes in 3D? Options[Plot3D] Plot3D[{x^2 + y^2, -x^2 - y^2}, {x, -2, 2}, {y, -2, 2}, RegionFunction -> Function[{x, y, z}, x^2 + y^2 <= 4], Boxed -> False, AxesOrigin -> {0, 0, 0}, AspectRatio -> 2] Bob Hanlon I'm using Mathematica 7.0 and would like to put the axes at the origin in a 3D graph instead of showing them on a bounding box. I have the 3D-Axes.nb (found on http://library.wolfram.com/infocenter/MathSource/528/ ) but would like a source that can determine the ranges automatically. This seems like an obvious option for any 3D plot--especially since version 7.0 seems to be very receptive to making things look just like students would expect to see them. HHulett === Subject: Tolerance in LinearProgramming Hi! I would like to understand better the meaning of the Tolerance parameter in LinearProgramming. For example, I would like to understand why M = {{1000., 300., -300.0}, {10., -2000., -1.}, {100000., -1000., -90.}}; LinearProgramming[{0, 0, 0}, M, {0, 0, 0}, {1, 1, 1}, Tolerance -> 0.1] does not find a solution, while with smaller Tolerance it does: LinearProgramming[{0, 0, 0}, M, {0, 0, 0}, {1, 1, 1}, Tolerance -> 0.01] Naively, I find this behavior counterintuitive. -- Vyacheslav Rychkov https://mail.sns.it/~rychkov Scuola Normale Superiore Tel: +39-050-509068 (office) Classe di Scienze +39-050-3820086 (home) Piazza dei Cavalieri, 7 +39-3403925168 (mobile) 56100 Pisa Fax: +39-050-509045 Italy E-mail: Rychkov@sns.it === Subject: Re: FindRoot After the solution below, maybe you'll want ComplexExpand[r] // Simplify Gerry F. > eqn = x^3 - 4 a^2 x - 2 a^3 == 0; r = Simplify[x /. Solve[eqn, x], a > 0] {((4*3^(1/3) + (9 + I*Sqrt[111])^ > (2/3))*a)/(3^(2/3)* > (9 + I*Sqrt[111])^(1/3)), > (I*(-12 + 4*I*Sqrt[3] + > I*3^(1/6)*(9 + I*Sqrt[111])^ > (2/3) + (27 + 3*I*Sqrt[111])^ > (2/3))*a)/(2*3^(5/6)* > (9 + I*Sqrt[111])^(1/3)), > ((12*I - 4*Sqrt[3] - > 3^(1/6)*(9 + I*Sqrt[111])^ > (2/3) - > I*(27 + 3*I*Sqrt[111])^(2/3))* > a)/(2*3^(5/6)*(9 + I*Sqrt[111])^ > (1/3))} Plot[r, {a, 0, 5}] > Bob Hanlon > Hi all, > How can I to find the reals roots of a cubic equation in simbolic > form: For example, Find the roots of > x^3-4a^2x-2a^3==0 where a is real and a>0. === Subject: Re: FindRoot To see real roots that APPEAR real (when a is real), I'd use something like eqn = x^3 - 4 a^2 x - 2 a^3 == 0; r = Simplify[ComplexExpand[x /. Solve[eqn, x]], a > 0] {(4 a Cos[1/3 ArcTan[Sqrt[37/3]/3]])/Sqrt[3], -(2/3) a (Sqrt[3] Cos[1/3 ArcTan[Sqrt[37/3]/3]] + 3 Sin[1/3 ArcTan[Sqrt[37/3]/3]]), a (-((2 Cos[1/3 ArcTan[Sqrt[37/3]/3]])/Sqrt[3]) + 2 Sin[1/3 ArcTan[Sqrt[37/3]/3]])} Plot[r, {a, -5, 5}] or equivalently: eqn2 = eqn /. x -> a y; r = y /. ComplexExpand@Solve[eqn2, y] {(4 Cos[1/3 ArcTan[Sqrt[37/3]/3]])/Sqrt[3], -(( 2 Cos[1/3 ArcTan[Sqrt[37/3]/3]])/Sqrt[3]) + 2 Sin[1/3 ArcTan[Sqrt[37/3]/3]], -(( 2 Cos[1/3 ArcTan[Sqrt[37/3]/3]])/Sqrt[3]) - 2 Sin[1/3 ArcTan[Sqrt[37/3]/3]]} Plot[a r, {a, -5, 5}] Bobby > eqn = x^3 - 4 a^2 x - 2 a^3 == 0; r = Simplify[x /. Solve[eqn, x], a > 0] {((4*3^(1/3) + (9 + I*Sqrt[111])^ > (2/3))*a)/(3^(2/3)* > (9 + I*Sqrt[111])^(1/3)), > (I*(-12 + 4*I*Sqrt[3] + > I*3^(1/6)*(9 + I*Sqrt[111])^ > (2/3) + (27 + 3*I*Sqrt[111])^ > (2/3))*a)/(2*3^(5/6)* > (9 + I*Sqrt[111])^(1/3)), > ((12*I - 4*Sqrt[3] - > 3^(1/6)*(9 + I*Sqrt[111])^ > (2/3) - > I*(27 + 3*I*Sqrt[111])^(2/3))* > a)/(2*3^(5/6)*(9 + I*Sqrt[111])^ > (1/3))} Plot[r, {a, 0, 5}] > Bob Hanlon > Hi all, > How can I to find the reals roots of a cubic equation in simbolic > form: For example, Find the roots of > x^3-4a^2x-2a^3==0 where a is real and a>0. -- DrMajorBob@bigfoot.com === Subject: Re: tooltip - evaluate function at point Hi Cristina, The problem here seems to be that ContourPlot has built into it a tooltip that tells you which equation the contour lines correspond to. This actually was what I thought was a bug in my example, but I realize that it is a feature of ContourPlot. I have to think of how to turn that off, as that tooltip seems to preempt any other tooltip that is imposed on the plot as I did. ....Ah, this seems to do the trick, I think, using the option ContourLabels -> None]: With[{plot = ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 20, ContourLabels -> None]}, Dynamic@Tooltip[ plot, (With[{z = Complex @@ MousePosition[Graphics]}, {z, Gamma [z]}])]] Yes, if you look up the ContourLabels documentation, this is indeed what's needed. Does this work for you? David _______________________________________________________ David, at all points other than the points on the solution curves given by Arg [Gamma[x+I*y]]==0. When the mouse goes over the points on the curve the tooltip gives only Arg[Gamma[x+I*y]]==0. But I am interested in the value of Gamma precisely at the points on the curves above. Best wishes, Cristina > 04/16/09 8:09 PM > Here is the start of one sort of approach. It seems ot have some bugginess though. But perhaps this will get you going: With[{plot = ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 20]}, Dynamic@Tooltip[ plot, (With[{z = Complex @@ MousePosition[Graphics]}, {z, Gamma[z]}]) ] ] I suspect that someone else will give you a more stable approach.... --David On Apr 16, 4:18 am, Cristina < I would like to plot the solutions to an equation using ContourPlot and > add a tooltip that evaluates a different function at the points on the > solution. In particular, for the plot ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 20] when the cursor is over a solution point I would like the ToolTip to > display the value of Gamma at that point. Is this possible? If so, any > suggestion is greatly appreciated. Cristina -- This message and any attachments, may contain confidential and/or legally privileged information. If you are not the intended recipient of the message by the original sender, please destroy it. Message and attachments copyright (c) 2009, all rights reserved. Any unauthorized dissemination, distribution or copying is strictly forbidden. === Subject: Re: tooltip - evaluate function at point Just so folks see how this turned out. Part of he problem is that what works in Version 7 doesn't always work n version 6. I created a possible solution that works around the bug in ContourPlot from veroins 6. --D === Subject: Re: tooltip - evaluate function at point Cc: Bcc: HI Cristina , Of course the important question at this point is to see whether we are using the same version of Mathematica. I am doing this with Version 7 on OSX. It seems to work for me both on the contour and off of it. I agree that the documentation for ContourLabels is somewhat obscure. So, I just tested the code that I sent to you in Mathematica 6 and indeed it does not behave properly. Clearly there is a bug in version 6 that was fixed in version 7. So I have to trick the whole graphics thing in Verions 6 to make this work. Try the following (I use a transparent rectangle above the contourplot so that the Tooltip is getting its coordinates from the rectangle rather than getting it from the buggy ContourPlot): With[{plot = ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 20, ContourLabels -> None], rect = Graphics[{Opacity[0], Rectangle[{-10, -10}, {10, 10}]}]}, Dynamic@ Tooltip[Show[plot, rect], With[{z = Complex @@ MousePosition[Graphics]}, {z, Gamma[z]}]]] Best, David Hi David, I copied and pasted the code and it does the exact same thing as the other than the points on the curves. At the points of the curves it just gives Arg[Gamma[x+I*y]]==0. I couldn't find anything in the documentation of ContourLabels referring to tooltip other than The label can be any expression or graphic, and can include constructs such as Tooltip but I don't understand what that means. It seems to me that ContourLabels is just a label on the contours on the plot. If specified, they appears regardless of the position of the mouse. But maybe I am wrong. Cristina > David Reiss <> 04/17/09 9:05 PM > Hi Crristina, exactly what you wish. Also if you review the documentation for ContourLabels you will see how it controls the tooltip. David >Hi David, doesn't seem to be connected to Tooltip. There must be some other >way to turn off the tooltip label and overwrite it with a new label. >Best wishes, Cristina Hi Cristina, >The problem here seems to be that ContourPlot has built into it a tooltip >that tells you which equation the contour lines correspond to. This >actually was what I thought was a bug in my example, but I realize that it >is a feature of ContourPlot. I have to think of how to turn that off, a= s >that tooltip seems to preempt any other tooltip that is imposed on the plo= t >as I did. ....Ah, this seems to do the trick, I think, using the option ContourLabel= s >-> None]: With[{plot = > ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, > PlotPoints -> 20, ContourLabels -> None]}, > Dynamic@Tooltip[ > plot, (With[{z = Complex @@ MousePosition[Graphics]}, {z, Gamma[z]= }])]] Yes, if you look up the ContourLabels documentation, this is indeed what's >needed. >Does this work for you? >David > David, >> t >> all points other than the points on the solution curves given by >> Arg[Gamma[x+I*y]]==0. When the mouse goes over the points on the cu= rve the >> tooltip gives only Arg[Gamma[x+I*y]]==0. But I am interested in th= e value >> of Gamma precisely at the points on the curves above. >> Best wishes, >> Cristina >> > 04/16/09 8:09 PM > Here is the start of one sort of approach. It seems ot have some >> bugginess though. But perhaps this will get you going: >> With[{plot = >> ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, >> PlotPoints -> 20]}, >> Dynamic@Tooltip[ >> plot, >> (With[{z = Complex @@ MousePosition[Graphics]}, >> {z, Gamma[z]}]) >> ] >> ] >> I suspect that someone else will give you a more stable approach.... >> --David >> On Apr 16, 4:18 am, Cristina Ballantine > I would like to plot the solutions to an equation using ContourPlot a= nd >> > add a tooltip that evaluates a different function at the points on th= e >> > solution. In particular, for the plot >> > > ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, >> PlotPoints -> 20] >> > > when the cursor is over a solution point I would like the ToolTip to >> > display the value of Gamma at that point. Is this possible? If so, an= y >> > suggestion is greatly appreciated. >> > > Cristina > -- >This message and any attachments, may contain confidential and/or >legally privileged information. If you are not the intended >recipient of the message by the original sender, please destroy it. >Message and attachments copyright (c) 2009, all rights reserved. Any >unauthorized dissemination, distribution or copying is strictly >forbidden. -- <><><><><><><><><>><><><>><><><> David Reiss, Ph.D; Scientific Arts, LLC . http://www.scientificarts.com <><><><><><><><><>><><><>><><><> This message and any attachments, may contain confidential and/or legally privileged information. If you are not the intended recipient of the message by the original sender, please destroy it. Message and attachments Copyright (c) 2009, all rights reserved. -- <><><><><><><><><>><><><>><><><> David Reiss, Ph.D; Scientific Arts, LLC . http://www.scientificarts.com <><><><><><><><><>><><><>><><><> This message and any attachments, may contain confidential and/or legally privileged information. If you are not the intended recipient of the message by the original sender, please destroy it. Message and attachments Copyright (c) 2009, all rights reserved. === Subject: Abbreviation of File Names in File Menu In the drop down File Menu the penultimate block is a list of recently used notebooks; 30 in my case because I have used the options inspector to change NotebooksMenuHistoryLength. I like long notebook names because it helps me to distinguish changes I have made. In Version 7 these names are now given in an abbreviated form with the first few characters, three dots (an ellipsis) and the last few characters. This means that I can't reap the benefit of long file names because the middle of the name is missing. I have plenty of width across the screen so abbreviating is no help. Is it possible to prevent the file names being abbreviated.? Hugh Goyder === Subject: Re: Any way to make help browser remember the last position? > What bugs me, no, drives me mad, is the fact that, every time I press > F1 key to invoke the help or 'documentation center,' it goes straight > to the center of the screen instead of to the right like it did v4 an= d > 5. jka replies: I am very interested in what makes people mad. The Linux version of > Mathematica 7.0.1.0 I use leaves the help browser in place as long as > you don't close it. So an easy advise for your problem would be: don't > close the help browser. If you want to hide using it, place an other > window over it. If the Help material (and other documentation) for Mathematica were > written and displayed in another app and format (like, for example, > Adobe PDF), as is the case with most other major applications, you could > jump back and forth between your active Mathematica windows and your > currently active documentation window(s), leaving both of them > absolutely stable and unchanged in between viewings, with a single > keystroke, Cmd-Tab (on a Mac, anyway). Works like a charm; I do it all the time with other apps. And, > documentation in the form of a PDF file can be scanned, viewed, > searched, enlarged, read, and generally used _immensely_ more > effectively and easily in, say, Adobe Acrobat (or probably Reader, > though I don't use that) than documentation in Mathematica's cramped and > awkward format. [Of course, one can only imagine what documentation for, say Excel, > would be like, if MS insisted that _all_ the documentation for Excel > also had to be _written_ only in Excel . . . ] [Did I add, that selected pages or sections of documentation in PDF can > also be printed out, if you'd prefer to have a few particularly relevant > pages of the documentation sitting on your (physical) desktop, beside > your keyboard -- where you can just glance over at it, without having to > close or open anything on screen.] One of the great things about the help browser is that you can evaluate code so that not only do you get help, you can interactively experiment in order to gain a better understanding. You can't do that in a PDF. Mike === Subject: Re: Any way to make help browser remember the last > [...] > If the Help material (and other documentation) for Mathematica were > written and displayed in another app and format (like, for example, > Adobe PDF), as is the case with most other major applications, you could > jump back and forth between your active Mathematica windows and your > currently active documentation window(s), leaving both of them > absolutely stable and unchanged in between viewings, with a single > keystroke, Cmd-Tab (on a Mac, anyway). Works like a charm; I do it all the time with other apps. And, > documentation in the form of a PDF file can be scanned, viewed, > searched, enlarged, read, and generally used _immensely_ more > effectively and easily in, say, Adobe Acrobat (or probably Reader, > though I don't use that) than documentation in Mathematica's cramped and > awkward format. These other applications and their documentation display tools, how well > do they handle input and evaluation of mathematical content? I appreciate that there can be some value in being able to evaluate Mathematica examples or cells that are contained within the Mathematica documentation pages, directly within those pages. I personally do not find that I make much use of this, however -- and when I do want or need to do so, I can always (and would generally prefer to) copy the example (which is almost always a brief single cell or example) into my own running copy of Mathematica (which would be necessarily running anyway), where I can modify or customize it to apply to the situation I want to understand. And the numerous advantages of reading documentation in a more suitable format and using more suitable software -- in PDF, for example -- which I've listed above, coupled with the disadvantages associated with having to read it in the existing Mathematica documentation formats, just make the choice a no-brainer, IMHO. > [Of course, one can only imagine what documentation for, say Excel, > would be like, if MS insisted that _all_ the documentation for Excel > also had to be _written_ only in Excel . . . ] [Did I add, that selected pages or sections of documentation in PDF can > also be printed out, if you'd prefer to have a few particularly relevant > pages of the documentation sitting on your (physical) desktop, beside > your keyboard -- where you can just glance over at it, without having to > close or open anything on screen.] Last time I checked (which was today), one can still print Mathematica > notebooks. This would apply to e.g. Help browser pages. Last time I checked, most of the rest of the software world -- indeed most of the rest of the world, period -- was supplying its documentation in downloadable PDF format; and even the authors and distributors of many books and manuals sold on paper were also including a full CD of the full content along with the purchased book (and were also continuing to write, publish, and successfully market these books and manuals). Could it be there's a reason for this . . .? Or are you suggesting that it would be too difficult for Wolfram to serve different portions of its customer base, who might have varying needs or preferences, by just setting up an automated process to convert its documentation into PDF files on its web site, which users could then access and selectively download, when, if, and as they needed? > In the Help browser notebooks one can also click on URLs to the > corresponding (html) web pages, bring them up, print them, etc. Maybe > not suitable for framing (unless you print on really good paper). But > useful all the same. The endless and aimless clicking through literally hundreds if not thousands of infinitely branching links, trying to find out what is in Mathematica's documentation, or where it is, within what often seems an infinitely expanding tree structure -- or, later on, attempting to get back to something that you noted earlier on and now realize you want -- is in fact _the_ single most aggravating and disfunctional aspect of the whole system. trying to get back to something you saw earlier in thisis === Subject: Looking for a scrolling list control, or how to create/simulate one?? I am a little surprised there is not a scrolling list like control. I can find an input field but no way to make it work like a scrolling list. Am I missing something in docs? Have anyone created such a === Subject: Re: StringJoin with ToString I've considered your warnings, but - mainly because of my curiosity - I continued to find a solution to the problem. Combining information from here and my earlier tries, I've managed to come up with a stable code that is quite short: toString[expr_String] := expr; toString[expr_] := ToString[expr]; Unprotect[System`StringJoin]; Attributes[System`StringJoin] = {}; System`StringJoin[expr___] := StringJoin[{expr}]; System`StringJoin[expr_List] := Module[{s = }, Scan[(s = StringInsert [s, toString[#], -1]) &, expr]; s] Protect[System`StringJoin]; Extensive testing shows that this works as expected (error messages are returned unchanged, Import[file, Lines] works correctly, etc.). Of course, there are effects, which must be considered, e.g. David's example: ss = Quiet[2 <> 3]; Map[ToString[#^2] &, ss] this indeed would give 23 instead of 49, but that is definitely not disrupting, since one who uses the new StringJoin *should be aware* that it actually joins non-strings as well. I wouldn't consider it a problem, just a point, where it must be kept in mind what the extended StringJoin can do. To make my point clearer: no one would expect the following ss = Quiet[2[CirclePlus]3]; Map[ToString[#^2] &, ss] to result other than 4[CirclePlus]9 IFF there is no assigned meaning of CirclePlus. Although if one uses CirclePlus to actually do something, then the result of the first line won't be the same as the input: 2[CirclePlus]3. As one would expect. For the other problematic example of Albert (modified here a bit): string!], Print[string ok]] This should (in case of the new StringJoin) result string ok, while in case of the original StringJoin: this was no string!. But the former is exactly the functionality I would like to gain, namely to get a string from StringJoin even in case of non-string input. So, of course one must be cautios, but I wouldn't consider these cases problematic. Could anyone find any abnormal/unexpected behaviour of this new function? Istvan === Subject: Re: Mathematica User groups,where to find them? What is south Fla ? 2009/4/13 meitnik : > I am trying to find any local Mathematica user groups in my area (south Fla.) -- Peter Lindsay === Subject: Re: Change in NSolve algorithm $MachinePrecision behaviors, which was not clear to me before. Then, perhaps, a possible communication improvement for Mathematica developers might be to substitute/alias the keyword MachinePrecision with a new keyword, e.g. FPU, which would more easily convey the difference between: NSolve[eqns, vars, $MachinePrecision] NSolve[eqns, vars, FPU] ADL > Yes, WorkingPrecision -> $MachinePrecision will use Mathematica's > arbitrary precision arithmetic with $MachinePrecision number of digits > (around 16 on most machines). WorkingPrecision -> MachinePrecision wil= l > actually use the FPU to do the calculations. === Subject: Clip + Packed Integer Array Machine Precision Results This appears to be a bug: 1: Clip[{1, 2, 3}, {2, 2}, {0, 1/2}] ==> {0, 2, 1/2} 2: Clip[Developer`ToPackedArray[{1, 2, 3}], {2, 2}, {0, 1/2}] ==> {0., 2., 0.5} 2 should return the exact same as 1, instead it returns a packed vector of reals. === Subject: Re: Clip + Packed Integer Array Machine Precision Results Hi Raffy, from the manual: Clip[x,{min,max},{Subscript[v, min],Subscript[v, max]}] gives Subscript[v, min] for xmax. Therefore for xmin<= x <= xmax we simply get x Further: Only machine-sized numbers can be stored in packed form. Daniel > This appears to be a bug: 1: Clip[{1, 2, 3}, {2, 2}, {0, 1/2}] ==> {0, 2, 1/2} 2: Clip[Developer`ToPackedArray[{1, 2, 3}], {2, 2}, {0, 1/2}] == {0., 2., 0.5} 2 should return the exact same as 1, instead it returns a packed > vector of reals. > === Subject: Re: exponential moving average with a varying exponents. > I have a function with calculates an exponential moving average > with a varying exponent. EMAVariableExponent[data_, exponents_]:=Module[{ema}, > ema = {data[[1]]}; > Do[ema =Append[ema,ema[[t-1]] + exponents[[t]] * > (data[[t]] - ema[[t-1]])], {t,2,Length[data]}] > ]; You supply the function with a list of data and with a > list of exponents used at each step in the calculations. This seems to work OK but I'd like to replace it with a clearer > and more elegant functional construct. I wish ExponentialMovingAverage[] could take a list of exponents > rather than a constant, something like: ExponentialMovingAverage[list, exponentList] I tried the following to try to Map an ExponentialMovingAverage[] > across the list of exponents. ExponentialMovingAverage[data, #]&/@ exponents but it gives me a list of lists, each of which has > mapped each exponent in exponents to the list of data. Any suggestions much appreciated. Here's a first attempt. As a side comment, what you call exponents I tend to think of as multipliers or smoothing constants. emav[data_, c_] := FoldList[#1 + (#2[[1]]-#1)#2[[2]]&, data[[1]], Rest@Transpose@{data,c}] === Subject: Re: Dynamic popupmenu AND dynamic variables Yes! After some intense experimenting and reading on Dynamic, and using a MenuView too, I am close to having one palette to enter all Functions without typing. You have to understand, Gui is everything :-( Am curious though, why was there no true hierarchical menu widget to use, it would have made my work much faster and easier. Or, there are more widgets to come?? Andrew === Subject: Any way to make help browser remember the last position? What bugs me, no, drives me mad, is the fact that, every time I press F1 key to invoke the help or 'documentation center,' it goes straight to the center of the screen instead of to the right like it did v4 and 5. This started in v 6 except I didn't have much need for using v6. Now that I have a need v7, I absolutely hate the fact that help browser covers the open notebook and I have to move it manually. Is there a way to make it remember the last position? Sean === Subject: Re: Any way to make help browser remember the last position? I am very interested in what makes people mad. The Linux version of Mathematica 7.0.1.0 I use leaves the help browser in place as long as you don't close it. So an easy advise for your problem would be: don't close the help browser. If you want to hide using it, place an other window over it. > What bugs me, no, drives me mad, is the fact that, every time I press > F1 key to invoke the help or 'documentation center,' it goes straight > to the center of the screen instead of to the right like it did v4 and > 5. This started in v 6 except I didn't have much need for using v6. Now > that I have a need v7, I absolutely hate the fact that help browser > covers the open notebook and I have to move it manually. Is there a way to make it remember the last position? Sean > === Subject: Re: Any way to make help browser remember the last position? > What bugs me, no, drives me mad, is the fact that, every time I press > F1 key to invoke the help or 'documentation center,' it goes straight > to the center of the screen instead of to the right like it did v4 and > 5. > jka replies: > I am very interested in what makes people mad. The Linux version of > Mathematica 7.0.1.0 I use leaves the help browser in place as long as > you don't close it. So an easy advise for your problem would be: don't > close the help browser. If you want to hide using it, place an other > window over it. If the Help material (and other documentation) for Mathematica were written and displayed in another app and format (like, for example, Adobe PDF), as is the case with most other major applications, you could jump back and forth between your active Mathematica windows and your currently active documentation window(s), leaving both of them absolutely stable and unchanged in between viewings, with a single keystroke, Cmd-Tab (on a Mac, anyway). Works like a charm; I do it all the time with other apps. And, documentation in the form of a PDF file can be scanned, viewed, searched, enlarged, read, and generally used _immensely_ more effectively and easily in, say, Adobe Acrobat (or probably Reader, though I don't use that) than documentation in Mathematica's cramped and awkward format. [Of course, one can only imagine what documentation for, say Excel, would be like, if MS insisted that _all_ the documentation for Excel also had to be _written_ only in Excel . . . ] [Did I add, that selected pages or sections of documentation in PDF can also be printed out, if you'd prefer to have a few particularly relevant pages of the documentation sitting on your (physical) desktop, beside your keyboard -- where you can just glance over at it, without having to close or open anything on screen.] === Subject: Weather data options i have problem in using weather data options in Mathematica. i mean i dont know how to apply more options in a a single command. if i want to acess for example both TotalPrecipitation and cloudTypes or NearestStations of a city records, i face an error report. === Subject: Re: Weather data options You have to make separate calls for each quantity, I'm afraid. I don't think that's a problem. > i have problem in using weather data options in Mathematica. i mean i > dont know how to apply more options in a a single command. if i want > to acess for example both TotalPrecipitation and cloudTypes or > NearestStations of a city records, i face an error report. > === Subject: Re: converting a list element into a number? There may be more than one position in an expression that matches a pattern. And each position may have a multiple level specification. That is why the result is returned as a list of lists. If there is only one position at the first level you could use Part to extract its value. pos = Position[x + y, y] Part[pos, 1, 1] {{2}} 2 Or you could write: pos = Position[x + y, y] pos[[1, 1]] {{2}} 2 I often use the first form, just to be more explicit and get rid of double brackets. Another good practice in learning, and also in developing code and routines, is to write multiple steps in one cell. Put each step on a new line (but in the same cell). You can use % and %% to refer to the output of previous lines. Then, when you evaluate you can see what each step is doing. Keep changing, adding and experimenting, each time reevaluating the cell, until you understand what is happening and you get what you want. If you wish, you can even interlace the statements with Print statements to annotate what you think you are doing. Print[The initial expression] expr = x + y Print[Find the position of y] Position[expr, y] Print[Extract the number using Part] Part[%%, 1, 1] Print[Check it using Part with the position on the expression] Part[expr, %%] You could have multiple statements in a row, some of them with semicolons at the end if you want to suppress that particular output. With or without the Print statements this is a really useful way to develop a calculation. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hi I have noticed when using Position[], it returns a single element list. So how do I convert that into a number other than using Flatten to strip off the braces? It seems if I use Flatten within any subroutine code, I get the error code thats its Protected. So how do === Subject: Re: converting a list element into a number? >Hi I have noticed when using Position[], it returns a single element >list. So how do I convert that into a number other than using >Flatten to strip off the braces? It seems if I use Flatten within >any subroutine code, I get the error code thats its Protected. So >how do I work around using Flatten?? Here is an example to get a number In[2]:= Position[Range[5], 3][[1, 1]] Out[2]= 3 to get a 1-D list In[3]:= Position[Range[5], 3][[1]] Out[3]= {3} or In[4]:= First@Position[Range[5], 3] Out[4]= {3} Note, there is no problem using Flatten in a subroutine. Getting the error you described says there is something wrong with your code. Possibly, you are making an assignment to Flatten which would generate this error. === Subject: Re: How to evaluate a notebook programmatically? On Apr 13, 3:33 am, Paul Ellsmore In one notebook, gui.nb, I have the code for a user interface. In anoth= er, > functional.nb I have around 3000 lines of code, in several hundred cell= s. > I want to click a button (or something similar) in gui.nb, and tell > Mathematica to execute all the cells in functional.nb. Functional.nb will > use values for global variables that have been assigned in gui.nb, and > gui.nb will display the results of the execution of functional.nb. Seems > straightforward. Now in functional.nb, we group all the cells together, so that we can > manually execute them all with a single shift-click. What is the > programmatical equivalent of this? I have looked through all the tutorial= s > etc on controlling notebooks from the front end, frontendtokens etc., but > nothing seems to do quite what I want. The options seem to be: Option 1. Merge all the cells in functional.nb, and assign that cell to a > Function, which can then be called from gui.nb. This is highly undesirabl= e, > because if an error occurs, we find out about it at the end of 3000 lines= of > code, with no idea where the error occurred. The cell structure in > Mathematica is just too valuable to throw away. I guess that using workbe= nch > might mitigate some of these issues, but that means my colleagues and I a= ll > having to learn a new (and complicated) tool. Option 2. Assign each of the (hundreds of!) cells to a separate function, > and call each of them in turn from gui.nb. A lot of hard work here with t= he > potential for errors in naming and ordering the functions in the two > notebooks, and probably an increase in execution time. Option 3. Make all the cells in functional.nb initialization cells, then = get > gui.nb to open functional.nb each time we want to evaluate it, and then > close it again. Very clunky, and again probably slow. I am sure there are better options than these? Any ideas? > Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 > (* Get the notebook object. *) nb = First@Notebooks[functional*]; (* Select all cells. *) SelectionMove[nb, All, Notebook]; (* Evaluate the selection. *) SelectionEvaluate@nb === Subject: Re: How to evaluate a notebook programmatically? In one notebook, gui.nb, I have the code for a user interface. In another, > functional.nb I have around 3000 lines of code, in several hundred cells. > I want to click a button (or something similar) in gui.nb, and tell > Mathematica to execute all the cells in functional.nb. Functional.nb will > use values for global variables that have been assigned in gui.nb, and > gui.nb will display the results of the execution of functional.nb. Seems > straightforward. Now in functional.nb, we group all the cells together, so that we can > manually execute them all with a single shift-click. What is the > programmatical equivalent of this? I have looked through all the tutorials > etc on controlling notebooks from the front end, frontendtokens etc., but > nothing seems to do quite what I want. The options seem to be: Option 1. Merge all the cells in functional.nb, and assign that cell to a > Function, which can then be called from gui.nb. This is highly undesirable, > because if an error occurs, we find out about it at the end of 3000 lines of > code, with no idea where the error occurred. The cell structure in > Mathematica is just too valuable to throw away. I guess that using workbench > might mitigate some of these issues, but that means my colleagues and I all > having to learn a new (and complicated) tool. Option 2. Assign each of the (hundreds of!) cells to a separate function, > and call each of them in turn from gui.nb. A lot of hard work here with the > potential for errors in naming and ordering the functions in the two > notebooks, and probably an increase in execution time. Option 3. Make all the cells in functional.nb initialization cells, then get > gui.nb to open functional.nb each time we want to evaluate it, and then > close it again. Very clunky, and again probably slow. I am sure there are better options than these? Any ideas? > Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 > If you move your code from a notebook to a .m file (often known as a package file, but the code does not need to be a package), you will be able to execute the code by calling Get. Since version 6, .m files edit inside Mathematica beautifully - you can even have headings in the code (which are stored inside the .m file as special comments) - it is easy to forget if you are editing a notebook or a package file. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: How to evaluate a notebook programmatically? On Apr 13, 2:33 am, Paul Ellsmore In one notebook, gui.nb, I have the code for a user interface. In anoth= er, > functional.nb I have around 3000 lines of code, in several hundred cell= s. > I want to click a button (or something similar) in gui.nb, and tell > Mathematica to execute all the cells in functional.nb. Functional.nb will > use values for global variables that have been assigned in gui.nb, and > gui.nb will display the results of the execution of functional.nb. Seems > straightforward. Now in functional.nb, we group all the cells together, so that we can > manually execute them all with a single shift-click. What is the > programmatical equivalent of this? I have looked through all the tutorial= s > etc on controlling notebooks from the front end, frontendtokens etc., but > nothing seems to do quite what I want. The options seem to be: Option 1. Merge all the cells in functional.nb, and assign that cell to a > Function, which can then be called from gui.nb. This is highly undesirabl= e, > because if an error occurs, we find out about it at the end of 3000 lines= of > code, with no idea where the error occurred. The cell structure in > Mathematica is just too valuable to throw away. I guess that using workbe= nch > might mitigate some of these issues, but that means my colleagues and I a= ll > having to learn a new (and complicated) tool. Option 2. Assign each of the (hundreds of!) cells to a separate function, > and call each of them in turn from gui.nb. A lot of hard work here with t= he > potential for errors in naming and ordering the functions in the two > notebooks, and probably an increase in execution time. Option 3. Make all the cells in functional.nb initialization cells, then = get > gui.nb to open functional.nb each time we want to evaluate it, and then > close it again. Very clunky, and again probably slow. I am sure there are better options than these? Any ideas? > Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 > without seeing the notebooks my guess would be that you might want to do something like to tag the cells that you want to group and evaluate together, then use NotebookFind to locate those tagged cells and then SelectionEvaluate. Those steps could be combined into a function evaluteCells[yourTags_String]:=(NotebookFind[nb, yourTags, All, CellTags];SelectionEvaluate[nb];) where nb=EvalutionNotebook[] Mike === Subject: Re: UNDO and Mathematica - how useless > The backup functions in A WorkLife FrameWork are certainly a help here > (also note that there is a cell level backup functton there as well). > But it is not quite the solution needed for basic editing and textual > input. But I think that a basic Undo functionality in Mathematica is > essential. People have been asking for this for years, but WRI seems to have a complete blind spot in this matter :( In practice, a single-level UNDO is nearly useless, because of the uncertainty as to what constitutes a 'level' - particularly in the context of a complicated product like Mathematica. I would have thought UNDO is feasible for any non-output cell that does not contain Dynamic elements - plus perhaps a few other reasonable restrictions. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Dynamic popupmenu AND dynamic variables Ok, I finally got a working parts I needed, however, to work smart, I > really hate to hardwire the creation of each group of popupmenus with > unique variable names (I have a hundred to go!). Is there any way to > create a rule, function etc so I can pass data for the menus and > generate unique variable names within. I tried using module but it > fails to work. Is this doable? use this code for showing me: mainMenu = {hey, you, now} > stuff = {{a, 1, r}, {b, ee, 23}, {eg,rt,yy}}; f[e_] := Switch[e, hey, 1, you, 2, now, 3]; > CreatePalette[ > { > Labeled[ > Row[ > { > PopupMenu[Dynamic[x], mainMenu, Appearance -> Palette], > Dynamic[y = stuff[[f[x], 1]]; > PopupMenu[Dynamic[y], stuff[[f[x]]], Appearance -> Palette]], > ActionMenu[ > , { > Insert :> NotebookWrite[InputNotebook[], y], > Wrap :> NotebookApply[InputNotebook[], > RowBox[{y, [, [SelectionPlaceholder], ]}]] > }, ImageSize -> {4, 10}, FrameMargins -> 0 > ] > } > ] > , lbl, Left] > } > ] I want to create parameters for mainmenu and stuff; somehow uniquely > you. Yeah, this isn't so good because you're using the values of the global variables 'x' and 'y'. You should use DynamicModule[] to define your variables. If you put each set of constructs which isn't interdependent in a separate DynamicModule[], then you can use the same variable names repeatedly without worrying about conflicts. E.g., Column[{ DynamicModule[{x, y}, Row[{...}]], DynamicModule[{x, y}, Row[{...}]], ...}] John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: Best practices of coding using Mathematica? Anything by Roman Maeder, particularly (any edition of) Programming in Mathematica. Out of print, but copies are still available from used booksellers. Daniel === Subject: Re: Best practices of coding using Mathematica? 1) Go to Help, Documentation Center, Core Language, Functional Programming and try to become familiar with these commands. If you're used to procedural programming, a few of the functional commands may take a while to get used to but just keep 'pushing the envelope'. 2) Localize variable values. Don't write code like: x = 3; f = x^2 + Sqrt[y] Plot[f, {y, 0, 5}] Instead write: f[x_, y_] := x^2 + Sqrt[y] Plot[f[3, y], {y, 0, 5}] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ As a new user of Mathematica, where would I find coding style info towards good coding. I don't want to get into bad habits of coding. Any docs === Subject: Re: Best practices of coding using Mathematica? http://www.verbeia.com/mathematica/tips/Tricks.html And Google will always help you. As a new user of Mathematica, where would I find coding style info toward= s > good coding. I don't want to get into bad habits of coding. Any docs > -- Li Zhengji ------------------------------------------------------------- If all you have is a hammer, everything is a nail. ------------------------------------------------------------- === Subject: Re: Bug fixing reporting and fixing rate of Mathematica > I have a strong QA background and so it should come to no surprise I > am concerned about how QA is done and perceived by users. Please long > standing users of Mathematica, how would you rate and describe your exper= ience > hope WRI doesn't consider Bugs trade secrets! There are many threads on this subject on this group. Perhaps we do not want to go over this again? --David === Subject: Re: Bug fixing reporting and fixing rate of Mathematica 99.9% , or probably many more, of the things in Mathematica work fine. The most important thing for new users is to learn how it works and practice on simple but real math problems. It's much more fun. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have a strong QA background and so it should come to no surprise I am concerned about how QA is done and perceived by users. Please long standing users of Mathematica, how would you rate and describe your experience hope WRI doesn't consider Bugs trade secrets! === Subject: Fitting a Function with no closed form I have a histogram which I am trying to fit with a convoluted function. I get out the list of bin counts easy enough, but I can't figure out a way to fit the function to the data. This is the function: F(x)=Re[NIntegrate [normalizer*(E0 - u)^2 Sqrt[1 - m^2/(E0 - u)^2]*Exp[(-((x - u)^2/(2 [Sigma]^2)))/(Sqrt[2 [Pi]] [Sigma])], {u, 0, E0}]] E0 and sigma are known constants. Normalize and m are the fitting parameters. I can get a plot or of a table of values out of the function by: Plot[F(x),{x, minRange, maxRange}] Table[F(x),{x, minRange, maxRange, binWidth}] Is there a way to fit using a function like this? I would also like to error bars on the fit parameters. Adam Dally === Subject: Re: Fitting a Function with no closed form > I have a histogram which I am trying to fit with a convoluted function. I get out the list of bin counts easy enough, but I can't figure out a way > to fit the function to the data. This is the function: > F(x)=Re[NIntegrate [normalizer*(E0 - u)^2 Sqrt[1 - m^2/(E0 - u)^2]*Exp[(-((x > - u)^2/(2 [Sigma]^2)))/(Sqrt[2 [Pi]] [Sigma])], {u, 0, E0}]] > E0 and sigma are known constants. Normalize and m are the fitting > parameters. I can get a plot or of a table of values out of the function by: > Plot[F(x),{x, minRange, maxRange}] > Table[F(x),{x, minRange, maxRange, binWidth}] Is there a way to fit using a function like this? I would also like to error > bars on the fit parameters. Adam Dally > The function can be defined as a function that requires that the variables and fitting parameters to be numeric as follows In[1]:= f[x_?NumericQ, normalizer_?NumericQ, m_?NumericQ, [Sigma]_, E0_] := Re[NIntegrate[ normalizer*(E0 - u)^2 Sqrt[1 - m^2/(E0 - u)^2]* Exp[(-((x - u)^2/(2 [Sigma]^2)))/(Sqrt[2 [Pi]] [Sigma])], {u, 0, E0}]] Note that I left off the numeric requirement on [Sigma] and E0 because these will be known numbers, so there will be no need for the check so long as we always enter numbers for them. Here is some simulated data to demonstrate fitting. In[2]:= data = Table[{x, f[x, 3, 2, 1, 10] + RandomReal[{-.1, .1}]}, {x, 0, 2, .2}] Out[2]= {{0., 447.74}, {0.2, 484.515}, {0.4, 518.662}, {0.6, 549.172}, {0.8, 575.508}, {1., 597.046}, > {1.2, 613.54}, {1.4, 624.76}, {1.6, 630.629}, {1.8, 631.295}, {2., 627.419}} In version 7, NonlinearModelFit can be used to fit the data to the model and obtain an object that knows about various results and diagnostics. In[3]:= Normal[nlm = NonlinearModelFit[data, f[x, normalizer, m, 1, 10], {{normalizer, 2}, {m, 2.5}}, x]] Out[3]= f[x, 2.99854, 1.98476, 1, 10] Among the available results are ParameterConfidenceIntervalTable which presents estimates, standard errors and confidence intervals in a tabular form (alignment may appear off in the following text form in some email apps) and ParameterConfidenceIntervals which just gives the intervals. In[4]:= nlm[ParameterConfidenceIntervalTable] Out[4]= Estimate Standard Error Confidence Interval 2.99614 normalizer 2.99854 0.0010641 3.00095 1.9589 m 1.98476 0.0114313 2.01062 In[5]:= nlm[ParameterConfidenceIntervals] Out[5]= {{2.99614, 3.00095}, {1.9589, 2.01062}} For additional information about NonlinearModelFit and available properties, you can refer to the following: http://reference.wolfram.com/mathematica/ref/NonlinearModelFit.html http://reference.wolfram.com/mathematica/tutorial/StatisticalModelAnalysis.h tml In version 6, you can use the NonlinearRegress function in the NonlinearRegression` package to fit the function and get confidence intervals. Darren Glosemeyer Wolfram Research === Subject: Re: Fitting a Function with no closed form Hi Adam, you can calculate data pairs: d={{x1,y1},{x2,y2}..} You also have the specified function F[x,p1,p2], where p1 and p2 are the parameter to fit. Then you can calculate the parameters by e.g.: FindFit[d,F[x,p1,p2],{p1,p2},x] Here is an example: d = Table[{x, RandomReal[{-1, 1}] + 2 Exp[0.1 x]}, {x, 0, 10}]; F[x_, p1_, p2_] := p1 Exp[p2 x]; FindFit[d, F[x, p1, p2], {p1, p2}, x] Daniel > I have a histogram which I am trying to fit with a convoluted function. I get out the list of bin counts easy enough, but I can't figure out a way > to fit the function to the data. This is the function: > F(x)=Re[NIntegrate [normalizer*(E0 - u)^2 Sqrt[1 - m^2/(E0 - u)^2]*Exp[(-((x > - u)^2/(2 [Sigma]^2)))/(Sqrt[2 [Pi]] [Sigma])], {u, 0, E0}]] > E0 and sigma are known constants. Normalize and m are the fitting > parameters. I can get a plot or of a table of values out of the function by: > Plot[F(x),{x, minRange, maxRange}] > Table[F(x),{x, minRange, maxRange, binWidth}] Is there a way to fit using a function like this? I would also like to error > bars on the fit parameters. Adam Dally > === Subject: Assuming odd/even functions How can we give Mathematica the information of a function being odd or even, and have it applied automatically or in a Simplify[]? Such that, if e.g. f[y] is odd, the sum f(a)+f(-a) yields zero, the integral Integrate[f[y], {y, -a, a}] vanishes? --Martin === Subject: Re: Assuming odd/even functions Hi Martin, there is an options of Simplify: TransformationFunctions, that tells Simplify what to try. You may e.g. specify a function that transforms f[-x] into -f[x] for an odd function. Here is an example: t[e_] := e /. f[-x] -> -f[x]; Simplify[f[x] + f[-x], TransformationFunctions -> {Automatic, t}] hope this helps, Daniel > How can we give Mathematica the information of a function being odd or even, and have it applied automatically or in a Simplify[]? Such that, if e.g. f[y] is odd, the sum f(a)+f(-a) yields zero, the > integral Integrate[f[y], {y, -a, a}] vanishes? --Martin > === Subject: Re: Fast calculation of pair correlation function Hi Marcus, It seems that there is no way around computing all pair distances, so essentially we need a good old doubly nested loop. The code below may however be faster than the naively implemented nested loop - anyway, the best I could figure: In[1] = Clear[pairDistanceDistribution]; pairDistanceDistribution[ iter : {start_?NumericQ, end_?NumericQ, delta_?NumericQ}, points : {{_?NumericQ, _?NumericQ, _?NumericQ} ..}] := With[{len = Length[points]}, 2/(len*(len - 1))* N[Total[ MapIndexed[ BinCounts[ Sqrt@Total[(Transpose[Drop[points, First[#2]]] - #)^2] ], iter] &, points]]]]; What is being done here is that for every point, distances to all points after it are computed at once and immediately binned, so that they don't take space. All the binned results are then summed together to form the final distribution. You give this function your parameters (the distance interval and the delta), plus your list of generated 3D points. It returns the accordingly binned distribution. Here are 2000 random points (each of the 3 coordinates is random in the interval (-10,10)): In[2] = positions = RandomReal[{-10, 10}, {2000, 3}]; It takes about 8 sec. on my not too fast 5-years old P IV laptop: In[3] = (distr = pairDistanceDistribution[{0, 40, 1.}, positions]) // Timing Out[3] = {8.252, {0.000504752, 0.00324262, 0.00828264, 0.0149035, 0.0221901, 0.0304032, 0.0385338, 0.046089, 0.0538494, 0.0599565, 0.0653697, 0.0693417, 0.0716418, 0.0727229, 0.0724892, 0.0691691, 0.0650805, 0.0583087, 0.0500475, 0.0406423, 0.0302661, 0.0215503, 0.0144322, 0.00927564, 0.00569185, 0.0032051, 0.00163432, 0.000715358, 0.000301651, 0.000121061, 0.0000325163, 3.50175*10^-6, 1.50075*10^-6, 0., 0., 0., 0., 0., 0., 0.}} The distribution is normalized to 1: In[4] = Total[distr] Out[4] = 1. Internal compilation probably will not help all that much, since we vectorized the problem anyway. The complexity is of course quadratic with the size of your sample, but there seems to be no way around it. For a sample of 10000 points, my machine will then do it in roughly 3-4 minutes, and the modern fast desktop will probably be 3-4 times faster. Finally, it seems that your problem can be parallelized quite well, you may try parallel constructs in Mathematica to further speed it up, if you have a multi-core machine. Leonid I have a quite large list (length ~ 10,000) of coordinates (positions > {x2,y2,z2},...}, and I am looking for fast way to calculate the pair > correlation or radial distribution function, which tells me, for > epsilon). > Usually, this can be calculated by something like: Do[Do[histogr[[ Ceiling[Norm[ data[[i]]-data[[j]] ] / delta] ]], {j, i > +1, Length[data]}], {i, 1, Length[data]-1}] where histogr is just a list whose index corresponds to the distance > r. Unfortunately I have found that for lists of length >1,000, this way > of calculating is very slow (it can take ~minutes), compared to the > equivalent C code, which proceeds in a few seconds. I have also tried > to Compile the function, but the speed does not increase... Does anybody know some fast way of calculating the pair distribution > function in Mathematica? === Subject: Re: Fast calculation of pair correlation function I have a quite large list (length ~ 10,000) of coordinates (positions > {x2,y2,z2},...}, and I am looking for fast way to calculate the pair > correlation or radial distribution function, which tells me, for > epsilon). > Usually, this can be calculated by something like: Do[Do[histogr[[ Ceiling[Norm[ data[[i]]-data[[j]] ] / delta] ]], {j, i > +1, Length[data]}], {i, 1, Length[data]-1}] where histogr is just a list whose index corresponds to the distance > r. Unfortunately I have found that for lists of length >1,000, this way > of calculating is very slow (it can take ~minutes), compared to the > equivalent C code, which proceeds in a few seconds. I have also tried > to Compile the function, but the speed does not increase... Does anybody know some fast way of calculating the pair distribution > function in Mathematica? I am a bit unclear as to what you ultimately want. maybe a histogram, say, with respect to some fixed epsilon value? Or maybe you need to evaluate the RDF for various different {r,eps} pairs? For lists up to 5K or so in size (larger, on 64 bit machines), it would make sense to preprocess to get the full list of (sorted) distances. The code below seems to be reasonably efficient for finding all distances between pairs and sorting. distancesC = Compile[{{ll,_Real,2}}, Sort[Flatten[Table[Sqrt[#.#]&[(ll[[j]]-ll[[k]])], {j,Length[ll]}, {k,Length[ll]}]]]] Example on a set of 3000 points. dim = 3; coords = RandomReal[{-20,20}, {3000,dim}]; In[4]:= Timing[norms = distancesC[coords];] Out[4]= {11.8582, Null} For the situation where you may be interested in many distances and different epsiolons, I'd recommend a divide-and-conquer search. The code below will do this. Note we divide by two because we used each point pair twice. Alternatives would be to use Union in distancesC but this can cause trouble if you allow multiple points at the same coordinates (I'm guessing you do not, in which case modify the code as appropriate). radialDistributionC = Compile[ {{dlist,_Real,1}, {r,_Real}, {eps,_Real}}, Catch[Module[ {len=Length[dlist],bot=r-eps,top=r+eps,lo=1,mid,hi}, hi = len; If [dlist[[lo]]>top || dlist[[hi]]lo, If [dlist[[mid]]top && midtop, hi = mid; mid = Floor[(hi+lo)/2.], mid = Ceiling[(mid+hi)/2.]; ]]; Round[(hi-lo+1)/2] ]]]; Now we'll find out how many pairs are separated by distance 11.2 +- 0.05. In[7]:= Timing[radialDistributionC[norms,11.2,.05]] Out[7]= {0., 6861} This might be fast enough for your purposes but you will need considerable memory to get it to work for sets of 10^4 points. For that you might consider splitting into sublists, doing computations like those above on sublist pairs, and combining results. Alternatively, there might be approaches that use Nearest or other functionality that avoids creating an nxn matrix from the n points. I did try this on a 64 bit machine, with a list of 10^4 points. It took around 134 seconds to compute the distance pairs, and a single query was as below: In[6]:= Timing[radialDistributionC[norms,11.2,.05]] Out[6]= {0.001, 78500} Daniel Lichtblau Wolfram Research === Subject: Re: Fast calculation of pair correlation function I have a quite large list (length ~ 10,000) of coordinates (positions > {x2,y2,z2},...}, and I am looking for fast way to calculate the pair > correlation or radial distribution function, which tells me, for > epsilon). > Usually, this can be calculated by something like: Do[Do[histogr[[ Ceiling[Norm[ data[[i]]-data[[j]] ] / delta] ]], {j, i > +1, Length[data]}], {i, 1, Length[data]-1}] where histogr is just a list whose index corresponds to the distance > r. Unfortunately I have found that for lists of length >1,000, this way > of calculating is very slow (it can take ~minutes), compared to the > equivalent C code, which proceeds in a few seconds. I have also tried > to Compile the function, but the speed does not increase... Does anybody know some fast way of calculating the pair distribution > function in Mathematica? The code you provide doesn't compute the count, did you want to increment the value of histogr[[i]]? At any rate it seems faster to compute work recursively along the diagonals of the matrix like this: In[172]:= data=RandomReal[{-1.,1.},{1000,3}]; histogr=Range[1,35]; delta=0.1; Timing[Do[Do[histogr[[Ceiling[Norm[data[[i]]-data[[j]]]/delta]]],{j,i +1,Length[data]}],{i,1,Length[data]-1}];] Block[{reclim=$RecursionLimit,ret},$RecursionLimit=Infinity;ret=Timing [{histogr[[#]]&/@Ceiling[Norm[#1-#2]/delta],Sequence@@If[Length[#1] >1,#0[Most[#1],Rest[#2]],{}]}&[Most[data],Rest[data]];]; $RecursionLimit=reclim;ret] Out[175]= {7.35285,Null} Out[176]= {0.25028,Null} You can also significantly speed up your code by reducing the number of times the same object is indexed and using Outer to thread the subtraction over your list, this method returns the data in the same order as your original function: In[219]:= data=RandomReal[{-1.,1.},{1000,3}]; histogr=Range[1,35]; delta=0.1; Timing[Do[Do[histogr[[Ceiling[Norm[data[[i]]-data[[j]]]/delta]]],{j,i +1,Length[data]}],{i,1,Length[data]-1}];] Timing[Do[Block[{x={data[[i]]}},histogr[[#]]&/@Ceiling[Norm[Flatten [Outer[Subtract,x,data[[Range[i+1,Length[data]]]],1],1]]/delta]],{i, 1,Length[data]-1}];] Out[222]= {7.30233,Null} Out[223]= {0.807352,Null} === Subject: Fast calculation of pair correlation function I have a quite large list (length ~ 10,000) of coordinates (positions {x2,y2,z2},...}, and I am looking for fast way to calculate the pair correlation or radial distribution function, which tells me, for epsilon). Usually, this can be calculated by something like: Do[Do[histogr[[ Ceiling[Norm[ data[[i]]-data[[j]] ] / delta] ]], {j, i +1, Length[data]}], {i, 1, Length[data]-1}] where histogr is just a list whose index corresponds to the distance r. Unfortunately I have found that for lists of length >1,000, this way of calculating is very slow (it can take ~minutes), compared to the equivalent C code, which proceeds in a few seconds. I have also tried to Compile the function, but the speed does not increase... Does anybody know some fast way of calculating the pair distribution function in Mathematica? === Subject: Re: Fast calculation of pair correlation function Hi again, My previous post contained erroneous thinking from me - with function Outer all the distances will be computed twice, between points (a,b) but also between (b,a). Better solution would be to use e.g. rlist = Flatten[Table[Map[Norm, Drop[data,i]-Drop[data,-i]], {i, n-1}]] with 5 000 points it takes about 56 secs. Antti === Subject: Re: Fast calculation of pair correlation function thank you all for your answers! I hope in the next days I have time to check all of them and tell you... To clarify, what I wanted to achive with my code is a histogram the sample, seperated by a distance r+-deltaR (where deltaR is very distance r apart). For example, when you have a crystal and the positions in my data sample represent the atoms, you will end up with a histogram consisting of more of less sharp peaks, since the And there was also a little mistake in my code (as Sseziwa pointed out): of course the value of the histogram must be increased whenever histogr[[ ... ]]++ -Markus === Subject: Re: Fast calculation of pair correlation function I have a quite large list (length ~ 10,000) of coordinates (positions > {x2,y2,z2},...}, and I am looking for fast way to calculate the pair > correlation or radial distribution function, which tells me, for > epsilon). > Usually, this can be calculated by something like: Do[Do[histogr[[ Ceiling[Norm[ data[[i]]-data[[j]] ] / delta] ]], {j, i > +1, Length[data]}], {i, 1, Length[data]-1}] where histogr is just a list whose index corresponds to the distance > r. Unfortunately I have found that for lists of length >1,000, this way > of calculating is very slow (it can take ~minutes), compared to the > equivalent C code, which proceeds in a few seconds. I have also tried > to Compile the function, but the speed does not increase... Does anybody know some fast way of calculating the pair distribution > function in Mathematica? The time scales roughly as n^2. Note that it wants the x, y, and z vectors passed separately. It returns a list of frequency counts for bins whose upper bounds are w, 2*w, ..., m@w, where m*w is at least twice the distance from the centroid to the point farthest from the centroid. func = Compile[{{x,_Real,1},{y,_Real,1},{z,_Real,1},{w,_Real}}, Module[{n,m,f}, n = Length@x; m = Ceiling[2./w * Sqrt@Max[(x-Tr@x/n)^2 + (y-Tr@y/n)^2 + (z-Tr@z/n)^2]]; f = Table[0,{m}]; Do[Scan[f[[#]]++&, Ceiling[Sqrt[ (Drop[x,i]-x[[i]])^2 + (Drop[y,i]-y[[i]])^2 + (Drop[z,i]-z[[i]])^2]/w]], {i,n-1}]; f]] === Subject: Re: ListPlotVectorField3D It looks OK to me. Perhaps your file is the source of the error. Can't see what's in it. Did you include the needed package? << VectorFieldPlots`; > Hi every body, I first using mathematica 5 . > I want to make the vectorfield 3D using the command Flatten and > Table. Clear[Global`*] > Clear[mytest] > mytest = Flatten[ > Table[{{i, j, k}, Read[ D:dede_research200913-15A.txt, > {Real, Real, Real}]}, {i, 40}, {j, 10}, {k, 1}], 2]; > ListPlotVectorField3D[mytest, VectorHeads -> True, PlotRange -> All] But the program is not working Can Help my problem? === Subject: Been doing real-time measurements with Mathematica! (Wii Balance Just wanted to report that for the first time in my life I've been using Mathematica to do actual real-time measurements in an experiment that I'm currently performing. Jay! I'm using a Wii balance board (from the Wii fit game) to measure changes in my subjects' centre of gravity. The Wii Balance Board connects through bluetooth to my laptop. Using glovepie_download) and PPJoy (http://www.geocities.com/deonvdw/Docs/ converted to a virtual Windows joystick X,Y values which can be read directly and easily using Mathematica's ControllerState function. This gets me about 400 samples per second. A real-time plot of the user's motions reduces it to about 20 Hz. Still not bad at all, and very useful. Works for the Wiimote (acceleration sensors!) as well. === Subject: Re: Been doing real-time measurements with Mathematica! (Wii Balance On Apr 15, 1:58 am, Sjoerd C. de Vries using Mathematica to do actual real-time measurements in an experiment > that I'm currently performing. Jay! I'm using a Wii balance board (from the Wii fit game) to measure > changes in my subjects' centre of gravity. The Wii Balance Board connects through bluetooth to my laptop. Using > glovepie_download) and PPJoy (http://www.geocities.com/deonvdw/Docs/ > converted to a virtual Windows joystick X,Y values which can be read > directly and easily using Mathematica's ControllerState function. This gets me about 400 samples per second. A real-time plot of the > user's motions reduces it to about 20 Hz. Still not bad at all, and > very useful. Works for the Wiimote (acceleration sensors!) as well. > Anyone else find it a little limiting that one needs to virtualize devices to a joystick before Mathematica can access it through controller-state? Perhaps I've been looking in the wrong places, but I'd very much appreciate documentation towards writing new Mathematica drivers for unrecognized controllers. Barring that, anyone familiar with similar joystick virtualization under mac os X? Best, JJ === Subject: Re: Weather data options data = WeatherData[KMDZ, #, {{2008, 12, 25}, {2008, 12, 28}, Day}] & /@ {MeanTemperature, TotalPrecipitation, MeanPressure} Grouped by date: Transpose[data] Bob Hanlon i have problem in using weather data options in Mathematica. i mean i dont know how to apply more options in a a single command. if i want to acess for example both TotalPrecipitation and cloudTypes or NearestStations of a city records, i face an error report. === Subject: Re: Uninstalling Mathematica from Linux Assuming that Mathematica was installed in the default location, open a shell and cd to /usr/local/Wolfram/Mathematica. There you will find the installation for each version of Mathematica. Remove version 6 with sudo rm -rf 6.0 (no quotes). If you don't have su privelages then ask someone who does. In addition a number of links are created in /usr/local/bin that you may want to remove. Lastly in your home directory you will find a .Mathematica directory which should contain your user installed packages etc and customizations. Remove this if you want. Yas > Could anybody, please, tell me how to remove Mathematica 6 from Linux > (I have Ubuntu 8.10)? === Subject: Uninstalling Mathematica from Linux Could anybody, please, tell me how to remove Mathematica 6 from Linux (I have Ubuntu 8.10)? === Subject: Re: Uninstalling Mathematica from Linux Problem solved. Thread ended. === Subject: Re: Uninstalling Mathematica from Linux remove the /user/local/Wolfram/Mathematica/ directory and the sripts in /usr/local/bin, i.e., mathematica, mcc, math but you should keep Mathematica and remove Ubuntu ;-) Jens Jens > Could anybody, please, tell me how to remove Mathematica 6 from Linux > (I have Ubuntu 8.10)? > === Subject: Plotting a x,y,z function I needed help plotting the following function: f[x_,y_,z_] = (x^2+y^2+z^2) e^-(r^2/2) ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}] does not work because it doesn't understand what r (radius) is....what is the keyword/whatever for radius? Or do I have to define r in terms of x,y,z somehow?! Help with syntax will be great! === Subject: Re: Plotting a x,y,z function Of course you have to specify that r = Sqrt[x^2+y^2+z^2]. r is just a letter that sometimes is used to denote radius but it may serve millions of other purposes. How do you think Mathematica could guess what you're using it for? r[x_, y_, z_] = Sqrt[x^2 + y^2 + z^2]; f[x_, y_, z_] = (x^2 + y^2 + z^2) E^-(r[x, y, z]^2/2); ContourPlot3D[f[x, y, z], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}] In your definition of f you used the lowercase e which hasn't a special meaning, use esc-ee-esc or E instead. > I needed help plotting the following function: f[x_,y_,z_] = (x^2+y^2+z^2) e^-(r^2/2) ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2], {x, -10, 10}, {y, -10, > 10}, {z, -10, 10}] does not work because it doesn't understand what r (radius) is....what > is the keyword/whatever for radius? Or do I have to define r in terms > of x,y,z somehow?! Help with syntax will be great! > === Subject: Re: Plotting a x,y,z function you have to define what you mean with r Jens > I needed help plotting the following function: f[x_,y_,z_] = (x^2+y^2+z^2) e^-(r^2/2) ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2], {x, -10, 10}, {y, -10, > 10}, {z, -10, 10}] does not work because it doesn't understand what r (radius) is....what > is the keyword/whatever for radius? Or do I have to define r in terms > of x,y,z somehow?! Help with syntax will be great! === Subject: Re: Plotting a x,y,z function You have to provide a value for r. ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2 /. r -> 1], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}] But varying r doesn't seem to do much Manipulate[ ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}, Mesh -> False], {r, 1, 10}] > I needed help plotting the following function: f[x_,y_,z_] = (x^2+y^2+z^2) e^-(r^2/2) ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2], {x, -10, 10}, {y, -10, > 10}, {z, -10, 10}] does not work because it doesn't understand what r (radius) is....what > is the keyword/whatever for radius? Or do I have to define r in terms > of x,y,z somehow?! Help with syntax will be great! > === Subject: Re: Plotting a x,y,z function That's not Mathematica syntax... it's YOUR math problem. If you don't know what r is about, how could we possibly know? That said, it's POSSIBLE you want r^2 to be x^2 + y^2. Bobby > I needed help plotting the following function: f[x_,y_,z_] = (x^2+y^2+z^2) e^-(r^2/2) ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2], {x, -10, 10}, {y, -10, > 10}, {z, -10, 10}] does not work because it doesn't understand what r (radius) is....what > is the keyword/whatever for radius? Or do I have to define r in terms > of x,y,z somehow?! Help with syntax will be great! -- DrMajorBob@bigfoot.com === Subject: Re: Plotting a x,y,z function I assume the function you want to plot is: f[r_]:= r^2 Exp[-r^2/2]. But as this function only depends on r, the Contour surfaces will simply be spheres. Therefore the only thing to plot is Plot[f[r],{r,0,5}] Daniel > I needed help plotting the following function: f[x_,y_,z_] = (x^2+y^2+z^2) e^-(r^2/2) ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2], {x, -10, 10}, {y, -10, > 10}, {z, -10, 10}] does not work because it doesn't understand what r (radius) is....what > is the keyword/whatever for radius? Or do I have to define r in terms > of x,y,z somehow?! Help with syntax will be great! === Subject: axis label position The default position for axis labels in Mathematica is at the end of the axes. However, I need to make a plot with the x-axis label below the x axis and the y-axis to the left (not at the top). Is there some axes label format specification that controls this? So far, I have found two potential solutions, and neither of them are ideal: -I can instead use Text[] to put a label at the location of my choosing and then use Show[] to show the plot and the label together. The problem with this is that the plot axes get extended to accomodate these new graphics objects (the labels). I just want an x and y axis that begin at the origin and extend to positive values. Showing the labels makes them extend to negative values as well, which isn't very astheticaly pleasing. -What I want to do also seems possible with Frame, since FrameLabel produces the kinds of labels that I want. But to use frame I need to suppress the upper and right parts (i.e., so that I'm left with just an x and y axis). The command for this: Frame->{{True,False},{True,False}} does not seem to work on the version of Mathematica (5.2) installed on this computer system. Is there an easier/cleaner way to do this? === Subject: Re: axis label position > The default position for axis labels in Mathematica is at the end of the axes. However, I need to make a plot with the x-axis label below the x axis and the y-axis to the left (not at the top). Is there some axes label format specification that controls this? So far, I have found two potential solutions, and neither of them are ideal: -I can instead use Text[] to put a label at the location of my choosing and then use Show[] to show the plot and the label together. The problem with this is that the plot axes get extended to accomodate these new graphics objects (the labels). I just want an x and y axis that begin at the origin and extend to positive values. Showing the labels makes them extend to negative values as well, which isn't very astheticaly pleasing. -What I want to do also seems possible with Frame, since FrameLabel produces the kinds of labels that I want. > But to use frame I need to suppress the upper and right parts (i.e., so that I'm left with just an x and y axis). The command for this: Frame->{{True,False},{True,False}} > does not seem to work on the version of Mathematica (5.2) installed on this computer system. Is there an easier/cleaner way to do this? using the correct syntax (it might not be obvious but I think is documented) will make the Frame solution work (on every version since at least 4.2): Plot[x, {x, 0, 1}, Frame -> {True, True, False, False}, FrameLabel -> {x, y}] hth, albert === Subject: Problems in plotting Lyapunov Exponents: Hi I have been trying to debug the following piece of code to plot Lyapunov Exponents, but getting several errors. ---------------------------------------------------------------------------- ------------------- In[1]:=LypHS=Compile[{l, xinit, {n, _Complex}, {ndrop, _Complex}}, xlist=Drop[ NestList[-30000l+(1-l)#+l*(2858.16/(#-500)^0.82)&, xinit, n], ndrop+1]; Apply[Plus, Log[Abs[(1-l)-l(2343.71/(xlist-500)^1.82)]]]/ Length[xlist]]; Plot[LypHS[l, 10, 5000, 100], {l, 0.0, 1.0}] ---------------------------------------------------------------------------- ------------------- Can anyone try to run it and help me to fix these errors ? Or is any better code is possible for this problem ? ---------------------------------------------------------------------------- ------------------- === Subject: Re: Problems in plotting Lyapunov Exponents: you should read the manual about Compile. n and ndrop should be integer not complex numbers. Further you need to declare the complex list xlist. Here is a corrected version: LypHS = Compile[{l, xinit, {n, _Integer}, {ndrop, _Integer}}, xlist = Drop[ NestList[-30000 l + (1 - l) # + l*(2858.16/(# - 500)^0.82) &, xinit, n] , ndrop + 1]; Apply[Plus, Log[Abs[(1 - l) - l (2343.71/(xlist - 500)^1.82)]]]/ Length[xlist] , {{xlist, _Complex, 1}}]; Plot[LypHS[l, 10, 5000, 100], {l, 0.0, 1.0}] Daniel > Hi > I have been trying to debug the following piece of code > to plot Lyapunov Exponents, but getting several errors. > ----------------------------------------------------------------------------- ------------------ > In[1]:=LypHS=Compile[{l, xinit, {n, _Complex}, {ndrop, _Complex}}, > xlist=Drop[ > NestList[-30000l+(1-l)#+l*(2858.16/(#-500)^0.82)&, xinit, > n], > ndrop+1]; > Apply[Plus, Log[Abs[(1-l)-l(2343.71/(xlist-500)^1.82)]]]/ > Length[xlist]]; Plot[LypHS[l, 10, 5000, 100], {l, 0.0, 1.0}] > ----------------------------------------------------------------------------- ------------------ > Can anyone try to run it and help me to fix these errors ? > Or is any better code is possible for this problem ? > ----------------------------------------------------------------------------- ------------------ > === Subject: Re: Problems in plotting Lyapunov Exponents: I don't think this is going to work this way. n and ndrop shouldn't be of type Complex, they're Integers. Compile needs to know of xlist as well (3rd argument of Compile), but there is a problem, since it seems that Lists needs to have fixed size (I might be wrong here). > Hi > I have been trying to debug the following piece of code > to plot Lyapunov Exponents, but getting several errors. > -------------------------------------------------------------------------= ---------------------- > In[1]:=LypHS=Compile[{l, xinit, {n, _Complex}, {ndrop, _Complex}}, > xlist=Drop[ > NestList[-30000l+(1-l)#+l*(2858.16/(#-500)^0.82)&, xi= nit, > n], > ndrop+1]; > Apply[Plus, Log[Abs[(1-l)-l(2343.71/(xlist-500)^1.82)]]]/ > Length[xlist]]; Plot[LypHS[l, 10, 5000, 100], {l, 0.0, 1.0}] > -------------------------------------------------------------------------= ---------------------- > Can anyone try to run it and help me to fix these errors ? > Or is any better code is possible for this problem ? > -------------------------------------------------------------------------= ---------------------- === Subject: hyperlink problem in a ActionMenu hi, Way does this ActionMenu fail to work: ActionMenu[help, {Plotwww :> Hyperlink[ http://reference.wolfram.com/mathematica/ ref/Hyperlink.html], PlotLocal :> Hyperlink[paclet:ref/Plot]}] Nothing happens when I select the menuitems. What is missing in my Andrew === Subject: Re: hyperlink problem in a ActionMenu you are misusing Hyperlink. This creates a string that must be clicked to open the URL. What you want is: SystemOpen. Daniel > hi, Way does this ActionMenu fail to work: ActionMenu[help, > {Plotwww :> Hyperlink[ http://reference.wolfram.com/mathematica/ > ref/Hyperlink.html], > PlotLocal :> Hyperlink[paclet:ref/Plot]}] Nothing happens when I select the menuitems. What is missing in my Andrew > === Subject: Re: hyperlink problem in a ActionMenu It doesn't work because Hyperlink doesn't represent an action. It's a link, but not a click on a link. Use SystemOpen instead: ActionMenu[help, {Plotwww :> SystemOpen[http://reference.wolfram.com/mathematica/ ref/Hyperlink.html], PlotLocal :> SystemOpen[paclet:ref/Plot]}] > hi, Way does this ActionMenu fail to work: ActionMenu[help, > {Plotwww :> Hyperlink[ http://reference.wolfram.com/mathematica/ > ref/Hyperlink.html], > PlotLocal :> Hyperlink[paclet:ref/Plot]}] Nothing happens when I select the menuitems. What is missing in my Andrew === Subject: Re: hyperlink problem in a ActionMenu ActionMenu[] performs the command you give it without producing output (although it's okay for the command to have side effects which output something). The command you gave it was to give as output a clickable button which goes someplace. So, it's quite correctly doing nothing as a result. What you probably want is the command which performs the action a hyperlink performs when you've actually clicked on it. That command is SystemOpen. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. -----Original Message----- [mailto:l-mathgroup-bounces@wolfram.com] On Behalf Of meitnik === Subject: hyperlink problem in a ActionMenu hi, Way does this ActionMenu fail to work: ActionMenu[help, {Plotwww :> Hyperlink[ http://reference.wolfram.com/mathematica/ ref/Hyperlink.html], PlotLocal :> Hyperlink[paclet:ref/Plot]}] Nothing happens when I select the menuitems. What is missing in my Andrew === Subject: Re: hyperlink problem in a ActionMenu > hi, Way does this ActionMenu fail to work: ActionMenu[help, > {Plotwww :> Hyperlink[ http://reference.wolfram.com/mathematica/ > ref/Hyperlink.html], > PlotLocal :> Hyperlink[paclet:ref/Plot]}] Nothing happens when I select the menuitems. What is missing in my When the action menu item is selected that item's action is performed. Hyperlink[] does not itself open the hyperlink. Hyperlink evaluates to an expression which, when typset in the Mathematica user interface, gives the visual appearance of a hyperlink and which, when clicked, performs the action of opening the hyperlink. What you're looking for is the code which Hyperlink[] uses to perform its action. Try this instead: ActionMenu[help, {Plotwww :> SystemOpen[ http://reference.wolfram.com/mathematica/ref/Hyperlink.html], PlotLocal :> Documentation`HelpLookup[paclet:ref/Plot]}] -Rob === Subject: Re: hyperlink problem in a ActionMenu Hyperlink creates a textual object in a notebook that one clicks on to go to the link. It does not of itself, when executed, cause the link to be followed. --David > hi, Way does this ActionMenu fail to work: ActionMenu[help, > {Plotwww :> Hyperlink[ http://reference.wolfram.com/mathematica/ > ref/Hyperlink.html], > PlotLocal :> Hyperlink[paclet:ref/Plot]}] Nothing happens when I select the menuitems. What is missing in my Andrew === Subject: Re: PlotLegends bug? Windows XP. Today I have upgraded to version 7.0.1 and all is working properly. Jakub > -----Original Message----- === > Subject: PlotLegends bug? I wanted to export some ListLogLinearPlots with legends > (using = PlotLegends > package) as images today, but Mathematica exports just blank > images (on display the images are OK). Here is example code > (in reality I have more curves in one image so I realy need > the legends): > Needs[PlotLegends`] > data = {{16.`, -24.`}, {20.`, -23.`}, {25.`, -22.`}, {31.5`, > -21.`}, {40.`, -20.`}, {50.`, -20.`}, {63.`, -19.`}, {80.`, > -18.`}, {100.`, -13.`}, {125.`, -12.`}, {160.`, -10.`}, > {200.`, -8.`}, {250.`, -6.`}, {315.`, -5.`}, {400.`, -3.`}, > {500.`, -2.`}, {630.`, -1.`}, {800.`, -0.5`}, {1000.`, > 0.`}, {1250.`, -0.5`}, {1600.`, -0.5`}, {2000.`, -1.`}, > {2500.`, -1.5`}, {3150.`, -2.5`}, {4000.`, -3.5`}, {5000.`, > -5.`}, {6300.`, -6.5`}, {8000.`, -8.`}, {10000.`, -10.`}, > {12500.`, -12.`}, {16000.`, -14.`}, {20000.`, -15.`}, > {25000.`, -17.`}, {31500.`, -19.`}, {40000.`, -20.`}, > {50000.`, -21.`}, {63000.`, -22.`}, {80000.`, -23.`}, > {100000.`, -24.`}}; image = ListLogLinearPlot[data, > Joined -> True, > InterpolationOrder -> 2, > GridLines -> Automatic, > LegendPosition -> {1.1, -0.4}, > AxesLabel -> {Style[f [Hz], Bold, 18], > Style[!(*SubscriptBox[A, u]) [dB], Bold, 18]}, > LabelStyle -> Medium, > PlotLegend -> Style[data, Bold, 18], > PlotStyle -> Thick, > LegendSize -> 0.5, > ImageSize -> {1000, 600}] > Export[image.png, image] If I comment out all the options related to PlotLegends, the > Export = works just fine: image = ListLogLinearPlot[data, > Joined -> True, > InterpolationOrder -> 2, > GridLines -> Automatic, > (*LegendPosition->{1.1,-0.4},*) > AxesLabel -> {Style[f [Hz], Bold, 18], > Style[!(*SubscriptBox[A, u]) [dB], Bold, 18]}, > LabelStyle -> Medium, > (*PlotLegend->Style[data,Bold,18],*) > PlotStyle -> Thick, > (*LegendSize->0.5,*) > ImageSize -> {1000, 600}] > Export[image.png, image] Also it is not possible to Ctrl-C the image from the screen > and paste it = to the image editor (the pasted result is also = blank). > Does somebody see any bug in my code or there is the bug in > PlotLegends package? > Jakub === Subject: Re: Should I be using Mathematica at all? respectfully, I don't think this is quite right although I see what you are getting at. C++ is platform independent and free, unless you chose to tie yourself in to particular proprietary Libraries or IDEs. Peter 2009/4/14 Joseph Gwinn : > Hello again, >> I have had several questions answered by this group, for which I am very >> grateful. Now I have a more general topic, which I know will not have >> single, clear answers. I just would like to hear your opinions. >> I have some (fairly complicated) legacy Mathematica v5 software which we >> currently use in-house. Our intention is to turn this software into a >> saleable product. At the moment, I am contemplating upgrading to V7, wri= ting >> a GUI for our code (which has no compatibility issues with V7) and >> distributing it using PlayerPro. What is the nature of this product? >> To protect our IP, I will be using Encode to make it impossible for it t= o be >> reverse engineered. Does anyone know how secure this will actually be? I= s it >> more or less secure than a compiled C++ program would be, for instance? = Are >> there any particular issues I should be aware of? >> It turns out that there are some serious problems for us using PlayerPro >> (apart from the price!) which are making us reconsider using Mathematica= at >> all. Top of the list is the inability of Wolfram to offer a trial licens= e >> for PlayerPro. What this would mean is that we would be losing 100 or so >> every time someone ordered a trial version but did not subsequently buy = the >> package, because there is no way for us to get our PlayerPro license bac= k. >> This is not viable. The best Wolfram can offer is to give our prospectiv= e >> client a trial version of the full Mathematica package (say for 15 days)= . As >> a workaround, this is very clunky, when I requested my trial of V7 it= took >> 4 days to get the license. I think that, these days, people expect to go= to >> a website, download a trial version and start working with it immediatel= y. >> So, I am considering our options, in particular open source code, such a= s >> C++, and I'd be interested in your opinions about this. Our V5 code does= n't >> involve any exotic maths, but it makes extensive use of SetDelayed, and >> these definitions are frequently nested within long and complicated Do >> loops. Speed is crucial to our application, so is there any, in principl= e, >> reason why Mathematica might be able to do things significantly faster t= han >> a compiled C++ program (assuming the C++ code is written by someone who >> knows what they are doing)? Is there a better language than C++, bearing= in >> mind the need to compile (or encode in some way) and distribute the >> resulting code? I know there used to be a compiler for Mathematica once = upon >> a time, is there any easy way to get from mathematica code to a compilab= le >> program. I should stress that we are very happy with Mathematica in term= s of >> developing our application, it's just generating anything that we could = sell >> that is problematical. >> I have some experience of writing VB, Visual C and similar applications,= but >> these never had a large graphical content. Our code will require a lot o= f >> plotting of data (2D only, but lots of curves which need to be interacti= ve >> in some sense). Mathematica can do everything we want in this respect, b= ut I >> am less sure about the open source code. I am sure there are add-on >> packages, but never having used them I don't know whether they can match >> Mathematica's built in abilities, any comments? The big issue with translation to C++ or any other language to to avoid > lock-in to either Windows or to the compiler make and model. If lock-i= n > is permitted, especially to Windows, every time MS burps you will be > forced to play catch-up. While C++ is in theory standardized, there ar= e > significant differences in what C++ compilers will accept. Use of the = C > subset of C++ is usually far less stressful, and allows for graceful > transition should the compiler vendor go to find his guru. Platform independence also helps when negotiating with platform and > compiler vendors. To avoid lock-in, one must do all testing on at least two platform kinds > using compilers from at least two makers. It isn't enough to make > platform independence a goal, one must directly test for independence, > as its very easy for dependencies to creep in unnoticed. Choice of platforms: If one covers Windows, MacOS, and UNIX/Linux, one > has covered 99%. Going from one platform to two is the big step. > Adding the third isn't that much harder to achieve, although testing is > still an expense. Joe Gwinn -- Peter Lindsay === Subject: Re: Should I be using Mathematica at all? > respectfully, I don't think this is quite right although I see what > you are getting at. C++ is platform independent and free, unless you > chose to tie yourself in to particular proprietary Libraries or IDEs. C++ in practice is not platform independent at all, unless one goes to considerable effort to ensure independence. You put your finger right on it when you mentioned particular proprietary Libraries or IDEs. On Windows in particular, it can be very difficult to avoid things like ActiveX controls from creeping in and defeating portability and platform independence. And forcing one onto the upgrade treadmill. C, being at least ten times simpler, has far less of this problem, but even so vigilance is required. Joe Gwinn > 2009/4/14 Joseph Gwinn : > Hello again, >> I have had several questions answered by this group, for which I am very >> grateful. Now I have a more general topic, which I know will not have >> single, clear answers. I just would like to hear your opinions. >> I have some (fairly complicated) legacy Mathematica v5 software which we >> currently use in-house. Our intention is to turn this software into a >> saleable product. At the moment, I am contemplating upgrading to V7, wri= > ting >> a GUI for our code (which has no compatibility issues with V7) and >> distributing it using PlayerPro. What is the nature of this product? >> To protect our IP, I will be using Encode to make it impossible for it t= > o be >> reverse engineered. Does anyone know how secure this will actually be? I= > s it >> more or less secure than a compiled C++ program would be, for instance? = > Are >> there any particular issues I should be aware of? >> It turns out that there are some serious problems for us using PlayerPro >> (apart from the price!) which are making us reconsider using Mathematica= > at >> all. Top of the list is the inability of Wolfram to offer a trial licens= > e >> for PlayerPro. What this would mean is that we would be losing 100 or so >> every time someone ordered a trial version but did not subsequently buy = > the >> package, because there is no way for us to get our PlayerPro license bac= > k. >> This is not viable. The best Wolfram can offer is to give our prospectiv= > e >> client a trial version of the full Mathematica package (say for 15 days)= > . As >> a workaround, this is very clunky, when I requested my trial of V7 it= > took >> 4 days to get the license. I think that, these days, people expect to go= > to >> a website, download a trial version and start working with it immediatel= > y. >> So, I am considering our options, in particular open source code, such a= > s >> C++, and I'd be interested in your opinions about this. Our V5 code does= > n't >> involve any exotic maths, but it makes extensive use of SetDelayed, and >> these definitions are frequently nested within long and complicated Do >> loops. Speed is crucial to our application, so is there any, in principl= > e, >> reason why Mathematica might be able to do things significantly faster t= > han >> a compiled C++ program (assuming the C++ code is written by someone who >> knows what they are doing)? Is there a better language than C++, bearing= > in >> mind the need to compile (or encode in some way) and distribute the >> resulting code? I know there used to be a compiler for Mathematica once = > upon >> a time, is there any easy way to get from mathematica code to a compilab= > le >> program. I should stress that we are very happy with Mathematica in term= > s of >> developing our application, it's just generating anything that we could = > sell >> that is problematical. >> I have some experience of writing VB, Visual C and similar applications,= > but >> these never had a large graphical content. Our code will require a lot o= > f >> plotting of data (2D only, but lots of curves which need to be interacti= > ve >> in some sense). Mathematica can do everything we want in this respect, b= > ut I >> am less sure about the open source code. I am sure there are add-on >> packages, but never having used them I don't know whether they can match >> Mathematica's built in abilities, any comments? The big issue with translation to C++ or any other language to to avoid > lock-in to either Windows or to the compiler make and model. If lock-i= > n > is permitted, especially to Windows, every time MS burps you will be > forced to play catch-up. While C++ is in theory standardized, there ar= > e > significant differences in what C++ compilers will accept. Use of the = > C > subset of C++ is usually far less stressful, and allows for graceful > transition should the compiler vendor go to find his guru. Platform independence also helps when negotiating with platform and > compiler vendors. To avoid lock-in, one must do all testing on at least two platform kinds > using compilers from at least two makers. It isn't enough to make > platform independence a goal, one must directly test for independence, > as its very easy for dependencies to creep in unnoticed. Choice of platforms: If one covers Windows, MacOS, and UNIX/Linux, one > has covered 99%. Going from one platform to two is the big step. > Adding the third isn't that much harder to achieve, although testing is > still an expense. Joe Gwinn -- > Peter Lindsay === Subject: Re: Should I be using Mathematica at all? > Hello again, I have had several questions answered by this group, for which I am very > grateful. Now I have a more general topic, which I know will not have > single, clear answers. I just would like to hear your opinions. I have some (fairly complicated) legacy Mathematica v5 software which we > currently use in-house. Our intention is to turn this software into a > saleable product. At the moment, I am contemplating upgrading to V7, writing > a GUI for our code (which has no compatibility issues with V7) and > distributing it using PlayerPro. To protect our IP, I will be using Encode to make it impossible for it to be > reverse engineered. Does anyone know how secure this will actually be? Is it > more or less secure than a compiled C++ program would be, for instance? Are > there any particular issues I should be aware of? It turns out that there are some serious problems for us using PlayerPro > (apart from the price!) which are making us reconsider using Mathematica at > all. Top of the list is the inability of Wolfram to offer a trial license > for PlayerPro. What this would mean is that we would be losing 100 or so > every time someone ordered a trial version but did not subsequently buy the > package, because there is no way for us to get our PlayerPro license back. > This is not viable. The best Wolfram can offer is to give our prospective > client a trial version of the full Mathematica package (say for 15 days). As > a workaround, this is very clunky, when I requested my trial of V7 it took > 4 days to get the license. I think that, these days, people expect to go to > a website, download a trial version and start working with it immediately. So, I am considering our options, in particular open source code, such as > C++, and I'd be interested in your opinions about this. Our V5 code doesn't > involve any exotic maths, but it makes extensive use of SetDelayed, and > these definitions are frequently nested within long and complicated Do > loops. Speed is crucial to our application, so is there any, in principle, > reason why Mathematica might be able to do things significantly faster than > a compiled C++ program (assuming the C++ code is written by someone who > knows what they are doing)? Is there a better language than C++, bearing in > mind the need to compile (or encode in some way) and distribute the > resulting code? I know there used to be a compiler for Mathematica once upon > a time, is there any easy way to get from mathematica code to a compilable > program. I should stress that we are very happy with Mathematica in terms of > developing our application, it's just generating anything that we could sell > that is problematical. I have some experience of writing VB, Visual C and similar applications, but > these never had a large graphical content. Our code will require a lot of > plotting of data (2D only, but lots of curves which need to be interactive > in some sense). Mathematica can do everything we want in this respect, but I > am less sure about the open source code. I am sure there are add-on > packages, but never having used them I don't know whether they can match > Mathematica's built in abilities, any comments? If anyone out there has experience of preparing Mathematica code for sale > using PlayerPro, are there any pitfalls I should know about? Finally, would anyone care to recommend a consultant(s) who could translate > our Mathematica code into C++? I know this is a bit of a vague set of questions, but I'll be happy with > vague answers too! > Clearly, since Mathematica is itself written in C+Mathematica, it is always possible in principle to rewrite code in C and gain performance (often substantial), so what you need to consider is: a) Whether your code uses a feature of Mathematica that requires a lot of work to reproduce in C - e.g. symbolic calculations, extended precision, fancy graphics etc. b) Whether you can afford the time and effort to debug the C code. Java might be a better choice, because at least it is not subject to subtle memory overwriting bugs. If you stay with Mathematica, you might want to use my Super Widget Package to create a Java GUI (it is available free from my website) - which is much easier than using GUIKit (IMHO) - though writing a GUI in Java, and calling it via J/Link is also a good solution. Another approach might be to deliver your solution using Web Mathematica (which might offer greater protection for your IP because your code would not run on the client's PC) - however, I have never used Web Mathematica, so others can advise you in detail. PlayerPro worked well for me, but I did not explore it exhaustively. It requires extra packages to be encoded (to avoid exposing the entire functionality of Matheamatica!), but you will be doing that anyway. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Should I be using Mathematica at all? > Hello again, I have had several questions answered by this group, for which I am very > grateful. Now I have a more general topic, which I know will not have > single, clear answers. I just would like to hear your opinions. I have some (fairly complicated) legacy Mathematica v5 software which we > currently use in-house. Our intention is to turn this software into a > saleable product. At the moment, I am contemplating upgrading to V7, writing > a GUI for our code (which has no compatibility issues with V7) and > distributing it using PlayerPro. What is the nature of this product? > To protect our IP, I will be using Encode to make it impossible for it to be > reverse engineered. Does anyone know how secure this will actually be? Is it > more or less secure than a compiled C++ program would be, for instance? Are > there any particular issues I should be aware of? It turns out that there are some serious problems for us using PlayerPro > (apart from the price!) which are making us reconsider using Mathematica at > all. Top of the list is the inability of Wolfram to offer a trial license > for PlayerPro. What this would mean is that we would be losing 100 or so > every time someone ordered a trial version but did not subsequently buy the > package, because there is no way for us to get our PlayerPro license back. > This is not viable. The best Wolfram can offer is to give our prospective > client a trial version of the full Mathematica package (say for 15 days). As > a workaround, this is very clunky, when I requested my trial of V7 it took > 4 days to get the license. I think that, these days, people expect to go to > a website, download a trial version and start working with it immediately. So, I am considering our options, in particular open source code, such as > C++, and I'd be interested in your opinions about this. Our V5 code doesn't > involve any exotic maths, but it makes extensive use of SetDelayed, and > these definitions are frequently nested within long and complicated Do > loops. Speed is crucial to our application, so is there any, in principle, > reason why Mathematica might be able to do things significantly faster than > a compiled C++ program (assuming the C++ code is written by someone who > knows what they are doing)? Is there a better language than C++, bearing in > mind the need to compile (or encode in some way) and distribute the > resulting code? I know there used to be a compiler for Mathematica once upon > a time, is there any easy way to get from mathematica code to a compilable > program. I should stress that we are very happy with Mathematica in terms of > developing our application, it's just generating anything that we could sell > that is problematical. I have some experience of writing VB, Visual C and similar applications, but > these never had a large graphical content. Our code will require a lot of > plotting of data (2D only, but lots of curves which need to be interactive > in some sense). Mathematica can do everything we want in this respect, but I > am less sure about the open source code. I am sure there are add-on > packages, but never having used them I don't know whether they can match > Mathematica's built in abilities, any comments? The big issue with translation to C++ or any other language to to avoid lock-in to either Windows or to the compiler make and model. If lock-in is permitted, especially to Windows, every time MS burps you will be forced to play catch-up. While C++ is in theory standardized, there are significant differences in what C++ compilers will accept. Use of the C subset of C++ is usually far less stressful, and allows for graceful transition should the compiler vendor go to find his guru. Platform independence also helps when negotiating with platform and compiler vendors. To avoid lock-in, one must do all testing on at least two platform kinds using compilers from at least two makers. It isn't enough to make platform independence a goal, one must directly test for independence, as its very easy for dependencies to creep in unnoticed. Choice of platforms: If one covers Windows, MacOS, and UNIX/Linux, one has covered 99%. Going from one platform to two is the big step. Adding the third isn't that much harder to achieve, although testing is still an expense. Joe Gwinn === Subject: Re: Should I be using Mathematica at all? Hi Paul, > I have had several questions answered by this group, for which I am very > grateful. Now I have a more general topic, which I know will not have > single, clear answers. I just would like to hear your opinions. I have some (fairly complicated) legacy Mathematica v5 software which we > currently use in-house. Our intention is to turn this software into a > saleable product. At the moment, I am contemplating upgrading to V7, writing > a GUI for our code (which has no compatibility issues with V7) and > distributing it using PlayerPro. To protect our IP, I will be using Encode to make it impossible for it to be > reverse engineered. Does anyone know how secure this will actually be? Is it > more or less secure than a compiled C++ program would be, for instance? Are > there any particular issues I should be aware of? I don't know what kind of encryption is used for Encode, but I don't think that that is the weak part of it: since mathematica is a very open system you need some extra protection to inhibit people from reading the code by simply typing Information[function] or something alike. The combination of attributes ReadProtect, Protect, Locked will make this much more difficult, but still not impossible. You might want to use some additional protection but that will as usual be a competition with the one who tries to hack your code which you might or might not win... As with every code you give away, there is no 100% insurance that people will not hack it. If the winnings are high enough there will be a good chance that someone will hack it. If you use encryption with the above attributes I think it will definitely need some criminal effort and nontrivial knowhow to hack it and probably be about as save as delivering compiled code (from whatever compilable language that was generated...) Since Mathematica knowhow is much less spread than hacking in general, I would guess that it would probably be done by hacking the decryption that mathematica does when reading the package (at some stage it will probably have the unencrypted code in memory) and can be studied from anyone running a copy on their machines. > It turns out that there are some serious problems for us using PlayerPro > (apart from the price!) which are making us reconsider using Mathematica at > all. Top of the list is the inability of Wolfram to offer a trial license > for PlayerPro. What this would mean is that we would be losing 100 or so > every time someone ordered a trial version but did not subsequently buy the > package, because there is no way for us to get our PlayerPro license back. > This is not viable. The best Wolfram can offer is to give our prospective > client a trial version of the full Mathematica package (say for 15 days). As > a workaround, this is very clunky, when I requested my trial of V7 it took > 4 days to get the license. I think that, these days, people expect to go to > a website, download a trial version and start working with it immediately. that is really a drawback which of course only WRI can change. I also think that a network license mechanism would be adequate for Player _Pro_ to be fit for rollout in a _Pro_-fessional environment. > So, I am considering our options, in particular open source code, such as > C++, and I'd be interested in your opinions about this. Our V5 code doesn't > involve any exotic maths, but it makes extensive use of SetDelayed, and > these definitions are frequently nested within long and complicated Do > loops. Speed is crucial to our application, so is there any, in principle, > reason why Mathematica might be able to do things significantly faster than > a compiled C++ program (assuming the C++ code is written by someone who > knows what they are doing)? Is there a better language than C++, bearing in > mind the need to compile (or encode in some way) and distribute the > resulting code? I know there used to be a compiler for Mathematica once upon > a time, is there any easy way to get from mathematica code to a compilable > program. I should stress that we are very happy with Mathematica in terms of > developing our application, it's just generating anything that we could sell > that is problematical. I think the crucial question is whether or not any symbolic code needs to run in the delivered code. If yes, you will have a hard time to replace mathematica and probably won't have an option. If what you do is numeric only, it is just a matter of how much work you can spend in the recoding. Concerning speed I would guess that any reasonable written C/C++ code that implements the same algorithm should rather be faster than slower than the corresponding mathematica code -- it might just take much longer to write it... > I have some experience of writing VB, Visual C and similar applications, but > these never had a large graphical content. Our code will require a lot of > plotting of data (2D only, but lots of curves which need to be interactive > in some sense). Mathematica can do everything we want in this respect, but I > am less sure about the open source code. I am sure there are add-on > packages, but never having used them I don't know whether they can match > Mathematica's built in abilities, any comments? there are plenty of libraries for various languages that let you do graphics output. Depending on what you do you might need more than one library, learn each of them and find out under which conditions you can build a commercial application on them. Much work, but certainly possible. What you could consider is to write the pure algorithms in C/C++ (or Java or C#) which would probably solve some concerns with IP. Then you could use rather weakly protected mathematica code to just do the visualization and include the compiled code via MathLink, JLink or NETLink. This shouldn't be too much effort but would need to ensure that this is still supported with the current version of Player Pro. I think it was allowed to at least use JLink and NETLink with Player Pro 6.0. > If anyone out there has experience of preparing Mathematica code for sale > using PlayerPro, are there any pitfalls I should know about? yes I have, and the pitfalls are exactly the ones you have mentioned... hth, albert === Subject: Re: How to build a Tag Cloud Graph? This isn't a homework assignment by any chance? Let say, I have a simple list of sales numbers in different products. > The first element of the sublist is a product, the second is a product > group and the 3rd is the turnover. Like this one: sales={{Beef,Meat, 2343},{Milk,Drink, 234}, {Water,Drink, 234}, {Beer, > Drink, 1546}, {Coke, Drink, 1223}, {Pork, Meat, 1223}} QUESTION: > How to construct a Tag Cloud Plot in the way as it defined in > wikipedia: ...Tags are usually single words and are typically listed > alphabetically, and the importance of a tag is shown with font size or > color... For full details see:http://en.wikipedia.org/wiki/Tag_cloud It should be a frame with words in alphabetical order with different > font color for different product group. Condition: > For displaying products with huge and very small numbers a maximum and > minimum font size should apply. > Plotty === Subject: Re: How to build a Tag Cloud Graph? On 15 Apr., 10:58, Sjoerd C. de Vries Let say, I have a simple list of sales numbers in different products. > The first element of the sublist is a product, the second is a product > group and the 3rd is the turnover. Like this one: sales={{Beef,Meat, 2343},{Milk,Drink, 234}, {Water,Drink, 234}, {Beer, > Drink, 1546}, {Coke, Drink, 1223}, {Pork, Meat, 1223}} QUESTION: > How to construct a Tag Cloud Plot in the way as it defined in > wikipedia: ...Tags are usually single words and are typically listed > alphabetically, and the importance of a tag is shown with font size or > color... For full details see:http://en.wikipedia.org/wiki/Tag_cloud It should be a frame with words in alphabetical order with different > font color for different product group. Condition: > For displaying products with huge and very small numbers a maximum and > minimum font size should apply. > Plotty I swear it isn't! === Subject: Re: How to build a Tag Cloud Graph? Let say, I have a simple list of sales numbers in different products. > The first element of the sublist is a product, the second is a product > group and the 3rd is the turnover. Like this one: sales={{Beef,Meat, 2343},{Milk,Drink, 234}, {Water,Drink, 234}, {Beer, > Drink, 1546}, {Coke, Drink, 1223}, {Pork, Meat, 1223}} QUESTION: > How to construct a Tag Cloud Plot in the way as it defined in > wikipedia: ...Tags are usually single words and are typically listed > alphabetically, and the importance of a tag is shown with font size or > color... For full details see: > http://en.wikipedia.org/wiki/Tag_cloud It should be a frame with words in alphabetical order with different > font color for different product group. Condition: > For displaying products with huge and very small numbers a maximum and > minimum font size should apply. > Plotty > Something like this? color[___] = Black; color[Drink] = Blue; color[Meat] = Pink; maxfont = 100; minfont = 10; Panel[Row[Apply[ Tooltip[ Style[#1, FontFamily -> Helvetica, FontSize -> Max[maxfont*#3/Max[sales[[All, 3]]], minfont], FontColor -> color[#2] ], #3 ] &, SortBy[sales, First], {1} ], Spacer[5] ] ] of course you might want to use something smarter for the font sizes, but that would need more information about what you want to read from that tag cloud... albert === Subject: Re: How to build a Tag Cloud Graph? Let say, I have a simple list of sales numbers in different products. > The first element of the sublist is a product, the second is a product > group and the 3rd is the turnover. Like this one: sales={{Beef,Meat, 2343},{Milk,Drink, 234}, {Water,Drink, 234}, {Beer= , > Drink, 1546}, {Coke, Drink, 1223}, {Pork, Meat, 1223}} QUESTION: > How to construct a Tag Cloud Plot in the way as it defined in > wikipedia: ...Tags are usually single words and are typically listed > alphabetically, and the importance of a tag is shown with font size or > color... For full details see: >http://en.wikipedia.org/wiki/Tag_cloud It should be a frame with words in alphabetical order with different > font color for different product group. Condition: > For displaying products with huge and very small numbers a maximum and > minimum font size should apply. > Plotty Something like this? color[___] = Black; > color[Drink] = Blue; > color[Meat] = Pink; > maxfont = 100; > minfont = 10; > Panel[Row[Apply[ > Tooltip[ > Style[#1, FontFamily -> Helvetica, > FontSize -> Max[maxfont*#3/Max[sales[[All, 3]]], minfont], > FontColor -> color[#2] > ], > #3 > ] &, > SortBy[sales, First], > {1} > ], > Spacer[5] > ] > ] of course you might want to use something smarter for the font sizes, > but that would need more information about what you want to read from > that tag cloud... albert Hi Albert, One more thing: Is it possible to change the background color of a Panel from gray to white? Plotty === Subject: Re: How to build a Tag Cloud Graph? Let say, I have a simple list of sales numbers in different products. > The first element of the sublist is a product, the second is a product > group and the 3rd is the turnover. Like this one: sales={{Beef,Meat, 2343},{Milk,Drink, 234}, {Water,Drink, 234}, {Beer, > Drink, 1546}, {Coke, Drink, 1223}, {Pork, Meat, 1223}} QUESTION: > How to construct a Tag Cloud Plot in the way as it defined in > wikipedia: ...Tags are usually single words and are typically listed > alphabetically, and the importance of a tag is shown with font size or > color... For full details see: > http://en.wikipedia.org/wiki/Tag_cloud It should be a frame with words in alphabetical order with different > font color for different product group. Condition: > For displaying products with huge and very small numbers a maximum and > minimum font size should apply. > Plotty Here's a toy example: len = Length@ CountryData[]; str = CountryData[#, Name]& /@ CountryData[]; sz = Rescale[Rescale[ CountryData[#, Population]& /@ CountryData[] // #^(1/3)&], {0, 1}, {4, 48}]; col = RandomChoice[{Magenta, Darker@ Cyan}, len]; cloud = MapThread[Style[##, Bold]&, {str, sz, col}]; StringJoin@ Riffle[ToString[#, StandardForm]& /@ cloud, ] Maxim Rytin m.r@inbox.ru === Subject: Re: Scrollbars on palettes, Os x. In Windows at least, that's the way it is. The size of the scrollbar thumb is in proportion to the size of the window contents shown. If almost all of the contents are shown the thumb fills almost the whole edge, and if only a small portion of the contents are visible the thumb is small. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have set a palette to WindowElements -> {VerticalScrollBar, StatusArea}. I have noticed the scrollbar fills nearly the whole height of the window. I do have a number of controls to warrant scrolling. Is this a bug, or do I need to set some value for the scrollbar thumb size to become smaller in proportion to the window contents?? === Subject: Scrollbars on palettes, Os x. I have set a palette to WindowElements -> {VerticalScrollBar, StatusArea}. I have noticed the scrollbar fills nearly the whole height of the window. I do have a number of controls to warrant scrolling. Is this a bug, or do I need to set some value for the scrollbar thumb size to become smaller in proportion to the window contents?? === Subject: Re: Importing a large image... > So, my fellow denizens of the group. I have a very large TIFF image--roughly 700MB in size. Its dimension are 43201 by 15601. It is single color with a bit depth > of 8. without maxing out the memory. I actually do not need to read in the whole file: I'd be happen with > being able to break the file into a number of smaller TIFFs which tile > it completely and then process each on independently (I am needing to > act on the data in various ways to yield a processed result for > further analysis down the line). This is all for a larger project > for a consulting client of mine. Any suggestions for how to programmatically carve up the image without > having to completely read it in first? I am looking for quick > solutions rather than ones that require a lot of programming. Either > it can be done pretty simply, or (more likely) Mathematica chokes on > these very large files. (Photoshop, on the other hand, does not choke on it at all, nor do > some other programs that are optimized for image analysis such as ENVI > (http://www.ittvis.com/ProductServices/ENVI.aspx): but I don't want to > work with these... nor do I have them....) Of course this leads to a suggestion for the Import function: to allow > reading in only a part of an image at a time. Feel free to respond to the list, but also CC me on the replies so > that I get them sooner than the usual turnaround. > --David > TIFF format is uncompressed (at least in practice), so I think you could write code using binary I/O, re-positioning the stream as necessary to read a block out of a larger image. Note that there is a big/little endian flag at the start of the file. Alternatively, you could perform the same operations in Java, using J/Link to communicate the results to Mathematica. Of course, using a 64-bit machine (and operating system) with sufficient memory, it would be probably be possible to use Import in the normal way. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Importing a large image... > Naturally, Mathematica can't be good for any task. Sometimes you have > to use other programs too :) That's not what certain other people (at least one of them named Wolfram) are saying . . . right? === Subject: Re: Importing a large image... hi David I have a solution I think. I used a sample TIFF of ~700MB. I note you use a Mac, so that makes it easy - I opened it in GraphicConverter, a free app [ http://www.lemkesoft.com/ ] and saved it as a [ lossless ] PNG but also used the save option to Split the file into 4 X 3 smaller constituent files. Each of these files [ ~20MB ] is then easily imported into Mathematica by something like: a=Import[Desktop/tiff-2a-03-03.png] I'm sure the http://www.imagemagick.org/ utility [ which is available free on the mac and I think via mactex installation ] can do a similar trick. Conversion to PNG is probably not necessary but it seemed like a good idea at the time ;) I hope this helps Peter 2009/4/11 David Reiss : > So, my fellow denizens of the group. I have a very large TIFF image--roughly 700MB in size. Its dimension are 43201 by 15601. It is single color with a bit depth > of 8. without maxing out the memory. I actually do not need to read in the whole file: I'd be happen with > being able to break the file into a number of smaller TIFFs which tile > it completely and then process each on independently (I am needing to > act on the data in various ways to yield a processed result for > further analysis down the line). This is all for a larger project > for a consulting client of mine. Any suggestions for how to programmatically carve up the image without > having to completely read it in first? I am looking for quick > solutions rather than ones that require a lot of programming. Either > it can be done pretty simply, or (more likely) Mathematica chokes on > these very large files. (Photoshop, on the other hand, does not choke on it at all, nor do > some other programs that are optimized for image analysis such as ENVI > (http://www.ittvis.com/ProductServices/ENVI.aspx): but I don't want to > work with these... nor do I have them....) Of course this leads to a suggestion for the Import function: to allow > reading in only a part of an image at a time. Feel free to respond to the list, but also CC me on the replies so > that I get them sooner than the usual turnaround. > --David -- Peter Lindsay === Subject: Simplify can somebody explain, why Simplify[x^2/y^2,ComplexityFunction->LeafCount] does not simplify to (x/y)^2, although the LeafCount is: LeafCount[Hold[x^2/y^2]] gives 10 and LeafCount[Hold[(x/y)^2]] gives 8 Daniel === Subject: Re: Simplify Actually, this point has been explained many times (by me ;-)) (I like to think of Mathematica's evaluation process in terms of something called The Evaluator, which I think I first found in David Wagner's book Power Programming with Mathematica. I think it is only an abstraction, along with the Parser, the Typesetter etc, but a convenient one when one is thinking about the evaluation process. ) The Evaluator always evaluates (x/y)^2 to x^2/y^2 This happens before Simplify takes any effect. Even if Simplify converted x^2/y^2 to (x/y)^2 the Evaluator would kick in and again convert it back to x^2/y^2. Since the Evaluator always overrides Simplify there is no way to get (x/y)^2 as the output without using Hold. Perhaps you are asking why Mathematica (or the Evaluator) automatically converts (x/y)^2 to x^2/y^2. It's because of something called canonical forms or standard forms. Basically, in order to optimize performance in computer algebra systems one want to reduce to 0 as quickly as possible as many expressions that are actually equal. The earlier you do this the better the performance. If you allow expressions to contain a large number of subexpressions that are actually 0 until you apply Simplify, it may very seriously impair performance. Canonical forms (or normal forms, there is a slight difference between them but I shall ignore it) are certain unique forms to which various expressions are reduced automatically by the Evaluator (before applying Simplify). This has the effect causing independent of any particular ComplexityFunction used, hence the reduction has to be performed outside Simplify. The advantage of using canonical forms independent of ComplexityFunction is that they often enable Mathematica to identify two expressions as equal even if Simplify can't fine a sequence of Complexity reducing transformations that will convert one expression into the other. Not surprisingly, using canonical forms can sometimes produce undesirable side-effects and this is one of them (a rather minor one, worse ones do occur). Andrzej Kozlowski can somebody explain, why Simplify[x^2/y^2,ComplexityFunction->LeafCount] does not simplify to (x/y)^2, although the LeafCount is: LeafCount[Hold[x^2/y^2]] gives 10 and LeafCount[Hold[(x/y)^2]] gives 8 Daniel > === Subject: Re: Simplify Hi Daniel, One reason may be the following: In[1] = Hold[x^2/y^2]//FullForm Out[1] = Hold[Times[Power[x, 2], Power[Power[y, 2], -1]]] In[2] = x^2/y^2 // FullForm Out[2] = Times[Power[x, 2], Power[y, -2]] The LeafCount of the latter is then 7, not 10. However, there seems to be more to it, since it looks like there is a built-in rule, so that even if you type (x/y)^2, it will be immediately rewritten as x^2/y^2 (or, (a*b)^c->a^c*b^c, etc): In[3] = (x/y)^2 Out[3] = x^2/y^2 In[4] = Block[{Power}, Hold[Evaluate[((x/y)^2)]]] Out[4] = Hold[(x/y)^2] This probably means that even if LeafCount would indeed be larger, there would be no chance to get the final result unless you either somehow block this specific rule, or get inside Simplify and intercept some intermediate result. Leonid can somebody explain, why Simplify[x^2/y^2,ComplexityFunction->LeafCount] does not simplify to (x/y)^2, although the LeafCount is: LeafCount[Hold[x^2/y^2]] gives 10 and LeafCount[Hold[(x/y)^2]] gives 8 Daniel === Subject: Re: Simplify Yes, you are quite right. I underestimated WRI ;-) I have version 7.01 and it does behave this way. The example I used I two times or more, before Mathematica 6, I think. But Simplify has been improved and is much cleverer now.(I should have expected that and checked). What has happened is that it now knows about this problem and treats it as a special case. Thus, although the difference between 2*6^z - 6^z 2^(z + 1) 3^z - 6^z and 2*5^z - 5^z 5^z still remains, when you apply Simplify you get the same answer. been fixed, my main point remains unchanged. You can never Simplify 2^(z + 1)*3^z to 2*6^z even though LeafCount[Hold[2*6^z]] 6 while LeafCount[2^(z + 1)*3^z] 9 Andrzej Kozlowski > Hi Andrzej, > which version of Mathematica do you have? In version 7.0.1 Simplify seems to > have changed. > Your example: FullSimplify[2*6^z - 6^z] > 2^(z + 1)*3^z - 6^z in my version: > Simplify[2*6^z - 6^z] > 6^z Daniel > Yes, you are right but I still think it is beside the point. >> Consider this rather more striking (in my opinion) example. >> let >> expr = 2^(z + 1)*3^z >> You can easily see that this can be re-written as 2*6^z and that: >> LeafCount[Hold[2*6^z]] >> 6 >> while >> LeafCount[expr] >> 9 >> so 2*6^z has a much smaller LeafCount than expr, but you can never >> Simplify expr to 2*6^z because the Evaluator will always rewrite it >> again as expr. This has a rather unpleasant consequence: >> FullSimplify[2*6^z - 6^z] >> 2^(z + 1)*3^z - 6^z >> Simplify cannot see that the simplest answer if 6^z (no matter what >> ComplexityFunction you use) because immediately on evaluation 2*6^z >> is converted to expr above and then it is too late; Simplify can't >> see that the first term is simply twice the second term. Yet >> Simplify has no problem noticing that: >> Simplify[2*6^z - 6^z == 6^z] >> True >> The reason for the problem is the following canonical form: >> expressions like (a^k1*b^k2*c^k3...)^z *(a*l1*b^l2*...) where a, >> b, c are positive are re-written as a^(k1+l1)*b^(k2+l2)*.... >> For example >> (2^u*5^v)*(2*3^w*5^z) >> 2^(u + 1) 3^w 5^(v + z) >> (actually the rule used is note general, but I just want to give an >> example of a canonical form that causes trouble). >> Since these reductions are made by the Evaluator, Simplify has no >> effect on them. But because of them we get the following >> inconsistent behaviour: >> 2*5^z - 5^z >> 5^z >> but >> 2*6^z - 6^z >> 2^(z + 1)*3^z - 6^z >> This, of course, cannot be changed by applying Simplify with any >> ComplexityFunction because canonical forms can't be changed by >> Simplify (unless you apply Hold). >> Andrzej > Hi Andrzej, > Let me just mention that there is an additional reason, internally > the expression x^2/y^2 is rewritten and has the the same leaf > count as (x/y)^2. Consider: > FullForm[Hold[x^2/y^2]] > FullForm[x^2/y^2] > Daniel >> Actually, this point has been explained many times (by me ;-)) >> (I like to think of Mathematica's evaluation process in terms of >> something called The Evaluator, which I think I first found in >> David Wagner's book Power Programming with Mathematica. I think >> it is only an abstraction, along with the Parser, the >> Typesetter etc, but a convenient one when one is thinking about >> the evaluation process. ) >> The Evaluator always evaluates >> (x/y)^2 >> to >> x^2/y^2 >> This happens before Simplify takes any effect. Even if Simplify >> converted x^2/y^2 to (x/y)^2 the Evaluator would kick in and >> again convert it back to x^2/y^2. Since the Evaluator always >> overrides Simplify there is no way to get (x/y)^2 as the output >> without using Hold. >> Perhaps you are asking why Mathematica (or the Evaluator) >> automatically converts (x/y)^2 to x^2/y^2. It's because of >> something called canonical forms or standard forms. >> Basically, in order to optimize performance in computer algebra >> systems one want to reduce to 0 as quickly as possible as many >> expressions that are actually equal. The earlier you do this the >> better the performance. If you allow expressions to contain a >> large number of subexpressions that are actually 0 until you >> apply Simplify, it may very seriously impair performance. >> Canonical forms (or normal forms, there is a slight >> difference between them but I shall ignore it) are certain unique >> forms to which various expressions are reduced automatically by >> the Evaluator (before applying Simplify). This has the effect >> forms have to be independent of any particular >> ComplexityFunction used, hence the reduction has to be performed >> outside Simplify. The advantage of using canonical forms >> independent of ComplexityFunction is that they often enable >> Mathematica to identify two expressions as equal even if Simplify >> can't fine a sequence of Complexity reducing transformations that >> will convert one expression into the other. >> Not surprisingly, using canonical forms can sometimes produce >> undesirable side-effects and this is one of them (a rather minor >> one, worse ones do occur). >> Andrzej Kozlowski >> Andrzej Kozlowski can somebody explain, why Simplify[x^2/y^2,ComplexityFunction->LeafCount] does not simplify to (x/y)^2, although the LeafCount is: LeafCount[Hold[x^2/y^2]] gives 10 and LeafCount[Hold[(x/y)^2]] gives 8 Daniel -- Daniel Huber > Metrohm Ltd. > Oberdorfstr. 68 > CH-9100 Herisau > Tel. +41 71 353 8585, Fax +41 71 353 8907 > E-Mail: -- Daniel Huber > Metrohm Ltd. > Oberdorfstr. 68 > CH-9100 Herisau > Tel. +41 71 353 8585, Fax +41 71 353 8907 > E-Mail:LeafCount] does not simplify to (x/y)^2, although the LeafCount is: LeafCount[Hold[x^2/y^2]] gives 10 and LeafCount[Hold[(x/y)^2]] gives 8 Daniel === Subject: Re: Simplify Hi Sjoerd, why do you think x^2/y^2 is not equivalent to (x/y)^2 ???? Daniel > It doesn't simplify to that because the two are not equivalent. Try I > for x and -1 for y. > Sjoerd > >> can somebody explain, why >> Simplify[x^2/y^2,ComplexityFunction->LeafCount] >> does not simplify to (x/y)^2, although the LeafCount is: >> LeafCount[Hold[x^2/y^2]] gives 10 >> and >> LeafCount[Hold[(x/y)^2]] gives 8 >> Daniel === Subject: Re: Simplify Hi Andrzej, which version of Mathematica do you have? In version 7.0.1 Simplify seems to have changed. Your example: > FullSimplify[2*6^z - 6^z] > 2^(z + 1)*3^z - 6^z in my version: Simplify[2*6^z - 6^z] 6^z Daniel > Yes, you are right but I still think it is beside the point. Consider > this rather more striking (in my opinion) example. let expr = 2^(z + 1)*3^z You can easily see that this can be re-written as 2*6^z and that: LeafCount[Hold[2*6^z]] > 6 while LeafCount[expr] > 9 so 2*6^z has a much smaller LeafCount than expr, but you can never > Simplify expr to 2*6^z because the Evaluator will always rewrite it > again as expr. This has a rather unpleasant consequence: FullSimplify[2*6^z - 6^z] > 2^(z + 1)*3^z - 6^z Simplify cannot see that the simplest answer if 6^z (no matter what > ComplexityFunction you use) because immediately on evaluation 2*6^z is > converted to expr above and then it is too late; Simplify can't see that > the first term is simply twice the second term. Yet Simplify has no > problem noticing that: Simplify[2*6^z - 6^z == 6^z] > True The reason for the problem is the following canonical form: > expressions like (a^k1*b^k2*c^k3...)^z *(a*l1*b^l2*...) where a, b, c > are positive are re-written as a^(k1+l1)*b^(k2+l2)*.... For example (2^u*5^v)*(2*3^w*5^z) > 2^(u + 1) 3^w 5^(v + z) (actually the rule used is note general, but I just want to give an > example of a canonical form that causes trouble). Since these reductions are made by the Evaluator, Simplify has no effect > on them. But because of them we get the following inconsistent behaviour: 2*5^z - 5^z > 5^z but 2*6^z - 6^z > 2^(z + 1)*3^z - 6^z > This, of course, cannot be changed by applying Simplify with any > ComplexityFunction because canonical forms can't be changed by Simplify > (unless you apply Hold). Andrzej > >> Hi Andrzej, >> Let me just mention that there is an additional reason, internally the >> expression x^2/y^2 is rewritten and has the the same leaf count as >> (x/y)^2. Consider: >> FullForm[Hold[x^2/y^2]] >> FullForm[x^2/y^2] >> Daniel > Actually, this point has been explained many times (by me ;-)) > (I like to think of Mathematica's evaluation process in terms of > something called The Evaluator, which I think I first found in > David Wagner's book Power Programming with Mathematica. I think it > is only an abstraction, along with the Parser, the Typesetter > etc, but a convenient one when one is thinking about the evaluation > process. ) > The Evaluator always evaluates > (x/y)^2 > to > x^2/y^2 > This happens before Simplify takes any effect. Even if Simplify > converted x^2/y^2 to (x/y)^2 the Evaluator would kick in and again > convert it back to x^2/y^2. Since the Evaluator always overrides > Simplify there is no way to get (x/y)^2 as the output without using > Hold. > Perhaps you are asking why Mathematica (or the Evaluator) > automatically converts (x/y)^2 to x^2/y^2. It's because of something > called canonical forms or standard forms. Basically, in order to > optimize performance in computer algebra systems one want to reduce > to 0 as quickly as possible as many expressions that are actually > equal. The earlier you do this the better the performance. If you > allow expressions to contain a large number of subexpressions that > are actually 0 until you apply Simplify, it may very seriously impair > performance. Canonical forms (or normal forms, there is a slight > difference between them but I shall ignore it) are certain unique > forms to which various expressions are reduced automatically by the > Evaluator (before applying Simplify). This has the effect causing > be independent of any particular ComplexityFunction used, hence the > reduction has to be performed outside Simplify. The advantage of > using canonical forms independent of ComplexityFunction is that they > often enable Mathematica to identify two expressions as equal even if > Simplify can't fine a sequence of Complexity reducing transformations > that will convert one expression into the other. > Not surprisingly, using canonical forms can sometimes produce > undesirable side-effects and this is one of them (a rather minor one, > worse ones do occur). > Andrzej Kozlowski > Andrzej Kozlowski >> can somebody explain, why >> Simplify[x^2/y^2,ComplexityFunction->LeafCount] >> does not simplify to (x/y)^2, although the LeafCount is: >> LeafCount[Hold[x^2/y^2]] gives 10 >> and >> LeafCount[Hold[(x/y)^2]] gives 8 >> Daniel >> -- >> Daniel Huber >> Metrohm Ltd. >> Oberdorfstr. 68 >> CH-9100 Herisau >> Tel. +41 71 353 8585, Fax +41 71 353 8907 >> E-Mail: Internet: -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: Simplify can somebody explain, why Simplify[x^2/y^2,ComplexityFunction->LeafCount] does not simplify to (x/y)^2, although the LeafCount is: LeafCount[Hold[x^2/y^2]] gives 10 and LeafCount[Hold[(x/y)^2]] gives 8 > Hello Daniel, There are two reasons. First, try this: In[1]:= FullForm[Hold[x^2/y^2]] Out[1]//FullForm= Hold[Times[Power[x,2],Power[Power[y,2],-1]]] In[2]:= FullForm[x^2/y^2] Out[2]//FullForm= Times[Power[x,2],Power[y,-2]] Second, (x/y)^2 autoevaluates to x^2/y^2, so no function can return (x/ y)^2 without some kind of Hold-wrapper. The LeafCounts of the different forms are In[9]:= LeafCount[Unevaluated[x^2/y^2]] Out[9]= 9 In[10]:= LeafCount[x^2/y^2] Out[10]= 7 In[11]:= LeafCount[Unevaluated[(x/y)^2]] Out[11]= 7 === Subject: Re: Simplify > The reason for the problem is the following canonical form: > expressions like (a^k1*b^k2*c^k3...)^z *(a*l1*b^l2*...) where a, b, > c are positive are re-written as a^(k1+l1)*b^(k2+l2)*.... For example (2^u*5^v)*(2*3^w*5^z) > 2^(u + 1) 3^w 5^(v + z) I did not state this rule correctly. The rule is that in products of powers of integers are factored, with the factors being powers of primes. Andrzej > Yes, you are right but I still think it is beside the point. > Consider this rather more striking (in my opinion) example. let expr = 2^(z + 1)*3^z You can easily see that this can be re-written as 2*6^z and that: LeafCount[Hold[2*6^z]] > 6 while LeafCount[expr] > 9 so 2*6^z has a much smaller LeafCount than expr, but you can never > Simplify expr to 2*6^z because the Evaluator will always rewrite it > again as expr. This has a rather unpleasant consequence: FullSimplify[2*6^z - 6^z] > 2^(z + 1)*3^z - 6^z Simplify cannot see that the simplest answer if 6^z (no matter what > ComplexityFunction you use) because immediately on evaluation 2*6^z > is converted to expr above and then it is too late; Simplify can't > see that the first term is simply twice the second term. Yet > Simplify has no problem noticing that: Simplify[2*6^z - 6^z == 6^z] > True The reason for the problem is the following canonical form: > expressions like (a^k1*b^k2*c^k3...)^z *(a*l1*b^l2*...) where a, b, > c are positive are re-written as a^(k1+l1)*b^(k2+l2)*.... For example (2^u*5^v)*(2*3^w*5^z) > 2^(u + 1) 3^w 5^(v + z) (actually the rule used is note general, but I just want to give an > example of a canonical form that causes trouble). Since these reductions are made by the Evaluator, Simplify has no > effect on them. But because of them we get the following > inconsistent behaviour: 2*5^z - 5^z > 5^z but 2*6^z - 6^z > 2^(z + 1)*3^z - 6^z > This, of course, cannot be changed by applying Simplify with any > ComplexityFunction because canonical forms can't be changed by > Simplify (unless you apply Hold). Andrzej > Hi Andrzej, >> Let me just mention that there is an additional reason, internally >> the expression x^2/y^2 is rewritten and has the the same leaf count >> as (x/y)^2. Consider: >> FullForm[Hold[x^2/y^2]] >> FullForm[x^2/y^2] >> Daniel > Actually, this point has been explained many times (by me ;-)) > (I like to think of Mathematica's evaluation process in terms of > something called The Evaluator, which I think I first found in > David Wagner's book Power Programming with Mathematica. I think > it is only an abstraction, along with the Parser, the > Typesetter etc, but a convenient one when one is thinking about > the evaluation process. ) > The Evaluator always evaluates > (x/y)^2 > to > x^2/y^2 > This happens before Simplify takes any effect. Even if Simplify > converted x^2/y^2 to (x/y)^2 the Evaluator would kick in and > again convert it back to x^2/y^2. Since the Evaluator always > overrides Simplify there is no way to get (x/y)^2 as the output > without using Hold. > Perhaps you are asking why Mathematica (or the Evaluator) > automatically converts (x/y)^2 to x^2/y^2. It's because of > something called canonical forms or standard forms. Basically, > in order to optimize performance in computer algebra systems one > want to reduce to 0 as quickly as possible as many expressions > that are actually equal. The earlier you do this the better the > performance. If you allow expressions to contain a large number of > subexpressions that are actually 0 until you apply Simplify, it > may very seriously impair performance. Canonical forms (or > normal forms, there is a slight difference between them but I > shall ignore it) are certain unique forms to which various > expressions are reduced automatically by the Evaluator (before > occur early. Also, these canonical forms have to be independent > of any particular ComplexityFunction used, hence the reduction has > to be performed outside Simplify. The advantage of using canonical > forms independent of ComplexityFunction is that they often enable > Mathematica to identify two expressions as equal even if Simplify > can't fine a sequence of Complexity reducing transformations that > will convert one expression into the other. > Not surprisingly, using canonical forms can sometimes produce > undesirable side-effects and this is one of them (a rather minor > one, worse ones do occur). > Andrzej Kozlowski > Andrzej Kozlowski >> can somebody explain, why >> Simplify[x^2/y^2,ComplexityFunction->LeafCount] >> does not simplify to (x/y)^2, although the LeafCount is: >> LeafCount[Hold[x^2/y^2]] gives 10 >> and >> LeafCount[Hold[(x/y)^2]] gives 8 >> Daniel >> -- >> Daniel Huber >> Metrohm Ltd. >> Oberdorfstr. 68 >> CH-9100 Herisau >> Tel. +41 71 353 8585, Fax +41 71 353 8907 >> E-Mail: Internet: Hi Andrzej, > Let me just mention that there is an additional reason, internally > the expression x^2/y^2 is rewritten and has the the same leaf count > as (x/y)^2. Consider: > FullForm[Hold[x^2/y^2]] > FullForm[x^2/y^2] > Daniel >> Actually, this point has been explained many times (by me ;-)) >> (I like to think of Mathematica's evaluation process in terms of >> something called The Evaluator, which I think I first found in >> David Wagner's book Power Programming with Mathematica. I think >> it is only an abstraction, along with the Parser, the >> Typesetter etc, but a convenient one when one is thinking about >> the evaluation process. ) >> The Evaluator always evaluates >> (x/y)^2 >> to >> x^2/y^2 >> This happens before Simplify takes any effect. Even if Simplify >> converted x^2/y^2 to (x/y)^2 the Evaluator would kick in and again >> convert it back to x^2/y^2. Since the Evaluator always overrides >> Simplify there is no way to get (x/y)^2 as the output without using >> Hold. >> Perhaps you are asking why Mathematica (or the Evaluator) >> automatically converts (x/y)^2 to x^2/y^2. It's because of >> something called canonical forms or standard forms. Basically, >> in order to optimize performance in computer algebra systems one >> want to reduce to 0 as quickly as possible as many expressions that >> are actually equal. The earlier you do this the better the >> performance. If you allow expressions to contain a large number of >> subexpressions that are actually 0 until you apply Simplify, it may >> very seriously impair performance. Canonical forms (or normal >> forms, there is a slight difference between them but I shall >> ignore it) are certain unique forms to which various expressions >> are reduced automatically by the Evaluator (before applying >> early. Also, these canonical forms have to be independent of any >> particular ComplexityFunction used, hence the reduction has to be >> performed outside Simplify. The advantage of using canonical forms >> independent of ComplexityFunction is that they often enable >> Mathematica to identify two expressions as equal even if Simplify >> can't fine a sequence of Complexity reducing transformations that >> will convert one expression into the other. >> Not surprisingly, using canonical forms can sometimes produce >> undesirable side-effects and this is one of them (a rather minor >> one, worse ones do occur). >> Andrzej Kozlowski >> Andrzej Kozlowski can somebody explain, why Simplify[x^2/y^2,ComplexityFunction->LeafCount] does not simplify to (x/y)^2, although the LeafCount is: LeafCount[Hold[x^2/y^2]] gives 10 and LeafCount[Hold[(x/y)^2]] gives 8 Daniel -- Daniel Huber > Metrohm Ltd. > Oberdorfstr. 68 > CH-9100 Herisau > Tel. +41 71 353 8585, Fax +41 71 353 8907 > E-Mail:LeafCount] does not simplify to (x/y)^2, although the LeafCount is: LeafCount[Hold[x^2/y^2]] gives 10 and LeafCount[Hold[(x/y)^2]] gives 8 Daniel Hold[x^2/y^2] // FullForm ==> Hold[Times[Power[x,2],Power[Power[y, 2],-1]]] x^2/y^2 // FullForm ==> Times[Power[x,2],Power[y,-2]] x^2/y^2 // LeafCount ==> 7 === Subject: Re: Trouble with FullSimplify >> What is wrong with the following in Mathematica 7: >> Clear[n]; >> FullSimplify[n Exp[-n * 0.], Element[n, Integers]] >> result: n/2, which is scary. If I replace 0. by $MachineEpsilon/2, I >> get a correct result. >> It's also fun to express your feelings about Mathematica 7 this way: >> FullSimplify[$Version Exp[$Version *($VersionNumber - >> $VersionNumber)]] >> Jens This is a terrible bug. I am very much disappointed with Simplify and > even more with FullSimplify functions in Mathematica 6 and worse in > Mathematica 7. > Anyone who uses Simplify or FullSimplify with approximate numbers fully deserves the consequences. Andrzej Kozlowski === Subject: Re: Trouble with FullSimplify > What is wrong with the following in Mathematica 7: Clear[n]; > FullSimplify[n Exp[-n * 0.], Element[n, Integers]] result: n/2, which is scary. If I replace 0. by $MachineEpsilon/2, I > get a correct result. It's also fun to express your feelings about Mathematica 7 this way: > FullSimplify[$Version Exp[$Version *($VersionNumber - > $VersionNumber)]] Jens This is a terrible bug. I am very much disappointed with Simplify and even more with FullSimplify functions in Mathematica 6 and worse in Mathematica 7. === Subject: Re: Trouble with FullSimplify What is wrong with the following in Mathematica 7: Clear[n]; > FullSimplify[n Exp[-n * 0.], Element[n, Integers]] result: n/2, which is scary. If I replace 0. by $MachineEpsilon/2, I > get a correct result. It's also fun to express your feelings about Mathematica 7 this way: > FullSimplify[$Version Exp[$Version *($VersionNumber - > $VersionNumber)]] Jens This is a terrible bug. I am very much disappointed with Simplify and > even more with FullSimplify functions in Mathematica 6 and worse in > Mathematica 7. OK, so what exactly is it that's broken in Simplify in version 7 (and not in version 6), *apart* from this specific bug? What is it that's broken in 6 too? It sounds like you've found other problems, so please post your examples in this thread. === Subject: Re: Been doing real-time measurements with Mathematica! can you post some results ? Sounds like good fun.Peter 2009/4/15 Sjoerd C. de Vries using Mathematica to do actual real-time measurements in an experiment > that I'm currently performing. Jay! I'm using a Wii balance board (from the Wii fit game) to measure > changes in my subjects' centre of gravity. The Wii Balance Board connects through bluetooth to my laptop. Using > glovepie_download) and PPJoy (http://www.geocities.com/deonvdw/Docs/ > converted to a virtual Windows joystick X,Y values which can be read > directly and easily using Mathematica's ControllerState function. This gets me about 400 samples per second. A real-time plot of the > user's motions reduces it to about 20 Hz. Still not bad at all, and > very useful. Works for the Wiimote (acceleration sensors!) as well. > -- Peter Lindsay === Subject: Re: Assuming odd/even functions Use UpValues Clear[f]; f /: f[a_] + f[-a_] = 0 ; f[x] + f[-x] 0 f[-x] + f[x] 0 This isn't robust f[x^2 - 3 x + 2] + f[-x^2 + 3 x - 2] f[-x^2 + 3*x - 2] + f[x^2 - 3*x + 2] However, you can help it along Simplify[ f[x^2 - 3 x + 2] + f[-x^2 + 3 x - 2], x^2 - 3 x + 2 == t] 0 f /: Integrate[f[x_], {x_, -a_, a_}] = 0; Integrate[f[y], {y, -z, z}] 0 However, Integrate[f[y], {y, z, -z}] Integrate[f[y], {y, z, -z}] Add another UpValue f /: Integrate[f[x_], {x_, a_, -a_}] = 0; Integrate[f[y], {y, z, -z}] 0 Again, not robust Integrate[f[y], {y, x^2 - 3, -x^2 + 3}] Integrate[f[y], {y, x^2 - 3, 3 - x^2}] But as before Simplify[ Integrate[f[y], {y, x^2 - 3, -x^2 + 3}], x^2 - 3 == t] 0 Bob Hanlon How can we give Mathematica the information of a function being odd or even= , and have it applied automatically or in a Simplify[]? Such that, if e.g. f[y] is odd, the sum f(a)+f(-a) yields zero, the integral Integrate[f[y], {y, -a, a}] vanishes? --Martin === Subject: Re: Plotting a x,y,z function The radius is Norm[{x, y, z}] Sqrt[Abs[x]^2 + Abs[y]^2 + Abs[z]^2] Since you are dealing only with real values Simplify[%, Element[{x, y, z}, Reals]] Sqrt[x^2 + y^2 + z^2] f[x_, y_, z_] = Module[{r2 = x^2 + y^2 + z^2}, r2* E^-(r2/2)] E^((1/2)*(-x^2 - y^2 - z^2))*(x^2 + y^2 + z^2) ContourPlot3D[f[x, y, z], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}] Bob Hanlon I needed help plotting the following function: f[x_,y_,z_] = (x^2+y^2+z^2) e^-(r^2/2) ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}] does not work because it doesn't understand what r (radius) is....what is the keyword/whatever for radius? Or do I have to define r in terms of x,y,z somehow?! Help with syntax will be great! === Subject: Re: How to find current ViewAngle, ViewPoint during Rotating graphics? > Mathematica 7. Is there a way to display the current ViewAngle and/or View point of a 3D > graphics as one is rotating it with the mouse? Sometimes I am not sure what is the best view angle to use initially, but > after I rotate the 3D graphics and find a good angle I like, there does not > seem to be a way to determine its value from the front end. I was expecting > may be that a mouse right-click on the graphics or something similar would > bring up some information about the current state of the graphics. Any one knows a trick way to find this information? --Nasser For this purpose I use the following function: ExtrahiereViews[pl_]:= Flatten[Union[(Extract[pl,Position[pl,#]]&)/@ {ViewPoint->_, ViewCenter->_, ViewVertical->_, ViewAngle->_, ViewVector->_, ViewRange->_} ]] Give your moused image as argument to it -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: How to find current ViewAngle, ViewPoint during Rotating graphics? Here I've incorporated your 3D plot into my example. I've made the tube optional since it slows things down. Note that ViewPoint->{3.38378, 0, 0} with ViewVertical->{0,1,0} gives you a spring which is oriented sideways. Manipulate[ ParametricPlot3D[{Sin[u], Cos[u], 0.05*u}, {u, 0, 5*2*Pi}, PlotStyle -> If[tube, Tube[0.05], Automatic], Axes -> Dynamic[axes], Boxed -> Dynamic[boxed], ImageSize -> 300, ViewPoint -> Dynamic[vp], ViewVertical -> Dynamic[vv], ViewAngle -> Dynamic[va], ViewCenter -> Dynamic[vc], SphericalRegion -> Dynamic[sr], Method -> {RotationControl -> Dynamic[rc]}], {{vp, ViewPoint /. Options[Graphics3D], ViewPoint[Rule]}, InputField}, {{vv, {0, 0, 1}, ViewVertical[Rule]}, InputField}, {{va, Automatic, ViewAngle[Rule]}, InputField}, {{vc, {{1/2, 1/2, 1/2}, {1/2, 1/2}}, ViewCenter[Rule]}, InputField}, Row[{Labeled[Checkbox[Dynamic[sr]], SphericalRegion[Rule], Left, Spacings -> 0], Labeled[Checkbox[Dynamic[axes]], Axes[Rule], Left, Spacings -> 0], Labeled[Checkbox[Dynamic[boxed]], Boxed[Rule], Left, Spacings -> 0], Labeled[Checkbox[Dynamic[tube]], Tube[Rule], Left, Spacings -> 0]}], {sr, {True, False}, None}, {axes, {False, True}, None}, {boxed, {False, True}, None}, {tube, {False, True}, None}, {{rc, ArcBall, RotationControl[Rule]}, {ArcBall, Globe}}] Enjoy! Alexander Make a Plot, say, Plot3D[(x - 3) (y - 2), {x, 0, 5}, {y, 0, 5}, > ImageSize -> 300] Then in the output, position the cursor to the left of the plot and type > 'AbsoluteOptions['. Next position the cursor to the right of the plot and > type ',ViewPoint]'. Evaluate and you will obtain the current ViewPoint. > You > can rotate the image and reevaluate to get the new ViewPoint. Then copy > the > ViewPoint into the original plot statement. Without the ImageSize option it also works but I get warning messages > after > rotating. > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ this 3D plot ParametricPlot3D[{Sin[u], Cos[u], 0.05*u}, {u, 0, 5*2*Pi}, PlotStyle - {Tube[thick]}, > ViewPoint -> {2.645, 2.057138, 0.468316}, ViewAngle -> Automatic, Axes - False, Boxed -> False, > ImageSize -> 300] And the above ViewPoint value was copied as a result of the method you > described, yet the resulting image orientation does not match that which I > copied the ViewPoint from. Here is a screen shot. http://12000.org/tmp/041209/viewpoint.PNG Basically, I am trying to make a spring which is oriented sideways instead > of up-down. This is on Mathematica 7 ps. You are right above getting a warning when not using ImageSize. --Nasser > === Subject: Re: How to find current ViewAngle, ViewPoint during Rotating graphics? >> Make a Plot, say, >> Plot3D[(x - 3) (y - 2), {x, 0, 5}, {y, 0, 5}, >> ImageSize -> 300] >> Then in the output, position the cursor to the left of the plot and type >> 'AbsoluteOptions['. Next position the cursor to the right of the plot >> and >> type ',ViewPoint]'. Evaluate and you will obtain the current ViewPoint. >> You >> can rotate the image and reevaluate to get the new ViewPoint. Then copy >> the >> ViewPoint into the original plot statement. >> Without the ImageSize option it also works but I get warning messages >> after >> rotating. >> David Park >> djmpark@comcast.net >> http://home.comcast.net/~djmpark/ > this 3D plot ParametricPlot3D[{Sin[u], Cos[u], 0.05*u}, {u, 0, 5*2*Pi}, PlotStyle - {Tube[thick]}, > ViewPoint -> {2.645, 2.057138, 0.468316}, ViewAngle -> Automatic, Axes - False, Boxed -> False, > ImageSize -> 300] And the above ViewPoint value was copied as a result of the method you > described, yet the resulting image orientation does not match that which= I > copied the ViewPoint from. Here is a screen shot. http://12000.org/tmp/041209/viewpoint.PNG Basically, I am trying to make a spring which is oriented sideways > instead > of up-down. This is on Mathematica 7 ps. You are right above getting a warning when not using ImageSize. --Nasser You should be getting not only the ViewPoint, but the ViewVertical, as well. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: Image Analysis: identifying objects with Mathematica Gideon, > Hi All! I would appreciate any input on the following problem: After scanning my samples with TEM, I get images (JPEG or TIFF) which > other molecule. > Approximately half of the popoulation is that of dimmers, while the > other half contains trimmers, monomers, etc. I would like to run some > statistics on the samples. > I read Theodore Gray's post in the Wolfram Blog about the new > capabilities of image processing in Mathematica 7.0.1 and I would like > to ask if it is possible to do the following in Mathematica: Pick out a square that contains the dimmers, define that square as a > new image, and then let Mathematica search for such an image within > the original image. Yes, it is possible. You can use ImageCorrelate; if the appearance of the dimmers varies a lot in the image, this approach may not be good. You can then revert to ImageFilter with a more robust template matching function. We could probably be more specific if we could see one of your images. Matthias Odisio Wolfram Research I know that Mathematica has a new function MorphologicalComponents > that is apparently the key to getting this done, but I don't really > understand how to use it. It is also supposed to return the > coordinates of the located images, but I don't know how to extract > this output from the function. > Gideon === Subject: integer programming How is integer programming done in Mathematica? Francisco === Subject: Mathematica 7 problems I run Mathemtica 7.0.1 on 64-bit Linux (opensuse 11.0). ------ First problem ------------------- I have a problem with $MachineDomains, when I try execute it, kernel silently crashes. Because of that SystemInformation[] is also broken (because it includes SystemInformation[Kernel, MachineDomains], I checked all other properties are OK). Mathematica 6.0.3 does not crash in this situation In[1]:= $MachineDomains Out[1]= {host.de, host.de} These are domains for two network interfaces. If I disable all networkinterfaces, Mathematica 7.0.1 does not crash, but output is different from 6.0.3: In 6.0.3: In[1]:= $MachineDomains Out[1]= {host.de} In 7.0.1: In[1]:= $MachineDomains Out[1]= {hostname.host.de, hostname.host.de} Which is obviously wrong, because it shows not only domains, but also includes hostname. ------- Second problem -------------------------- For some reason (perhaps because of Compiz window manager) I cannot minimize or maximize any window from Documentation Center. All other windows are OK (notebooks, palettes, etc...). The window only slightly changes its shape but the size does not change. It is strange because in 6.0.3 it works flawlessly. -- === Subject: Strange Output!!!Please help me thank you. Hi Mathematica community, I have to solve this system: Reduce[{Element[{i, j}, Integers], i <= iP, j >= jP, 1*j + 1*i == 1*jP + 1*iP, Reduce[{Element[{N, iP}, Integers], Not[(iP < N)], Exists[{iPP}, (iPP < N) && iP == iPP + 1]}]}, {iP, jP}, Backsubstitution -> True] the output should be:( i | j | N | iP) are Integers && i <= N && iP == N && jP == i + j - N but mathematica gave me this output: (C[1] | C[2] | C[3] | C[4]) are Integers && C[1] >= 0 && C[2] >= 0 && C[3] >= 0 && C[4] >= 0 && i == C[1] - C[2] - C[3] && iP == C[1] - C[2] + C[4] && N == C[1] - C[2] + C[4] && jP == j - C[3] - C[4] which is not understandable at all! and I dont want the output to be like that. I have observed that when I remove i from Element[{i, j}, Integers] mathematica give me the output I want and which is :iP == N && jP == i + j - N So how can I have this same output without removing i from Element[{i, j}, Integers]? === Subject: Exporting animations is there a possibility to adjust the animation rate or speed when exporting a Manipulate / ControllerManipulate / Animate object with a fixed number of plots to an .avi file? In Mathematica the AnimationRate option of Animate works fine, but in the avi-player the animation runs much too fast. Hannes Kessler === Subject: FindRoot Hi all, How can I to find the reals roots of a cubic equation in simbolic form: For example, Find the roots of x^3-4a^2x-2a^3==0 where a is real and a>0. === Subject: problem with replace all and functions I've a lot of rules created by NDSolve: {{Subscript[x, 1][t]->InterpolatingFunction[{{0.`,213.43887344465708`}}, <>][t], Subscript[y, 1][t]->InterpolatingFunction[{{0.`,213.43887344465708`}}, <>] [t], Subscript[x, 2][t]->InterpolatingFunction[{{0.`,213.43887344465708`}}, <>] [t], Subscript[y, 2][t]->InterpolatingFunction[{{0.`,213.43887344465708`}}, <>] [t], ... }} I have defined: Subscript[punto, 1][t_]:= Evaluate[{Subscript[x, 1][t],Subscript[y, 1][t]}/.sol3[[1]]] Subscript[punto, 2][t_]:= Evaluate[{Subscript[x, 2][t],Subscript[y, 2][t]}/.sol3[[1]]] Subscript[punto, 3][t_]:= Evaluate[{Subscript[x, 3][t],Subscript[y, 3][t]}/.sol3[[1]]] it works, but it's not very good, I've want something like this: Subscript[punto, i_][t_]:= Evaluate[{Subscript[x, i][t],Subscript[y, i][t]}/.sol3[[1]]] but it doesn't work === Subject: tooltip - evaluate function at point I would like to plot the solutions to an equation using ContourPlot and add a tooltip that evaluates a different function at the points on the solution. In particular, for the plot ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 20] when the cursor is over a solution point I would like the ToolTip to display the value of Gamma at that point. Is this possible? If so, any suggestion is greatly appreciated. Cristina === Subject: Re: Plotting a x,y,z function >I needed help plotting the following function: >f[x_,y_,z_] = (x^2+y^2+z^2) e^-(r^2/2) >ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2], {x, -10, 10}, {y, -10, >10}, {z, -10, 10}] >does not work because it doesn't understand what r (radius) >is....what is the keyword/whatever for radius? There is none. >Or do I have to define r in terms of x,y,z somehow?! Yes. >Help with syntax will be great! Assuming standard cartesian coordinates, then r^2 should be x^2+y^2+z^2 and the following code will give you the desired graphic ContourPlot3D[(x^2 + y^2 - z^2) Exp[-(x^2 + y^2 - z^2)/2], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}] f[x_,y_,z_] = (x^2+y^2+z^2) E^-((x^2 + y^2 - z^2)/2) can be used to create the graphic using ContourPlot3D[f[x,y,z], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}] === Subject: Finding all n-partitions of a set Please how can I find all n-partions of a set ? Say, i want partitions of the set (no order) {a,a,b,b} into 2, so we have { {{a,a,b,},{b}}, {{a,b,b},{a}}, {{a,a},{b,b}}, {{a,b},{a,b}} } is there already a built in function in mathematica ? i need so n can be any number === Subject: Re: axis label position >The default position for axis labels in Mathematica is at the end of >the axes. However, I need to make a plot with the x-axis label below >the x axis and the y-axis to the left (not at the top). Is there >some axes label format specification that controls this? produces the kinds of labels that I want. But to use frame I need to >suppress the upper and right parts (i.e., so that I'm left with just >an x and y axis). The command for this: >Frame->{{True,False},{True,False}} does not seem to work on the >version of Mathematica (5.2) installed on this computer system. Instead of Frame->{{True,False},{True,False}} try Frame->{True,False,True,F= alse} === Subject: Re: MaxIterations for FindRoot called by NDSolve Hi david, here is an example: FindRoot[x^100, {x, 1}, MaxIterations -> 1000] Daniel When running NDSolve, I get this error message: FindRoot::cvmit: Failed to converge to the requested accuracy or precision > within 100 iterations. I wish to change MaxIterations, and I am calling this line before NDSolve, SetOptions[FindRoot, MaxIterations -> [Infinity]]; But, the options is not applying to FindRoot when it is called by NDSolve, I > get the same error message. How can I change MaxIterations for FindRoot > when called my NDSolve? > David === Subject: Re: Image Analysis: identifying objects with Mathematica 7.0 Hi Gideon, if I understand correctly, you want to find where a subpicture occurs in a larger picture. If you consider the picture as a numerrical array, then the correlation is large at places ahere the subpicture appears. Here is a simple example where we place a subpicture in the middle of a larger array: m1 = SparseArray[{{10, 10} -> 1, {10, 11} -> 1, {11, 10} -> 1, {11, 11} -> 1}, {20, 20}]; m2 = {{1, 1}, {1, 1}}; ListCorrelate[m2, m1] // MatrixForm hope this helps, Daniel > Hi All! I would appreciate any input on the following problem: After scanning my samples with TEM, I get images (JPEG or TIFF) which > other molecule. > Approximately half of the popoulation is that of dimmers, while the > other half contains trimmers, monomers, etc. I would like to run some > statistics on the samples. > I read Theodore Gray's post in the Wolfram Blog about the new > capabilities of image processing in Mathematica 7.0.1 and I would like > to ask if it is possible to do the following in Mathematica: Pick out a square that contains the dimmers, define that square as a > new image, and then let Mathematica search for such an image within > the original image. I know that Mathematica has a new function MorphologicalComponents > that is apparently the key to getting this done, but I don't really > understand how to use it. It is also supposed to return the > coordinates of the located images, but I don't know how to extract > this output from the function. > Gideon > === Subject: Re: About Reduce and domains if you want something like x>0... then you specify a domain implicitly. For a complex number x>0 does not make much sense. Note that you may also specify the domain of some variables in the first argument of Reduce: Reduce[{..,Element[{x,y},Reals],..}] Daniel > Hi Mathematica community, > I remarqued in many outputs with reduce, that mathematica treats some > parameters as complexe numbers and consequently distinguich between Re > part and Im part: > For example: > (Re[d]<0&&Re[a]<0&& ...) || (Re[d]<0&&Re[a]==0&&Im[a]<0&& ...) || (Re > [d]<0&&Re[a]==0&&Im[a]>0&&...) || (Re[d]<0&&Re[a]>0&&...) || (Re[d] > ==0&&Im[d]<0&&Re[a]<0&&...) ||... In the help I have read that Reduce[expr,vars] assumes by default that > quantities appearing algebraically in inequalities are real, while all > other quantities are complex. But is there a mean to force mathematica in the way that it does not > distinguich between real part and imaginary part in the output and > consequently to have: d<0 && a<0 ...|| d==0 && a>0 || ...without > specifying a domain which means without Reduce[expr,vars,doms]? === Subject: Re: axis label position I think that in Version 5.2 you can use Frame -> {True, True, False, False}. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ The default position for axis labels in Mathematica is at the end of the axes. However, I need to make a plot with the x-axis label below the x axis and the y-axis to the left (not at the top). Is there some axes label format specification that controls this? So far, I have found two potential solutions, and neither of them are ideal: -I can instead use Text[] to put a label at the location of my choosing and then use Show[] to show the plot and the label together. The problem with this is that the plot axes get extended to accomodate these new graphics objects (the labels). I just want an x and y axis that begin at the origin and extend to positive values. Showing the labels makes them extend to negative values as well, which isn't very astheticaly pleasing. -What I want to do also seems possible with Frame, since FrameLabel produces the kinds of labels that I want. But to use frame I need to suppress the upper and right parts (i.e., so that I'm left with just an x and y axis). The command for this: Frame->{{True,False},{True,False}} does not seem to work on the version of Mathematica (5.2) installed on this computer system. Is there an easier/cleaner way to do this? === Subject: Re: axis label position Plot[x, {x, 0, 1}, Frame -> {True, True, False, False}, FrameLabel -> {x, y}, Axes -> False] Bob Hanlon The default position for axis labels in Mathematica is at the end of the axes. However, I need to make a plot with the x-axis label below the x axis and the y-axis to the left (not at the top). Is there some axes label format specification that controls this? So far, I have found two potential solutions, and neither of them are ideal: -I can instead use Text[] to put a label at the location of my choosing and then use Show[] to show the plot and the label together. The problem with this is that the plot axes get extended to accomodate these new graphics objects (the labels). I just want an x and y axis that begin at the origin and extend to positive values. Showing the labels makes them extend to negative values as well, which isn't very astheticaly pleasing. -What I want to do also seems possible with Frame, since FrameLabel produces the kinds of labels that I want. But to use frame I need to suppress the upper and right parts (i.e., so that I'm left with just an x and y axis). The command for this: Frame->{{True,False},{True,False}} does not seem to work on the version of Mathematica (5.2) installed on this computer system. Is there an easier/cleaner way to do this? === Subject: Re: Brace, bracket pretty format needed here is a function that I once copied from a Wolfram site, but I can no more tell exactly where. Anyway, the function ColorBrackets will color bracket and braces. TransformBrackets and FindBrackets are auxilliary functions. TransformBrackets[f_, expr_] := DisplayForm[FindBrackets[ToBoxes[expr], f]]; FindBrackets[startexpr_, f_] := Fold[Function[{expr, location}, ReplacePart[expr, f[expr[[Sequence @@ location]], Length[location]], location]], startexpr, Sort[Position[startexpr, RowBox[{a___, { | [ | (, b__, ] | } | ), c___}]], Length[#1] > Length[#2] &]]; ColorBrackets[expr_] := TransformBrackets[ StyleBox[AdjustmentBox[#1, BoxMargins -> {{0, 0}, {.5, .5}}], Background -> Hue[Mod[N[#2/10], 1], .5]] &, expr] a new cell with the colored selection. E.g.: Button[ColorBrackets, (nb = SelectedNotebook[]; SelectionCreateCell[nb]; SelectionMove[nb, All, Cell]; NotebookApply[nb, ColorBrackets[[SelectionPlaceholder] ], All]; SelectionEvaluate[nb])] Finally you may put this button in a palete. hope ths helps, Daniel > Hi Due to my visual limitations, trying to keep track of all the braces/ > brackets can become very frustrating for me. I need some button on a > palette that will indent and clean up the braces/brackets so I can > tell what is going on. The color change for unmatched stuff is good > but what I really want is a different color for each level of > you > === Subject: Re: Contour Plots of Lists there is ListContourPlot. But why you do not want mathematica to choose the points, simply using ContourPlot: ContourPlot[Abs[F(x + I y)],{x,1,100},{y,1,100}] Daniel > I'm familiar with the straightforward and simple commands of > Mathematica, but am a bit unsure of how to do this. I have a > complicated function f(z) that must be integrated from a known point > to a parameter, z = s. Call this F(s). Mathematica can do the integral > provided I tell it how to do it on a case-by-case basis. I need a contour plot of F(s) (s is complex). So I would need to > program something like this: Create 100x100 mesh in [x, y] For 1:100 > --For 1:100 > ----Calculate F(x + iy) using specific fashion > --end > end ContourPlot[x, y, Abs[F]] Is there a way to do ContourPlots on discrete meshes? (I guess they're > called Lists in Mathematica) > === Subject: Re: Imaginary numbers - most interesting points The most extraordinary thing to me is that complex numbers are built into ordinary space - of any dimension! They are not something you have to import from the outside. How do you find out about that? Read about 'geometric algebra'. ('New Foundations for Classical Mechanics: Second Edition' by David Hestenes or 'Geometric Algebra for Physicists' by Chris Doran & Anthony Lasenby. And, as it happens, there is a very powerful Mathematica package for this called GrassmannAlgebra written by John Browne: http://www.grassmannalgebra.info/ David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have (perhaps unwisely!) decided to do a 'Pecha Kucha' on imagination .... or at least imaginary numbers. The audience are all engineers with hazy recollection of undergrad maths. If you are not familiar with Pecha Kucha, then its worth checking Youtube and doing some googling. Simplistically the concept is to share understanding of something using 20 slides. Each slide should convey as much as possible with as few words as possible, with the message limited to 20 seconds! So, what is the most interesting thing about the imaginary number 'i' that you can think of, and how can it most simply be conveyed using Mathematica 7 in Slide presentation form? I've started with the notion of polynomial roots, de Moivre, reflections etc. but would appreciate a wider view. R === Subject: Imaginary numbers - most interesting points I have (perhaps unwisely!) decided to do a 'Pecha Kucha' on imagination .... or at least imaginary numbers. The audience are all engineers with hazy recollection of undergrad maths. If you are not familiar with Pecha Kucha, then its worth checking Youtube and doing some googling. Simplistically the concept is to share understanding of something using 20 slides. Each slide should convey as much as possible with as few words as possible, with the message limited to 20 seconds! So, what is the most interesting thing about the imaginary number 'i' that you can think of, and how can it most simply be conveyed using Mathematica 7 in Slide presentation form? I've started with the notion of polynomial roots, de Moivre, reflections etc. but would appreciate a wider view. R === Subject: Re: Plotting a x,y,z function I needed help plotting the following function: f[x_,y_,z_] = (x^2+y^2+z^2) e^-(r^2/2) ContourPlot3D[(x^2 + y^2 - z^2) Exp[-r^2/2], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}] does not work because it doesn't understand what r (radius) is....what is the keyword/whatever for radius? Or do I have to define r in terms of x,y,z somehow?! Help with syntax will be great! What's wrong with this: ContourPlot3D[(x^2 + y^2 - z^2) Exp[-Sqrt[x^2 + y^2 + z^2]/ 2], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}] ? ------------------------------------------------------------------------ -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Re: Adding text to RegionPlot > This does what you want RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, > PlotRange -> {{0, 3}, {0, 1}}, Epilog -> {Text[mytext, {1.5, 1}]}] plotting commands had illustrated the use of this epilog feature. I never knew it even existed after all these years! Jim === Subject: Re: Adding text to RegionPlot >> This does what you want >> RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, >> PlotRange -> {{0, 3}, {0, 1}}, Epilog -> {Text[mytext, {1.5, 1}]}] > plotting commands had illustrated the use of this epilog feature. I > never knew it even existed after all these years! Epilog is right there under Options on the page for Plot. Also, there is a page on CombiningGraphics which is pretty easy to find from the Documentation home page. -- Helen Read University of Vermont === Subject: 3D plots and using mouse click-drag to rotate - why the extra When you create a 3D plot and then use the mouse to click-drag to rotate the surface to view it from another angle, there is always an extra translation thrown in by Mathematica as soon as you let the mouse button go after this click-drag. However, if you do an Option- click to zoom in or out and then let go there is no extra translation, and thereafter if you click-drag as before there is no extra translation after letting go of the mouse button. Is this extra translation at the end something that you can prevent without having to resort to the Option-click/zoom step?? I am on a Mac with version 7.0.1 (I think this has occured for a long time, but can't verify it right now). So for example if you try something like: Plot3D[Sin[x y] + 10, {x, -3, 3}, {y, -3, 3}, AxesOrigin -> {0, 0, 10}, Boxed -> False, PlotRange -> {Automatic, Automatic, {0, 20}}] and then click-drag to rotate to look at the bottom and let go there is an extra little jump that the surface goes thru when you let the mouse button go. Then do an Option-click and zoom in and out to still maintain the entire surface in view and let go and no extra jump either. Now do a click-drag again and let go and no extra little translation any more (until you re-execute the cell again). Comments? -Bob === Subject: Re: 3D plots and using mouse click-drag to rotate - why the extra The default setting of SphericalRegion->False scales three-dimensional images to be as large as possible, given the display area specified. This scaling occurs as soon as you let the mouse button go after the click-drag, causing the extra translation you are experiencing. Setting SphericalRegion->True or the ViewAngle option to some value or option-clicking to zoom in or out makes the zoom value of the view fixed and no longer subject to the automatic scaling stated above. - Alexander === Subject: Re: 3D plots and using mouse click-drag to rotate - why the extra Ever since Version 6 the Presentations package has had a NiceRotation command that can be inserted among the options in a Draw3DItems statement. But, in any case, it is just a convenience and you can easily duplicate it. NiceRotation Sequence[SphericalRegion -> True, RotationAction -> Clip] So Plot3D[Sin[x y] + 10, {x, -3, 3}, {y, -3, 3}, SphericalRegion -> True, RotationAction -> Clip, AxesOrigin -> {0, 0, 10}, Boxed -> False, PlotRange -> {Automatic, Automatic, {0, 20}}] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ When you create a 3D plot and then use the mouse to click-drag to rotate the surface to view it from another angle, there is always an extra translation thrown in by Mathematica as soon as you let the mouse button go after this click-drag. However, if you do an Option- click to zoom in or out and then let go there is no extra translation, and thereafter if you click-drag as before there is no extra translation after letting go of the mouse button. Is this extra translation at the end something that you can prevent without having to resort to the Option-click/zoom step?? I am on a Mac with version 7.0.1 (I think this has occured for a long time, but can't verify it right now). So for example if you try something like: Plot3D[Sin[x y] + 10, {x, -3, 3}, {y, -3, 3}, AxesOrigin -> {0, 0, 10}, Boxed -> False, PlotRange -> {Automatic, Automatic, {0, 20}}] and then click-drag to rotate to look at the bottom and let go there is an extra little jump that the surface goes thru when you let the mouse button go. Then do an Option-click and zoom in and out to still maintain the entire surface in view and let go and no extra jump either. Now do a click-drag again and let go and no extra little translation any more (until you re-execute the cell again). Comments? -Bob === Subject: Re: 3D plots and using mouse click-drag to rotate - why the extra > When you create a 3D plot and then use the mouse to click-drag to > rotate the surface to view it from another angle, there is always an > extra translation thrown in by Mathematica as soon as you let the > mouse button go after this click-drag. ... Is this extra > translation at the end something that you can prevent without having > to resort to the Option-click/zoom step? You can specify an explicit ViewAngle. For example, Plot3D[Sin[x y] + 10, {x, -3, 3}, {y, -3, 3}, AxesOrigin -> {0, 0, 10}, Boxed -> False, PlotRange -> {Automatic, Automatic, {0, 20}}, ViewAngle -> 0.3] Of course, it can be tricky to figure out a good setting for ViewAngle at the start. Incidentally, I figured this out by examining the cell expression for a 3D output cell before and after your Option-click/zoom trick and then comparing. You can examine the cell expression of any cell by highlighting the cell and choosing 'Show Expression' under the Cell menu. Mark McClure === Subject: Re: 3D plots and using mouse click-drag to rotate - why the extra Bob, After a rotation Mathematica tries to fit a frame as good as possible around the plot. This is what causes the jump. If you add SphericalRegion -> True to your Plot function Mathematica reserves enough blank space so that the frame will always be able to contain the plot however you rotate it. If you scale there is no extra fitting necessary, so no jump. > When you create a 3D plot and then use the mouse to click-drag to > rotate the surface to view it from another angle, there is always an > extra translation thrown in by Mathematica as soon as you let the > mouse button go after this click-drag. However, if you do an Option- > click to zoom in or out and then let go there is no extra translation, > and thereafter if you click-drag as before there is no extra > translation after letting go of the mouse button. Is this extra > translation at the end something that you can prevent without having > to resort to the Option-click/zoom step?? I am on a Mac with version > 7.0.1 (I think this has occured for a long time, but can't verify it > right now). So for example if you try something like: Plot3D[Sin[x y] + 10, {x, -3, 3}, {y, -3, 3}, > AxesOrigin -> {0, 0, 10}, Boxed -> False, > PlotRange -> {Automatic, Automatic, {0, 20}}] and then click-drag to rotate to look at the bottom and let go there > is an extra little jump that the surface goes thru when you let the > mouse button go. Then do an Option-click and zoom in and out to still > maintain the entire surface in view and let go and no extra jump > either. Now do a click-drag again and let go and no extra little > translation any more (until you re-execute the cell again). Comments? -Bob === Subject: Re: Export / pipe problems On Apr 18, 1:36 am, Frederick Finkelstein using Mathematica Vers. 6 on Linux, I expected that fig = Plot[x, {x, 1, 10}] Export[!lpr, fig, EPS] should work like advertised in the Documentation Center, instead, I get an error message lpr: error - stdin is empty, so no job has been sent. The same happens with Export[!lpr, Hello World, Text] Does anybody have a idea why stdin could be empty? Of course, Export[fig.eps, fig, EPS] works fine and lpr also. The documentation says, Export[!prog,expr, ...] exports data to a pipe. Do I misunderstand something? Fred. PS: The purpose is to replace Display[!PSPrint, fig] as Display does > not exist any more in v6. This works OK on my Mac - although some of the graph on the printout got clipped off (missing x tick labels and a small portion of the leftmost part of the graph (minimum x value on printout looks to be about 1.4 instead of the value on the screen and what it should be of 1.0 ) So this appears to be specific to Linux (at least) -- wonder if there is a different character on Linux to use instead of the ! -- Is there anywhere in the Documentation Center that has platform specific details? -Bob ps - just for grins try putting a backslash in front of the ! === Subject: Determining a formula with Mathematica 6 With Mathematica 6, can you help me do the following?: * I have multiple sets of about fifty input variables, each set has its own output variable. This is all in an excel spreadsheet. I need Mathematica 6 to create a formula, with the highest possible correlation to the output variable, using the input variables. Dylan === Subject: Re: Determining a formula with Mathematica 6 Hi Dylan, Looks like you're in for a standard data fit, although your phrasing is not really clear. You ask for a solution that maximizes correlation. However, you don't specify what should be correlated with what. I take it that you mean the correlation between the measured and predicted values. Usually, a data fit minimizes an error term which is the sum of the squares of the differences between the predicted and measured values. This is what Mathematica uses. If you want to fit a linear combination of terms you can use Fit. If you have a non-linear model you can try FindFit. If you want to look closer to the fit's statistics (and if you have version 7) you could try LinearModelFit, GeneralizedLinearModelFit, NonlinearModelFit, LogitModelFit, and ProbitModelFit. What you are looking for to create a formula, with the highest possible correlation to the output variable, using the input variables actually doesn't make sense if you don't restrict this formula in some way or another. This is so because it is always possible to find a function (perhaps with many, many coefficients and terms) that will fit your data perfectly. Therefore, I feel (but I may be mistaken here) that you are looking for a fit that simply consists of a linear combination of your 50 input values. Let's call them x1, x2, ..., x49 and x50. To lower the degree of clutter in the following example I'll assume we have 4 inputs. You'll be able to generalize this. In[35]:= Fit[{{1, 1, 1, 1, 4}, {1, 2, 3, 4, 10}, {2, 1, 2, 1, 6}}, {x1, x2, x3, x4}, {x1, x2, x3, x4}] Out[35]= 0.909091 x1 + 1.09091 x2 + 1.09091 x3 + 0.909091 x4 Here you see a fit to a set of three measurements of an output dependent on 4 inputs. The first four numbers in each sublist are the inputs and the last one in each is the output. The next argument of Fit states that I want the fitted function to be in terms of simply x1, x2, x3, and x4. The last argument names the variables, which in this case equals the fit functions themselves. The fit functions could have been any set of functions of x1, x2, x3, and x4 you can think of. Actually, I generated the outputs (4, 10 and 6) by just summing the inputs. In that case you might expect the fit to be x1+x2+x3+x4, but it isn't. How come? Well, the number of data points is less than the number of variables. In this case, the problem is called underdetermined. There is an infinite amount of solutions to the fitting problem. Try filling in the inputs of the example in the function given by Fit and you see that the fit is perfect. In your case, with 50 inputs, it would be good if you had at least 50 observations with different inputs in order to avoid this underdetermination issue. You can try your fit nevertheless, but you can be sure that the solution is not unique. With Mathematica 6, can you help me do the following?: > * > I have multiple sets of about fifty input variables, each set has its own > output variable. This is all in an excel spreadsheet. I need Mathematica 6 to create a formula, with the highest possible > correlation to the output variable, using the input variables. Dylan === Subject: Basic Macintosh text editing features?? I am discovering: 1. can't auto scroll window content while dragging some selected text when it approaches the edge of the window 2. can't drag duplicate some selected text 3. can't drag/drop some selected text between windows I need to use often these moused based editing actions as possible. Why can't the Mac version of Mathematica be a best of breed application for supporting Mac editing? Or, am I missing something here. Or is Mathematica its own world with its own way of doing things, ignoring its host platform? Each platform has editing behaviors for a good reason! Accessibility support is not just about visual or sound. Long live the mouse! Here is a thought: is Workbench the future IDE and the classic IDE is just waiting around till its replaced? Andrew, frustrated (but enjoying doing math again) [using os x 10.5.6] === Subject: Re: Basic Macintosh text editing features?? > I am discovering: > 1. can't auto scroll window content while dragging some selected text > when it approaches the edge of the window > 2. can't drag duplicate some selected text > 3. can't drag/drop some selected text between windows I need to use often these moused based editing actions as possible. Why can't the Mac version of Mathematica be a best of breed > application for supporting Mac editing? Or, am I missing something > here. Or is Mathematica its own world with its own way of doing > things, ignoring its host platform? Each platform has editing > behaviors for a good reason! Accessibility support is not just about > visual or sound. > Long live the mouse! Here is a thought: is Workbench the future IDE and the classic IDE is > just waiting around till its replaced? Andrew, frustrated (but enjoying doing math again) [using os x 10.5.6] The clipboard (via keyboard shortcuts) is far more versatile, efficient, and precise than any implementation of drag and drop editing I've used. The drag and drop analogy should be restricted to files/objects. If you shift to using the clipboard more, I'd recommend LaunchBar (http://www.obdev.at/products/launchbar/). LaunchBar provides a clipboard history and clipmerge, which lets you append to the current pasteboard. === Subject: Mathematica WebServices and EPO OpenPatentServices Hi all, I just found out that Mathematica can work with web services using the WebServices package (see WebServices/tutorial/Overview). I've been trying to get it to work with the web service of the European Patent Office. There is information on how this is supposed to work on http://ops.espacenet.com/ (including the wdsl page), but I don't understand it well enough to get Mathematica to work with it. I get errors all the time. Is there anyone out there with some experience with web services who knows how to get this to work in Mathematica? === Subject: Re: Exporting animations Hi Hannes, Try this: Export[C:Documents and SettingsSjoerdDesktopanimation.avi, Table[Plot[Sin[x + a], {x, 0, 2 Pi}, ImageSize -> 1024], {a, 0, Pi, Pi/20}], FrameRate -> 1] Works for me. > about the resolution of the animation? Export[animation.avi, Table[Plot[Sin[x + a], {x, 0, 2 Pi}], {a, 0, > Pi, Pi/20}], FrameRate -> 1, ImageSize -> Medium, > ImageResolution -> 1024] I played with ImageResolution and also with RasterSize but could not > get a descent resolution of the animated plot at full screen. > A solution to this question is really appreciated. Hannes is there a possibility to adjust the animation rate or speed when > exporting a Manipulate / ControllerManipulate / Animate object with a > fixed number of plots to an .avi file? In Mathematica the > AnimationRate option of Animate works fine, but in the avi-player the > animation runs much too fast. Hannes Kessler > when exporting to a movie you can play with FrameRate option. Have a > look here: http://forums.wolfram.com/mathgroup/archive/2008/Nov/msg00197.html for some further details. > Success, Alexei -- > Alexei Boulbitch, Dr., habil. > Senior Scientist IEE S.A. > ZAE Weiergewan > 11, rue Edmond Reuter > L-5326 Contern > Luxembourg Phone: +352 2454 2566 > Fax: +352 2454 3566 Website:www.iee.lu This e-mail may contain trade secrets or privileged, undisclosed or oth= er= wise confidential information. If you are not the intended recipient and = ha= > ve received this e-mail in error, you are hereby notified that any review= , = > copying or distribution of it is strictly prohibited. Please inform us im= me= fo= > r your co-operation. === Subject: Load .m file from a web server Hi all, I wish to place a .m package on a web server and have many mathematica sessions download and use this package. However, I can not find a way to get this to happen--typing download into the help menu does not give me the answer. I could probably use curl to download and then load, but is there a Mathematica way (i.e. cross-platform) to do this? Eric === Subject: Re: Load .m file from a web server > I wish to place a .m package on a web server and have man= y > mathematica sessions download and use this package. Use Import. Here's an example: Import[http://facstaff.unca.edu/mcmcclur/JuliaSet.m]; Julia[z^3 + I, z] Something tells me that a problem could arise involving Contexts, but I've tried some more complicated examples (packages that load other packages off of the same server) and they seem to work. fine! Mark McClure === Subject: Re: Load .m file from a web server > Hi all, > I wish to place a .m package on a web server and have man= y > mathematica sessions download and use this package. However, I can > not find a way to get this to happen--typing download into the help > menu does not give me the answer. > I could probably use curl to download and then load, but = is there a > Mathematica way (i.e. cross-platform) to do this? > Eric Import[ .../Package.m ]; === Subject: Re: Load .m file from a web server Hi Eric, It looks like Import can do this: Import[http://fmwww.bc.edu/repec/bocode/e/Econometrics.m] ?Reg Reg[y_,x_,opts___] runs a regression of y on x. y is a vector or list of vectors, x is a matrix, a list of vectors or matrices, or a tensor of lists of vectors. Include const (quotes are essential here) in x list if there is to be an intercept. y and x may contain missing observations (any non-numeric entries). Options[Reg] = {displayOutput -> True, varDCom -> False, displayDigits -> 3, varCovMatrix -> OLS (White), algorithm -> QR (SVD), returnValues -> Level1 (Level2)} returnValues Options Level1 = {beta,err,yhat,sig2} (default) Level2 = {beta,err,yhat,sig2,se,vcMat} > Hi all, > I wish to place a .m package on a web server and have man= y > mathematica sessions download and use this package. However, I can > not find a way to get this to happen--typing download into the help > menu does not give me the answer. > I could probably use curl to download and then load, but = is there a > Mathematica way (i.e. cross-platform) to do this? > Eric === Subject: Re: Load .m file from a web server Eric, The easy was is to use Mathematica's built-in ftp capability. The harder way is to use Mathematica's built-in Java capability, and then use Java to get whatever you need from the web. Scot -----Original Message----- === Subject: Load .m file from a web server Hi all, I wish to place a .m package on a web server and have many mathematica sessions download and use this package. However, I can not find a way to get this to happen--typing download into the help menu does not give me the answer. I could probably use curl to download and then load, but is there a Mathematica way (i.e. cross-platform) to do this? Eric === Subject: Re: Load .m file from a web server > Hi all, > I wish to place a .m package on a web server and have many > mathematica sessions download and use this package. However, I can > not find a way to get this to happen--typing download into the help > menu does not give me the answer. Import[http://full-path-here/file.m] does the trick. Depending on the host server settings, it might bring up a dialog asking for a username and password on the host when you Import. I just now tried it on my university web space and was asked for username/password when I imported the test file, but when I posted it on another (non-university) server where I have web space, I was able to import the file without supplying username/password. -- Helen Read University of Vermont === Subject: Graphplot - colors of particular edges is there an easy way how to change colors of some edges in graph? I think I can use this solution: http://mathforum.org/kb/thread.jspa?forumID=79&threadID=1863422&messageID=65 16576#6516576 (only for edges) but it seems to be a little clumsy. This is my graph: GraphPlot[{v9 -> v1, v9 -> v5, v9 -> v7, v9 -> v4, v5 -> v2, v5 -> v0, v7 -> v0, v7 -> v3, v2 -> v1, v3 -> v4, v2 -> v6, v0 -> v6, v0 -> v8, v3 -> v8, v6 -> v10, v8 -> v10, v1 -> v10, v4 -> v10}, VertexLabeling -> True, VertexCoordinateRules -> {v0 -> {0, 0}, v2 -> {-2, 0}, v3 -> {2, 0}, v1 -> {-3, 0}, v4 -> {3, 0}, v5 -> {-1, 1}, v7 -> {1, 1}, v6 -> {-1, -1}, v8 -> {1, -1}, v9 -> {0, 2}, v10 -> {0, -2}}, EdgeRenderingFunction -> ({Black, Thickness[0.0030], Line[#1]} &), VertexRenderingFunction -> ({LightGray, Disk[#1, 0.25], Black, Text[#2, #1]} &)] And I want to change color of several edges - not many. === Subject: Re: Graphplot - colors of particular edges GraphPlot[{v9 -> v1, v9 -> v5, v9 -> v7, v9 -> v4, v5 -> v2, v5 -> v0, v7 -> v0, v7 -> v3, v2 -> v1, v3 -> v4, v2 -> v6, v0 -> v6, v0 -> v8, v3 -> v8, v6 -> v10, v8 -> v10, v1 -> v10, v4 -> v10}, VertexLabeling -> True, VertexCoordinateRules -> {v0 -> {0, 0}, v2 -> {-2, 0}, v3 -> {2, 0}, v1 -> {-3, 0}, v4 -> {3, 0}, v5 -> {-1, 1}, v7 -> {1, 1}, v6 -> {-1, -1}, v8 -> {1, -1}, v9 -> {0, 2}, v10 -> {0, -2}}, EdgeRenderingFunction -> (If[ Thickness[0.0030], Line[#1]}, {Black, Thickness[0.0030], Line[#1]}] &), VertexRenderingFunction -> ({LightGray, Disk[#1, 0.25], Black, Text[#2, #1]} &)] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ is there an easy way how to change colors of some edges in graph? I think I can use this solution: http://mathforum.org/kb/thread.jspa?forumID=79&threadID=1863422&messageID=65 16576#6516576 (only for edges) but it seems to be a little clumsy. This is my graph: GraphPlot[{v9 -> v1, v9 -> v5, v9 -> v7, v9 -> v4, v5 -> v2, v5 -> v0, v7 -> v0, v7 -> v3, v2 -> v1, v3 -> v4, v2 -> v6, v0 -> v6, v0 -> v8, v3 -> v8, v6 -> v10, v8 -> v10, v1 -> v10, v4 -> v10}, VertexLabeling -> True, VertexCoordinateRules -> {v0 -> {0, 0}, v2 -> {-2, 0}, v3 -> {2, 0}, v1 -> {-3, 0}, v4 -> {3, 0}, v5 -> {-1, 1}, v7 -> {1, 1}, v6 -> {-1, -1}, v8 -> {1, -1}, v9 -> {0, 2}, v10 -> {0, -2}}, EdgeRenderingFunction -> ({Black, Thickness[0.0030], Line[#1]} &), VertexRenderingFunction -> ({LightGray, Disk[#1, 0.25], Black, Text[#2, #1]} &)] And I want to change color of several edges - not many. === Subject: Re: Graphplot - colors of particular edges Try this for the EdgeRenderingFunction option: EdgeRenderingFunction -> ({Switch[#2, {v9, v1}, Red, {v6, v10}, Green, {v7, v3}, Blue, _, Black], Thickness[0.0030], Line[#1]} &) is there an easy way how to change colors of some edges in graph? I t= hink I can use this solution: http://mathforum.org/kb/thread.jspa?forumID=79&threadID=1863422&messa= ... (only for edges) but it seems to be a little clumsy. This is my graph: > GraphPlot[{v9 -> v1, v9 -> v5, v9 -> v7, v9 -> v4, > v5 -> v2, v5 -> v0, v7 -> v0, v7 -> v3, > v2 -> v1, v3 -> v4, v2 -> v6, v0 -> v6, > v0 -> v8, v3 -> v8, v6 -> v10, v8 -> v10, > v1 -> v10, v4 -> v10}, VertexLabeling -> True, > VertexCoordinateRules -> {v0 -> {0, 0}, v2 -> {-2, 0}, > v3 -> {2, 0}, v1 -> {-3, 0}, v4 -> {3, 0}, v5 -> {-1, 1}, > v7 -> {1, 1}, v6 -> {-1, -1}, v8 -> {1, -1}, v9 -> {0, 2}, > v10 -> {0, -2}}, > EdgeRenderingFunction -> ({Black, Thickness[0.0030], Line[#1]} &), > VertexRenderingFunction -> ({LightGray, Disk[#1, 0.25], Black, > Text[#2, #1]} &)] And I want to change color of several edges - not many. > === Subject: Re: tooltip - evaluate function at point David's answer completely solved my problem. Cristina ----------------------------- HI Cristina , Of course the important question at this point is to see whether we are using the same version of Mathematica. I am doing this with Version 7 on OSX. It seems to work for me both on the contour and off of it. I agree that the documentation for ContourLabels is somewhat obscure. So, I just tested the code that I sent to you in Mathematica 6 and indeed it does not behave properly. Clearly there is a bug in version 6 that was fixed in version 7. So I have to trick the whole graphics thing in Verions 6 to make this work. Try the following (I use a transparent rectangle above the contourplot so that the Tooltip is getting its coordinates from the rectangle rather than getting it from the buggy ContourPlot): With[{plot = ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 20, ContourLabels -> None], rect = Graphics[{Opacity[0], Rectangle[{-10, -10}, {10, 10}]}]}, Dynamic@ Tooltip[Show[plot, rect], With[{z = Complex @@ MousePosition[Graphics]}, {z, Gamma[z]}]]] Best, David >Hi David, I copied and pasted the code and it does the exact same thing as the >other than the points on the curves. At the points of the curves it >just gives Arg[Gamma[x+I*y]]==0. I couldn't find anything in the documentation of ContourLabels >referring to tooltip other than The label can be any expression or >graphic, and can include constructs such as Tooltip but I don't >understand what that means. It seems to me that ContourLabels is >just a label on the contours on the plot. If specified, they appears >regardless of the position of the mouse. But maybe I am wrong. >Cristina > David Reiss 04/17/09 9:05 PM Hi Crristina, exactly what you wish. Also if you review the documentation for >ContourLabels you will see how it controls the tooltip. >David >Hi David, >>doesn't seem to be connected to Tooltip. There must be some other >>way to turn off the tooltip label and overwrite it with a new label. >>Best wishes, >>Cristina >>Hi Cristina, >>The problem here seems to be that ContourPlot has built into it a tooltip >>that tells you which equation the contour lines correspond to. This >>actually was what I thought was a bug in my example, but I realize that it >>is a feature of ContourPlot. I have to think of how to turn that off, as >>that tooltip seems to preempt any other tooltip that is imposed on the plot >>as I did. >>....Ah, this seems to do the trick, I think, using the option ContourLabels >>-> None]: >>With[{plot = >> ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, >> PlotPoints -> 20, ContourLabels -> None]}, >> Dynamic@Tooltip[ >> plot, (With[{z = Complex @@ MousePosition[Graphics]}, {z, Gamma[z]}])]] >>Yes, if you look up the ContourLabels documentation, this is indeed what's >>needed. >>Does this work for you? >>David > David, all points other than the points on the solution curves given by > Arg[Gamma[x+I*y]]==0. When the mouse goes over the points on the curve the > tooltip gives only Arg[Gamma[x+I*y]]==0. But I am interested in the value > of Gamma precisely at the points on the curves above. Best wishes, Cristina > 04/16/09 8:09 PM Here is the start of one sort of approach. It seems ot have some > >> bugginess though. But perhaps this will get you going: With[{plot = > ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, > PlotPoints -> 20]}, > Dynamic@Tooltip[ > plot, > (With[{z = Complex @@ MousePosition[Graphics]}, > {z, Gamma[z]}]) > ] > ] I suspect that someone else will give you a more stable approach.... --David On Apr 16, 4:18 am, Cristina Ballantine I would like to plot the solutions to an equation using ContourPlot and > > add a tooltip that evaluates a different function at the points on the > > solution. In particular, for the plot > > ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, > PlotPoints -> 20] > > when the cursor is over a solution point I would like the ToolTip to > > display the value of Gamma at that point. Is this possible? If so, any > > suggestion is greatly appreciated. > > Cristina >-- >>This message and any attachments, may contain confidential and/or >>legally privileged information. If you are not the intended >>recipient of the message by the original sender, please destroy it. >>Message and attachments copyright (c) 2009, all rights reserved. Any >>unauthorized dissemination, distribution or copying is strictly >>forbidden. >-- <><><><><><><><><>><><><>><><>< David Reiss, Ph.D; Scientific Arts, LLC . > http://www.scientificarts.com ><><><><><><><><><>><><><>><><>legally privileged information. If you are not the intended >recipient of the message by the original sender, please destroy it. >Message and attachments Copyright (c) 2009, all rights reserved. -- <><><><><><><><><>><><><>><><><> David Reiss, Ph.D; Scientific Arts, LLC . http://www.scientificarts.com <><><><><><><><><>><><><>><><><> This message and any attachments, may contain confidential and/or legally privileged information. If you are not the intended recipient of the message by the original sender, please destroy it. Message and attachments Copyright (c) 2009, all rights reserved. --=__Part7A52D74A.0__=-- === Subject: Re: Abbreviation of File Names in File Menu > In the drop down File Menu the penultimate block is a list of recently > used notebooks; 30 in my case because I have used the options > inspector to change NotebooksMenuHistoryLength. I like long notebook > names because it helps me to distinguish changes I have made. In > Version 7 these names are now given in an abbreviated form with the > first few characters, three dots (an ellipsis) and the last few > characters. This means that I can't reap the benefit of long file > names because the middle of the name is missing. I have plenty of > width across the screen so abbreviating is no help. Is it possible to prevent the file names being abbreviated.? > Hugh Goyder There is a further problem with this feature. I too would like to look back at a longer list of recent file choices, but Mathematica picks out mnemonic letters for these which clash with letters used in the earlier part of the menu. Thus for example, if (with Windows) you type Alt-FS, you normally activate the save menu item, but sometimes with an extended list the S will have been picked again, which invalidates this method of selection completely. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Abbreviation of File Names in File Menu > In the drop down File Menu the penultimate block is a list of recently > used notebooks; 30 in my case because I have used the options > inspector to change NotebooksMenuHistoryLength. I like long notebook > names because it helps me to distinguish changes I have made. In > Version 7 these names are now given in an abbreviated form with the > first few characters, three dots (an ellipsis) and the last few > characters. This means that I can't reap the benefit of long file > names because the middle of the name is missing. I have plenty of > width across the screen so abbreviating is no help. Is it possible to prevent the file names being abbreviated.? > Hugh Goyder I tried this on my Mac with version 7 and with a really long file name it didn't get abbreviated in the recent files list. What platform are you on (Windows, Linux, or ???). How long of filenames are you dealing with? -Bob === Subject: Re: Abbreviation of File Names in File Menu In the drop down File Menu the penultimate block is a list of recently > used notebooks; 30 in my case because I have used the options > inspector to change NotebooksMenuHistoryLength. I like long notebook > names because it helps me to distinguish changes I have made. In > Version 7 these names are now given in an abbreviated form with the > first few characters, three dots (an ellipsis) and the last few > characters. This means that I can't reap the benefit of long file > names because the middle of the name is missing. I have plenty of > width across the screen so abbreviating is no help. Is it possible to prevent the file names being abbreviated.? > Hugh Goyder I tried this on my Mac with version 7 and with a really long file name > it didn't get abbreviated in the recent files list. What platform are > you on (Windows, Linux, or ???). How long of filenames are you dealing > with? -Bob I am using Windows. Below are some examples of abbreviations. The abbreviated version first then the full version (spelling mistakes are mine). There are obviously some interesting heuristics on how the ellipsis is inserted. Example ham ... lysis v1.nb Example hammer analysis v1.nb f1234567890...34567890.nb f123456789012345678901234567890.nb Pressure wav...f PSV v1.nb Pressure waves set up by opeing of PSV v1.nb Further ram...lysis v1.nb Further ram release analysis v1.nb Abbrivated...amples .nb Abbrivated files names examples .nb === Subject: Re: Passing arrays to MathLink without extra memory allocation Are there any other solutions for passing pointers to big data from > mathematica to external programs? No In this context, an 'external > program' does not need to be a separate process, it could simply be a > loadable shared library. The way another system deals with its c-extensions is > a good example of what I mean by this. A MahtLink program can run on a second computer, that will not work with dynamic librarys It seems like those official mathematica functions implemented in > native code do not have the above constraint and it is possible to > pass pointers without deep copying, is this correct? What is a official Mathematica function ? Why do you assume that the kernel store your data in the same way as your code does ? Since Mathematica can store symbols, expressions, integers, multi-precision numbers in its lists your program would never know what is in the memory location. MathLink is the only way to unfold the internal structures and to send it to an external program. If so, how is it > possible to implement a function like this? > *IT IS NOT POSSIBLE* And with a little cleverness in cen C-code it is not necessary. I have C-programs that deal with several GByte of data for visualization and image processing tasks and I have no idea for what this should be good for. Jens > On 18 Apr, 08:37, Jens-Peer Kuska a) MathLink is always buffered and >> b) it must copy the data into a memory area >> that bot programs can access >> c) your C-program can never access the memory space >> of an other program/process. The operating system is >> responsible to hinder/prevent such operations >> Jens > When passing a list/array from mathematica to c using mathlink, eg > when calling MLReleaseInteger32List(), it seems mathlink allocates > some memory which later has to be freed, eg using > MLReleaseInteger32List(). The question is, how is it possible to pass > a list from mathematica to c without this c memory allocation? > This example helps to make the question more clear: Assume MyFunction > [BigList] to be a function implemented in c using mathlink, where > BigList is a list of integers. Since BigList has been already created > in mathematica and its corresponding memory has been allocated, we do > not wish to allocate memory once again in c. It looks like one option > is to pass BigList by reference, that is: > SetProperties[MyFunction, HoldAll] > In this case, does mathlink still allocate memory and copy BigList in > the c side? === Subject: Re: Determining a formula with Mathematica 6 >With Mathematica 6, can you help me do the following?: * I have >multiple sets of about fifty input variables, each set has its own >output variable. This is all in an excel spreadsheet. >I need Mathematica 6 to create a formula, with the highest possible >correlation to the output variable, using the input variables. Anything that can be evaluated in Excel, absolutely anything can also be done in Mathematica. Mathematica is far far more capable than Excel. But beyond stating what to me is obvious, there isn't anything to offer in the way of specifics. All you've done is state you have a large number of input/output variables. You've not described what you are trying to do. There are literally and infinite number of formula's that can be created that will correlate input variables to output variables. === Subject: Plot Axis Unit Conversions Hello everyone, I am working on a notebook involving a flutter analysis of a flat plate in a wind tunnel. All of the equations involve metric units, but most of the physical measurements of size I have are in inches. In order to maintain a consistent system of units, I would like to plot the axis units in metric and English units. Specifically, I have a plot for the critical flutter speed in units of m/s versus the chord length in meters, and I want to overlay an x-axis, possibly on the top, that will display the equivalent length in inches (i.e, xinches=x*10000/254) without messing up the graph. At the very least, I would like to display it in centimeters instead of meters for better clarity. I do NOT want to recalculate the function using inches - just display the conversion. It would be nice if I could display it in both inches and centimeters at the same time. This is an absolute breeze to do in another system, but I haven't been able to find anything specifically dealing with scaling of axes for Mathematica. Anyone have any ideas? === Subject: Re: Any way to make help browser remember the last > [...] >> If the Help material (and other documentation) for Mathematica were >> written and displayed in another app and format (like, for example, >> Adobe PDF), as is the case with most other major applications, you >> could >> jump back and forth between your active Mathematica windows and your >> currently active documentation window(s), leaving both of them >> absolutely stable and unchanged in between viewings, with a single >> keystroke, Cmd-Tab (on a Mac, anyway). >> Works like a charm; I do it all the time with other apps. And, >> documentation in the form of a PDF file can be scanned, viewed, >> searched, enlarged, read, and generally used _immensely_ more >> effectively and easily in, say, Adobe Acrobat (or probably Reader, >> though I don't use that) than documentation in Mathematica's cramped >> and >> awkward format. >> These other applications and their documentation display tools, how well >> do they handle input and evaluation of mathematical content? I appreciate that there can be some value in being able to > evaluate Mathematica examples or cells that are contained > within the Mathematica documentation pages, directly within > those pages. I personally do not find that I make much use of this, however -- > and when I do want or need to do so, I can always (and would > generally prefer to) copy the example (which is almost always a > brief single cell or example) into my own running copy of > Mathematica (which would be necessarily running anyway), where > I can modify or customize it to apply to the situation I want to > understand. It has been pointed out that this is not a trivial undertaking if the format is anything other than InputForm. And it involves extra work on the part of the user. The point being that whatever method we use for documentation, some people will need to do extra work to get what they want, if what they want is something other than the documentation notebook. > And the numerous advantages of reading documentation in a more > suitable format and using more suitable software -- in PDF, for > example -- which I've listed above, coupled with the disadvantages > associated with having to read it in the existing Mathematica > documentation formats, just make the choice a no-brainer, IMHO. Clearly we disagree here. >>[...] >> [Did I add, that selected pages or sections of documentation in PDF >> can >> also be printed out, if you'd prefer to have a few particularly >> relevant >> pages of the documentation sitting on your (physical) desktop, beside >> your keyboard -- where you can just glance over at it, without having >> to >> close or open anything on screen.] >> Last time I checked (which was today), one can still print Mathematica >> notebooks. This would apply to e.g. Help browser pages. Last time I checked, most of the rest of the software world -- > indeed most of the rest of the world, period -- was supplying its > documentation in downloadable PDF format; and even the authors > and distributors of many books and manuals sold on paper were > also including a full CD of the full content along with the > purchased book (and were also continuing to write, publish, > and successfully market these books and manuals). Could it > be there's a reason for this . . .? One can get documentation in a conventional web-based form. Quick top right there is a URL button. Click and it gives a dropdown menu with a Go to web url option. If you click that, you get to the web page below. http://reference.wolfram.com/mathematica/ref/ContourPlot.html So now your documentation is in a standard format, of a web page, and you are on a site from which you can navigate. For purposes of documentation, web pages seem also to be well received, and are more readily navigated than pdf files (since one can change pages without requiring hot links). > Or are you suggesting that it would be too difficult for Wolfram > to serve different portions of its customer base, who might have > varying needs or preferences, by just setting up an automated > process to convert its documentation into PDF files on its web > site, which users could then access and selectively download, > when, if, and as they needed? I do not know if this would be difficult. If it is at all difficult, it might or might not be worth doing. The down side is of course the opportunity cost, in that it would very nearly replicate existing functionality (the viewing and navigability parts covered by html-based documentation, and the printing by notebook printing), at the expense of different development and/or documentation work. Not my call, but I myself see that as a significant issue. I will say that I agree there is a need for some amount of pdf-based documentation, specifically of the virtual book. I asked about that in house several months ago, and was told it is under discussion. I do not know what are the eventual prospects. >> In the Help browser notebooks one can also click on URLs to the >> corresponding (html) web pages, bring them up, print them, etc. Maybe >> not suitable for framing (unless you print on really good paper). But >> useful all the same. The endless and aimless clicking through literally hundreds if > not thousands of infinitely branching links, trying to find > out what is in Mathematica's documentation, or where it is, > within what often seems an infinitely expanding tree structure -- > or, later on, attempting to get back to something that you > noted earlier on and now realize you want -- is in fact _the_ > single most aggravating and disfunctional aspect of the > whole system. The web based documentation has quite standard methods of navigation, including the usual back button and bookmarking capabilities. I doubt this is substantially different from documentation for any other product. The need for branching follows from the very obvious need to handle the sorts of thing you yourself have complainend about long and often, to wit, that Mathematica is a complex product, requiring substantial documentation. And I would expect that the documentation will grow, not shrink, as more gaps get filled over time. Moral: You can get what you want, and still not be very happy. (Might be a very old quote; I think I first saw it in an old issue of Cerebus the Aardvark.) Daniel Lichtblau Wolfram Research === Subject: Re: Any way to make help browser remember the last Daniel, do you know of a straightforward way to make the Documentation Center remember its position across Mathematica sessions? The fact that it always returns to the center of the screen frustrates me as -Daniel Grady === Subject: Re: Any way to make help browser remember the last position? > What bugs me, no, drives me mad, is the fact that, every time I press > F1 key to invoke the help or 'documentation center,' it goes straight > to the center of the screen instead of to the right like it did v4 and > 5. This started in v 6 except I didn't have much need for using v6. Now > that I have a need v7, I absolutely hate the fact that help browser > covers the open notebook and I have to move it manually. Is there a way to make it remember the last position? Sean Sean, Just discovered this really doesn't work quite right. Any time you click on something in the DC window or type in something in the Search box, it brings up another window instead of putting the content in the already created window, so you are back where you started. Perhaps someone in the group will have an explanation of how/why this happens. Sorry ... -Bob === Subject: Re: Any way to make help browser remember the last position? > What bugs me, no, drives me mad, is the fact that, every time I press > F1 key to invoke the help or 'documentation center,' it goes straight > to the center of the screen instead of to the right like it did v4 and > 5. This started in v 6 except I didn't have much need for using v6. Now > that I have a need v7, I absolutely hate the fact that help browser > covers the open notebook and I have to move it manually. Is there a way to make it remember the last position? Sean Sean, You could modify the notebook file for the Documentation Center (just DC from now on) which is located (on a Mac) /Applications/Wolfram/Mathematica.app/Documentation/English/System/ Guides/Mathematica.nb and specify the desired values for WindowSize and WindowMargins settings. Put the DC window where you want it to always come up and the size you want it to have and then use Options Inspector to find out these values for WindowSize and WindowMargins. Be careful using the Options Inspector if you are not familiar with it. You should also make a backup copy of this file just in case you hose it up when editing it. Another thing you could do is add this file to the list of AutoOpenNotebooks (could use the Options Inspector for this also) in the init.m file. And while you're at it make a spare copy of your init.m file ( on a Mac this is located in ~/Library/Mathematica/FrontEnd ) as this is where the AutoOpenNotebooks is saved. You also need to set the Saveable->False to Saveable->True if you want it to remember where this DC window was last (and in fact you need to set this before the first time you change the size and/or position of the DC window). I would recommend to everybody that they make a copy of the init.m file -- if you ever accidently delete it sometime it is very painful to recreate what it had (the voice of experience -- this has happened to me and I was very bummed when I didn't have one and had to recreate a bunch of things all over again). There might be other side effects of making these changes, so please make a backup copy of changed files in case you need to go back to their initial state. HTH... -Bob === Subject: representing the dihedral group {1,r,r^2...s,sr^2...} in mathematica so I can do for example: s^3 and get s. I tried this code: Unprotect[Times, Power]; n = 4; ClearAll[r, s, Times, Power]; SetAttributes[Times, {Flat}] s^2 = 1; r^n = 1; Protect[Times, Power]; But this doesn't work for, for example, s^3. It is not able to simplify it. Otto === Subject: Re: representing the dihedral group {1,r,r^2...s,sr^2...} leave so important Mathematica functions like Times[] and Power[] unchanged and make your own GroupTimes[], GroupPower[] all other will probably not work. Times[] and Power[] are to deep hard coded in the Mathematica kernel. Jens > in mathematica so I can do for example: s^3 and get s. I tried this code: Unprotect[Times, Power]; > n = 4; > ClearAll[r, s, Times, Power]; > SetAttributes[Times, {Flat}] > s^2 = 1; > r^n = 1; > Protect[Times, Power]; But this doesn't work for, for example, s^3. It is not able to > simplify it. > Otto > === Subject: Mathematica documentation - for newest and older versions I just discovered that Wolfram now has all the documentation collected in one place for older versions of Mathematica and webMathematica and gridMathematica and Mathematica CalcCenter and Publicon, apparently in English, Japanese, Chinese, French, and German, along with about 20 packages. It is located at http://reference.wolfram.com/siteindex.html -- and there is even a PDF version of Stephen Wolfram's classic Mathematica Book for version 5 at http://reference.wolfram.com/legacy/v5_2/Mathematica_V5_Book.zip if you don't already have a copy (this is the 1464 page book that is no longer in print and is a wonderful source of information IMHO). I have not noticed this before, but think it's a great resource that nice web site tree like this!!! Now if only the PDF versions of the Documentation Center content for version 7.0 were done, life would be grand indeed!!!! (but they are are on their way the web site says -- see http://www.wolfram.com/learningcenter/tutorialcollection/ to see what they are intending to have if you have not seen this before. It appears that you will be able to order hardcopies (for a fee) of all the 7.0 documentation as well as download free versions of the PDF files for each of the sections. I am hoping that they also have one complete PDF file that has everything in it to make searching for things in the Mathematica documentation possible without the Documentation Center, although I agree that not having the ability to treat the documentation as a normal Mathematica notebook to play around with, will be hard to get used to not having. But I think it will provide a nice addition to the family of tools available to help with learning and using Mathematica!! Kudo's to Wolfram for providing these sorts of tools!! -Bob === Subject: Re: Mathematica documentation - for newest and older versions Cool! Just in time for me ;-) But when I compared the online help of a local version to these new docs, I see some differences, good ones as far I can tell now. It looks like a more classic narrative/descriptive approach is used. Yeah. And, WRI, thank for making the PDF free download. :-) Andrew === Subject: Re: About Reduce and domains if you want something like x>0... then you specify a domain implicitly. For a complex number x>0 does not make much sense. Note that you may also specify the domain of some variables in the first argument of Reduce: Reduce[{..,Element[{x,y},Reals],..}] Daniel Hi Mathematica community, I remarqued in many outputs with reduce, that mathematica treats some > parameters as complexe numbers and consequently distinguich between Re > part and Im part: > For example: > (Re[d]<0&&Re[a]<0&& ...) || (Re[d]<0&&Re[a]==0&&Im[a]<0&& ...) || (= Re > [d]<0&&Re[a]==0&&Im[a]>0&&...) || (Re[d]<0&&Re[a]>0&&...) || (Re[d] > ==0&&Im[d]<0&&Re[a]<0&&...) ||... In the help I have read that Reduce[expr,vars] assumes by default that > quantities appearing algebraically in inequalities are real, while all > other quantities are complex. But is there a mean to force mathematica in the way that it does not > distinguich between real part and imaginary part in the output and > consequently to have: d<0 && a<0 ...|| d==0 && a>0 || ...without > specifying a domain which means without Reduce[expr,vars,doms]? > - Afficher le texte des messages pr=E9c=E9dents - Hi daniel, the problem is that I dont know in advance which variables should I put in Element because it depends on which variables mathematica treat as complexe in the output. so how to deal with that? === Subject: Parallel processing downgrade The change from Mathematica 7.0.0 to 7.0.1 seems to be a downgrade in the area of parallel processing. Try LaunchKernels[8] in both. Back in good old 7.0.0 you get: {KernelObject[1, local], KernelObject[2, local], KernelObject[3, local], KernelObject[4, local], KernelObject[5, local], KernelObject[6, local], KernelObject[7, local], KernelObject[8, local]} Eight kernels - cool! In 7.0.1, you get {KernelObject[1, local], KernelObject[2, local], KernelObject[3, local], KernelObject[4, local], $Failed, $Failed, $Failed, $Failed} A little disappointing. The results are independent of how many processors your computer has. Mark McClure === Subject: Re: Parallel processing downgrade > The change from Mathematica 7.0.0 to 7.0.1 seems to be a > downgrade in the area of parallel processing. Try > LaunchKernels[8] in both. Back in good old 7.0.0 you > get: > {KernelObject[1, local], KernelObject[2, local], > KernelObject[3, local], KernelObject[4, local], > KernelObject[5, local], KernelObject[6, local], > KernelObject[7, local], KernelObject[8, local]} Eight kernels - cool! In 7.0.1, you get {KernelObject[1, local], KernelObject[2, local], > KernelObject[3, local], KernelObject[4, local], > $Failed, $Failed, $Failed, $Failed} A little disappointing. The results are independent of how many processors your > computer has. Mark McClure I believe the default license only supports 4? kernels. Unless your using grid (and mathlm), then you could try launch the kernels, one at a time, in a loop. Do[LaunchKernels[1],{8}] === Subject: Re: Looking for more Mathematica online user groups/forums Humm. I was just wrestling (thinking out loud) with the state of affairs with tech support outside of phone/WRI email after my limited 30 days. I appreciate all who have in past, present and future contributed to MathGroup list. Yes, I can wait, heaven knows I often have to wait due to my limitations. Yes, the answers are worth waiting for. But Steve C. is just one person, imagine what could be if there were many helping to review/respond. Yes, I will use MathGroup for it seems to be the only live game in town. Andrew === Subject: Re: Looking for more Mathematica online user groups/forums If the answers are not worth waiting 24 hours for, maybe you should not ask? The people answering your questions put quite an effort into that, and often need some time to think it over. They must assume that you are enough interested in the answer to be able to wait for it. So please be a bit patient! Another point is that there is a quite limited number of people, able and interested enough, to answer these kind of questions. And too few are able to be online and responding around the clock. There has been several attempts to complement MathGroup with other user resources. The most notable is the Mathematica-users Wiki at http://www.mathematica-users.org. But this site seems to be in a state of slow disintegration (please correct me if I am wrong there!), and that is something I regret. Other attempts have just faded away, e.g. hurray for MathGroup! Ingolf Dahl > -----Original Message----- === > Subject: Looking for more Mathematica online user > groups/forums WRI, Since Home edition offers me only 30 days tech support and I > am not a student around other Mathematica using students on a > campus. And buying expensive books does only cover so much > (And many are outdated or does not cover areas outside of > math like the Frontend), where on the internet do I find help > thats more real time? This group has been very helpful, but I > want more rapid turn around time, and someone to teach why > some code is good and mine is bad so I learn from mistakes . I do find it strange there is not a more active WRI > collection of people part of a tech support forum somewhere. > A whiteboard version of the FE to aid in support could be a > good direction. Collaborative editing FE in real time > somehow? How about a Home Ed users forum on WRI site?? Or perhaps allow Home Edition users email support; if it is > so, be clear it is so and how long the turn around time for a > reply. Or encourage local universities to create local > Mathematica support groups. Mathematics is a social activity as much as any other > creative one; helping each other is a great way to enjoy learning. Andrew, seeking some shoulders to stand on ;-) === Subject: Re: Looking for more Mathematica online user groups/forums I asked the same question at a summer school last year. In the past Sarah Flannery?? worked on an online collaboration tool but I gather there were security problems and risks from malware being sneaked onto our systems via Mathematica commands. As far as I can see, MathGroup is the best forum but the information exchange mechanism is a little outdated. Luuk B. tried to get a Wiki going but I couldn't see a clear reason for using it and not MG. I occasionally wonder if there will be a point when Steve gets tired of supporting the group and what would happen at that point - I suspect there is a significant amount of effort on his part. It seems odd that WRI don't host something with voluntary support from staff. It could be something as simple as standard Forum - that would give us all the chance to have Profiles, share files etc. It would also make it easier for Steve and others to moderate. Robert ----- Original Message ---- === Subject: Looking for more Mathematica online user groups/forums WRI, Since Home edition offers me only 30 days tech support and I am not a student around other Mathematica using students on a campus. And buying expensive books does only cover so much (And many are outdated or does not cover areas outside of math like the Frontend), where on the internet do I find help thats more real time? This group has been very helpful, but I want more rapid turn around time, and someone to teach why some code is good and mine is bad so I learn from mistakes . I do find it strange there is not a more active WRI collection of people part of a tech support forum somewhere. A whiteboard version of the FE to aid in support could be a good direction. Collaborative editing FE in real time somehow? How about a Home Ed users forum on WRI site?? Or perhaps allow Home Edition users email support; if it is so, be clear it is so and how long the turn around time for a reply. Or encourage local universities to create local Mathematica support groups. Mathematics is a social activity as much as any other creative one; helping each other is a great way to enjoy learning. Andrew, seeking some shoulders to stand on ;-) === Subject: Looking for more Mathematica online user groups/forums WRI, Since Home edition offers me only 30 days tech support and I am not a student around other Mathematica using students on a campus. And buying expensive books does only cover so much (And many are outdated or does not cover areas outside of math like the Frontend), where on the internet do I find help thats more real time? This group has been very helpful, but I want more rapid turn around time, and someone to teach why some code is good and mine is bad so I learn from mistakes . I do find it strange there is not a more active WRI collection of people part of a tech support forum somewhere. A whiteboard version of the FE to aid in support could be a good direction. Collaborative editing FE in real time somehow? How about a Home Ed users forum on WRI site?? Or perhaps allow Home Edition users email support; if it is so, be clear it is so and how long the turn around time for a reply. Or encourage local universities to create local Mathematica support groups. Mathematics is a social activity as much as any other creative one; helping each other is a great way to enjoy learning. Andrew, seeking some shoulders to stand on ;-) === Subject: Re: Looking for more Mathematica online user ...that's the impression I was beginning to get.... 2009/4/20 Sjoerd C. de Vries WRI, Since Home edition offers me only 30 days tech support and I am not a > student around other Mathematica using students on a campus. And > buying expensive books does only cover so much (And many are outdated > or does not cover areas outside of math like the Frontend), where on > the internet do I find help thats more real time? This group has been > very helpful, but I want more rapid turn around time, and someone to > teach why some code is good and mine is bad so I learn from mistakes . I do find it strange there is not a more active WRI collection of > people part of a tech support forum somewhere. A whiteboard version of > the FE to aid in support could be a good direction. Collaborative > editing FE in real time somehow? How about a Home Ed users forum on > WRI site?? Or perhaps allow Home Edition users email support; if it is so, be > clear it is so and how long the turn around time for a reply. Or > encourage local universities to create local Mathematica support > groups. Mathematics is a social activity as much as any other creative one; > helping each other is a great way to enjoy learning. Andrew, seeking some shoulders to stand on ;-) > -- Peter Lindsay === Subject: Re: Looking for more Mathematica online user groups/forums > WRI, Since Home edition offers me only 30 days tech support and I am not a > student around other Mathematica using students on a campus. And > buying expensive books does only cover so much (And many are outdated > or does not cover areas outside of math like the Frontend), where on > the internet do I find help thats more real time? This group has been > very helpful, but I want more rapid turn around time, and someone to > teach why some code is good and mine is bad so I learn from mistakes . I do find it strange there is not a more active WRI collection of > people part of a tech support forum somewhere. A whiteboard version of > the FE to aid in support could be a good direction. Collaborative > editing FE in real time somehow? How about a Home Ed users forum on > WRI site?? Or perhaps allow Home Edition users email support; if it is so, be > clear it is so and how long the turn around time for a reply. Or > encourage local universities to create local Mathematica support > groups. Mathematics is a social activity as much as any other creative one; > helping each other is a great way to enjoy learning. Andrew, seeking some shoulders to stand on ;-) Since this is a moderated list, the lag time is just something people on this list live with I guess. The other Mathematica resources I know about are: 1. This newsgroup list - comp.soft-sys.math.mathematica -- very knowledgeable about Mathematica, but not real fast turn around on questions. I try to usually reply to both the poster directly and the newsgroup, so replies can be a day quicker, but this still means a minimum 1 day turn-around, rather than the 2-day if you just reply to the newsgroup. 2. The student newsgroup forum at http://forums.wolfram.com/student-support= /list/ (it is moderated also but I don't think there is any way for them to verify you are a student so anyone can ask questions I think) 3. The sci.math.symbolic newsgroup - not moderated but not dedicated to Mathematica either 4. Wolfram web sites like MathWorld, etc (good list of these are at http://www.wolfram.com/products/student/mathforstudents/resources.html -- but these do not qualify as social activities 5. The Wolfram screencasts are pretty good about explaining very narrow topics -- see http://www.wolfram.com/learningcenter/ for a good jumping off point. 6. The Wolfram Demonstrations project at http://demonstrations.wolfram.com/ -- this is a really good place to see examples of lots of single- purposed different applications of Mathematica 7. The free on-line Wolfram seminars at http://www.wolfram.com/services/edu= cation/seminar.cgi You might want to talk with your local college or school district and see if there are any Mathematica users/experts. I agree it does seem odd that there is not a more active Mathematica user community out makes interaction a bit difficult. 8. The Wolfram Blog at blog.wolfram.com 9. If you ever get a chance to go to the User Conference in Champaign (usually in late October of every year I think) - this is a really great place to hear many talks and speak with many people who are really heavy duty Mathematica users/experts, as well as many Wolfram people who attend and give presentations. I went a couple of years ago and it was a week that was jam packed with Mathematica info. Wolfram puts a lot of the talks from all these on their web site -- e.g. see http://www.wolfram.com/news/events/userconf2008/ -- if there is any way for you to be a student you can get a tremendous discount for this meeting as well as the training classes that are always given before and after the actual meeting (meeting is usually 3 days on a Thur-Fri- Sat and training classes run on the Tue & Wed and Sun before and after the main meeting) You might wish to suggest to the people at Wolfram that they set up a Mathematica users forum like what Apple has (a corporate site with non- moderated content created by users with the occasional input from company people). Start up your own Mathematica group on Google that is not moderated and see what happens. Start up your own Mathematica user group in your area, ... But I think the best way to learn about Mathematica is to use it as much and often as you can and build up your own skills to as high a level as you wish. Another good book is Stephen Wolfram's The Mathematica Book which is available on Wolfram's web site now as a PDF (this is the ~1500 page book for version 5.2, but most of it is still very applicable to how Mathematica works) - the PDF is at http://reference.wolfram.com/legacy/v5_2/Mathematica_V5_Book.zip Good luck ... -Bob === Subject: Re: Looking for more Mathematica online user groups/forums > This group has been very helpful, but I want more rapid > turn around time Mathgroup has been around a long time and has been a tremendous value to the community. The delay in response, however, is a pretty major issue. Given the rising number of rapid response alternatives that also deal reasonably personally think it would be great to see such a forum become the main information exchange among Mathematica users. Mark McClure === Subject: Re: Looking for more Mathematica online user groups/forums Perhaps a mathematically gifted slave would be something for you? > WRI, Since Home edition offers me only 30 days tech support and I am not a > student around other Mathematica using students on a campus. And > buying expensive books does only cover so much (And many are outdated > or does not cover areas outside of math like the Frontend), where on > the internet do I find help thats more real time? This group has been > very helpful, but I want more rapid turn around time, and someone to > teach why some code is good and mine is bad so I learn from mistakes . I do find it strange there is not a more active WRI collection of > people part of a tech support forum somewhere. A whiteboard version of > the FE to aid in support could be a good direction. Collaborative > editing FE in real time somehow? How about a Home Ed users forum on > WRI site?? Or perhaps allow Home Edition users email support; if it is so, be > clear it is so and how long the turn around time for a reply. Or > encourage local universities to create local Mathematica support > groups. Mathematics is a social activity as much as any other creative one; > helping each other is a great way to enjoy learning. Andrew, seeking some shoulders to stand on ;-) === Subject: Re: Looking for more Mathematica online user groups/forums As you say, this group is really pretty fantastic for help. Sounds as though you want a lot more for free. 24hr turnaround is pretty good for any commercial software help, and that is about what you get with this newsgroup. Kevin > WRI, Since Home edition offers me only 30 days tech support and I am not a > student around other Mathematica using students on a campus. And > buying expensive books does only cover so much (And many are outdated > or does not cover areas outside of math like the Frontend), where on > the internet do I find help thats more real time? This group has been > very helpful, but I want more rapid turn around time, and someone to > teach why some code is good and mine is bad so I learn from mistakes . I do find it strange there is not a more active WRI collection of > people part of a tech support forum somewhere. A whiteboard version of > the FE to aid in support could be a good direction. Collaborative > editing FE in real time somehow? How about a Home Ed users forum on > WRI site?? Or perhaps allow Home Edition users email support; if it is so, be > clear it is so and how long the turn around time for a reply. Or > encourage local universities to create local Mathematica support > groups. Mathematics is a social activity as much as any other creative one; > helping each other is a great way to enjoy learning. Andrew, seeking some shoulders to stand on ;-) > === Subject: Re: Looking for a scrolling list control, or how to create/simulate OK, here is what I have come up with so far. Any corrections or improvements? And how do I reuse my custom control outside of the current notebook cell? That is how do I install it for use in other ListField[wd_, tz_, ls_] := DynamicModule[{x}, ld = Length[ls]; Framed[ Pane[ Column[ Table[ With[ {i = i} , Button[Style[ls[[i]], FontSize -> tz], Dynamic[x = ls[[i]]] , Appearance -> None , ImageSize -> {wd, tz + 2} , ImageMargins -> 0 , Alignment -> Left] ], {i, lt} ], Spacings -> 0 ] , ImageSize -> {wd, Round[(ld*tz/2) + (ld*2) - 4]} , ImageMargins -> {{1, 0}, {0, 0}} , Scrollbars -> {False, True} , AppearanceElements -> None ] , FrameMargins -> {{1, 0}, {0, -1}} ] Dynamic[x] ] mm = {yes, no, Andrew Merit, Marvin Honks, Pam Bakes, Marie loves, Anne jo Ann}; ListField[120, 14, mm] === Subject: Re: Looking for a scrolling list control, or how to create/simulate > I am a little surprised there is not a scrolling list like control. I > can find an input field but no way to make it work like a scrolling > list. Am I missing something in docs? Have anyone created such a Pane[1000!, ImageSize -> {400, 300}, Scrollbars -> True] Pane[1000!, ImageSize -> {400, 300}, Scrollbars -> Automatic] -Rob === Subject: Re: Importing a large image... I think that there is an inevitable difference between marketing (the video) and reality (the book). It would be interesting to know if there is a quote similar to the one on p 215 of the v5 book in the electronic documentation. george > Naturally, Mathematica can't be good for any task. Sometimes you > have > to use other programs too :) >> That's not what certain other people (at least one of them named >> Wolfram) are saying . . . right? >> Well, then he must have changed his mind since M5: > Although Mathematica does many things well, there are some things > that are > inevitable better done by external programs. :-) (The Mathematica Book, 5th edition, p.215) === Subject: Re: Importing a large image... > Naturally, Mathematica can't be good for any task. Sometimes you have >> to use other programs too :) That's not what certain other people (at least one of them named > Wolfram) are saying . . . right? = jP, j + i == jP = + = > iP, > Element[{n, iP}, Integers], Not[(iP < n)], > Exists[{iPP}, (iPP < n) && iP == iPP + 1]}, {iP, jP}, > Backsubstitution -> True] Hi Mathematica community, > I have to solve this system: > Reduce[{Element[{i, j}, Integers], i <= iP, j >= jP, > 1*j + 1*i == 1*jP + 1*iP, > Reduce[{Element[{N, iP}, Integers], Not[(iP < N)], > Exists[{iPP}, (iPP < N) && iP == iPP + 1]}]}, {iP, jP}, > Backsubstitution -> True] the output should be:( i | j | N | iP) are Integers && i <= N && iP = == > = > N && > jP == i + j - N > but mathematica gave me this output: > (C[1] | C[2] | C[3] | C[4]) are Integers && C[1] >= 0 && > C[2] >= 0 && C[3] >= 0 && C[4] >= 0 && i == C[1] - C[2] - = C[= > 3] && > iP == C[1] - C[2] + C[4] && N == C[1] - C[2] + C[4] && > jP == j - C[3] - C[4] which is not understandable at all! and I dont want the output to be > like that. I have observed that when I remove i from Element[{i, j}, Integers] > mathematica give me the output I want and which is :iP == N && j= P = > == > i + j - N So how can I have this same output without removing i from Element[{i, > j}, Integers]? > =E9dents - - Afficher le texte des messages pr=E9c=E9dents - Hi Sjoerd, Yes it works but I need to have 2 reduce because my system can be more complicated than that and consequently one reduce won't be sufficient. For example when I add some equations to my system and keep only one reduce as you suggest. mathematica can't solve it. So I need 2 reduce. Is there another possibility to avoid having this kind of output: (C[1] | C[2] | C[3] | C[4]) are Integers && C[1] >= 0 && C[2] >= 0 && C[3] >= 0 && C[4] >= 0 && i == C[1] - C[2] - C[3] &= & iP == C[1] - C[2] + C[4] && N == C[1] - C[2] + C[4] && jP == j - C[3] - C[4] ? === Subject: Re: Strange Output!!!Please help me thank you. On 17 avr, 10:26, Jens-Peer Kuska may be you should stop to use N as a variable because > N[] is the function to convert a analytic number into > a floating point number. Jens Hi Mathematica community, > I have to solve this system: > Reduce[{Element[{i, j}, Integers], i <= iP, j >= jP, > 1*j + 1*i == 1*jP + 1*iP, > Reduce[{Element[{N, iP}, Integers], Not[(iP < N)], > Exists[{iPP}, (iPP < N) && iP == iPP + 1]}]}, {iP, jP}, > Backsubstitution -> True] the output should be:( i | j | N | iP) are Integers && i <= N && iP = == > N && > jP == i + j - N > but mathematica gave me this output: > (C[1] | C[2] | C[3] | C[4]) are Integers && C[1] >= 0 && > C[2] >= 0 && C[3] >= 0 && C[4] >= 0 && i == C[1] - C[2] - = C[3] && > iP == C[1] - C[2] + C[4] && N == C[1] - C[2] + C[4] && > jP == j - C[3] - C[4] which is not understandable at all! and I dont want the output to be > like that. I have observed that when I remove i from Element[{i, j}, Integers] > mathematica give me the output I want and which is :iP == N && j= P == > i + j - N So how can I have this same output without removing i from Element[{i, > j}, Integers]? > =E9dents - - Afficher le texte des messages pr=E9c=E9dents - Hi Jens, I have replaced N by n but it does not solve the problem. === Subject: Installation Problem with Mathematica 4.2 under Windows XP because TechSupport of WRI (who would be primary addressee) does not respond to my inquiry I redirect my question to MathGroup hoping that someone may have come across the same problem and knows a work-around. On my laptop where I have (only) recently upgraded the operating system from Windowxs 2000 to XP Professional 2002 SP3 I want to reinstall Mathematica V 4.2.1 (besides other versions 3.0., 5.2, 6.0 and 7.0) in order to compare the sometimes different behavior of various versions of Mathematica with respect to specific procedures / packages e.g. Limit etc. Under Windows 2000 there was no problem installing previous versions of Mathematica (e.g. 3.0, 4.2, 5.2, 6.0 and 7.0) whereas with Windows XP there occurs an installation problem with Mathematica V 4.2.1 ONLY (not with the much older version 3.0 from 1998 !). The corresponding MathInstaller (08/2002) for version 4.2.1 starts a wizard but after about 18% the following message appears : MathInstaller is unable to run a program needed to proceed with the installation. Restart your system and try again ErroR 105. When I press the OK button then in an Application Error window the following message is displayed : ISSET_SE caused a general protection fault in module ... Does anyone know what to do in order to enforce the installation of Mathematica 4.2.1 under Windows XP Professional. (As emphasized above, no problem under OS Windows 2000 ) Robert Kragler === Subject: Re: Installation Problem with Mathematica 4.2 under Windows XP Dr. Kragler, I am not sure if this is relevant, but I seem to hazily recall a somewhat similar message when I installed some version without sufficient administrator privileges and/or from a non-admin account in XP. Perhaps worth a check... Yves because TechSupport of WRI (who would be primary addressee) does not > respond to my inquiry I redirect my question to MathGroup hoping that > someone may have come across the same problem and knows a work-around. On my laptop where I have (only) recently upgraded the operating system > from Windowxs 2000 to XP Professional 2002 SP3 I want to reinstall > Mathematica V 4.2.1 (besides other versions 3.0., 5.2, 6.0 and 7.0) in > order to compare the sometimes different behavior of various versions of > Mathematica with respect to specific procedures / packages e.g. Limit etc. Under Windows 2000 there was no problem installing previous versions of > Mathematica (e.g. 3.0, 4.2, 5.2, 6.0 and 7.0) > whereas with Windows XP there occurs an installation problem with > Mathematica V 4.2.1 ONLY (not with the much older version 3.0 from 1998 > !). The corresponding MathInstaller (08/2002) for version 4.2.1 starts > a wizard but after about 18% the following message appears : MathInstaller is unable to run a program needed to proceed with the > installation. Restart your system and try again ErroR 105. > When I press the OK button then in an Application Error window the > following message is displayed : > ISSET_SE caused a general protection fault in module ... Does anyone know what to do in order to enforce the installation of > Mathematica 4.2.1 under Windows XP Professional. (As emphasized above, > no problem under OS Windows 2000 ) Robert Kragler > === Subject: Re: Installation Problem with Mathematica 4.2 under Windows XP because TechSupport of WRI (who would be primary addressee) does not > respond to my inquiry I redirect my question to MathGroup hoping that > someone may have come across the same problem and knows a work-around. On my laptop where I have (only) recently upgraded the operating system > from Windowxs 2000 to XP Professional 2002 SP3 I want to reinstall > Mathematica V 4.2.1 (besides other versions 3.0., 5.2, 6.0 and 7.0) in > order to compare the sometimes different behavior of various versions of > Mathematica with respect to specific procedures / packages e.g. Limit etc. Under Windows 2000 there was no problem installing previous versions of > Mathematica (e.g. 3.0, 4.2, 5.2, 6.0 and 7.0) > whereas with Windows XP there occurs an installation problem with > Mathematica V 4.2.1 ONLY (not with the much older version 3.0 from 1998 > !). The corresponding MathInstaller (08/2002) for version 4.2.1 starts > a wizard but after about 18% the following message appears : MathInstaller is unable to run a program needed to proceed with the > installation. Restart your system and try again ErroR 105. > When I press the OK button then in an Application Error window the > following message is displayed : > ISSET_SE caused a general protection fault in module ... Does anyone know what to do in order to enforce the installation of > Mathematica 4.2.1 under Windows XP Professional. (As emphasized above, > no problem under OS Windows 2000 ) > Try to change the compatibility mode of the installation program to win2k: Right click the installation.exe, choose compatibility and change compatibilty mode to Windows 2000. After installation you have to adjust compatibility mode for the math.exe and mathematica.exe. -- Roland Franzius === Subject: integrate problem I'm having some issues understanding this... Following works as expected. s is the variable in time. a is a parameter. Integrate[1/(s + a), s] gives Log[a + s] But the following gives the integral itself. Integrate[1/(s[t] + a), t] If the function that needs to be integrated w.r.t time is 1/(s[t] + a), how do I accomplish that? It seems like if integrate it wrt to s [t] it will work. Integrate[1/(s[t] + a), s[t]] But does that sound about right? Any thoughts appreciated. Sean === Factor[(e0*s[t]*k1*k2)/(s[t]*k1 + k1*Km)] (e0*k2*s[t])/(Km + s[t]) or Cancel[(e0*s[t]*k1*k2)/(s[t]*k1 + k1*Km)] (e0*k2*s[t])/(Km + s[t]) Difficult ? Give an example of easy. And by the way, where did you get the idea that Assuming does anything at all with Collect? Andrzej Kozlowski > Hello group. I'm trying to do a little algebra which i can do in my head using > Mathematica. Why? Well, it's neater. Consider the following. > p'[t] == (e0 s[t] k1 k2 )/ (s[t] k1 + k1 Km) difficult to accomplish in mathematica? Following does nothing. p'[t] == (e0 s[t] k1 k2 )/ (s[t] k1 + k1 Km) // > Assuming[k1 > 0, {Collect[#, k1]}] & Sean === Hello group. I'm trying to do a little algebra which i can do in my head using Mathematica. Why? Well, it's neater. Consider the following. p'[t] == (e0 s[t] k1 k2 )/ (s[t] k1 + k1 Km) difficult to accomplish in mathematica? Following does nothing. p'[t] == (e0 s[t] k1 k2 )/ (s[t] k1 + k1 Km) // Assuming[k1 > 0, {Collect[#, k1]}] & Sean === eqn = p'[t] == (e0 s[t] k1 k2)/(s[t] k1 + k1 Km); and eqn /. a_ == b_ :> a == Cancel[b] or Cancel[eqn] or Simplify[eqn] or FullSimplify[eqn] or eqn /. a_*k1 + b_*k1 :> (a + b)*k1 will do it and it seems difficult to hinder Mathematica Jens > Hello group. I'm trying to do a little algebra which i can do in my head using > Mathematica. Why? Well, it's neater. Consider the following. > p'[t] == (e0 s[t] k1 k2 )/ (s[t] k1 + k1 Km) difficult to accomplish in mathematica? Following does nothing. p'[t] == (e0 s[t] k1 k2 )/ (s[t] k1 + k1 Km) // > Assuming[k1 > 0, {Collect[#, k1]}] & Sean === Subject: NumberForm spaces and commas in v7.0.1 hello, in Mathematica v4 and 5.2 to print long numbers separated by commas in blocks of 3, i used to use something like this for example: NumberForm[N[Pi, 10], DigitBlock -> 3] which gave: 3.141,592,654 i.e. commas to the right of the decimal point. but in Mathematica v7.0.1 the same statement generates number blocks separated by spaces, i.e: 3.141 592 654 i can recover the commas by using something like: NumberForm[N[Pi, 10], DigitBlock -> 3, NumberSeparator -> ,] but does anyone know if there is a quick fix to get the old style commas back without having to change all my old programs in this way? thankyou, f.c. === Subject: Re: Tolerance in LinearProgramming Hi Slava, I do not know how mathematica does the calculation. But because a>=0 is equivalent to !a<0, mathematica may use the second possibility, what would explain the behaviour of tolerance. Anyway, it is always better to calculate with exact numbers (Integers or Rationals), then you do not have these problems. Daniel > Hi! I would like to understand better the meaning of the Tolerance parameter > in LinearProgramming. For example, I would like to understand why M = {{1000., > 300., -300.0}, {10., -2000., -1.}, {100000., -1000., -90.}}; > LinearProgramming[{0, 0, 0}, M, {0, 0, 0}, {1, 1, 1}, > Tolerance -> 0.1] does not find a solution, while with smaller Tolerance it does: LinearProgramming[{0, 0, 0}, M, {0, 0, 0}, {1, 1, 1}, > Tolerance -> 0.01] Naively, I find this behavior counterintuitive. > === Subject: Re: running mathematica notebooks without interface you could try the time honored method of writing to a file and polling: Let the kernel-only code write a file with the data to plot (e.g. function or num. data). Then in another mathematica process with front end, poll for the file, read it, delete it, plot it and poll for the next occurence. Daniel > This is a very good idea and it works. > However I would like to use graphics command such as contourPlot and > others, and this seems not to be possible using a .m package run > without a frontend? > maybe the UsingFrontEnd command may help? But it's quite undocumented! > It seems there is no way to run a .nb file without a front-end and > save the output of the cells (including graphics) without having the > actual frontend running... Someone suggested me to use the Kernel remotely, which could be an idea! > However I have some troubles addressing the remote kernel since it is > located in a private network and I usually reach it by a double ssh > session (ssh user1@gateway and then ssh user2@server) > Any quick trick to tell mathematica to load a remote kernel using ssh > tunnel? Davide On Apr 18, 9:37 am, Jens-Peer Kuska take your notebook, mark all cells as initialization >> and save it. The Frontend will as you to create a >> package with you code. Say yes and you will have a >> *.m file tha you can run with out the FrontEnd >> from the kernel. >> Jens > Hi mathematica people! > I have a notebook with some heavy numerics which is supposed to > produce several plots and output files. > I have been recently granted access to a server with two quad-cores > where mathematica 7.0 is installed, however I can access it only > through some tedious ssh sessions (which can't be really called > tunneling) and of course I will have troubles automatizing the ssh- > tunnel. > Since I would like to run a parallelized version of my code on this > new machine.. the question is: > how can I run the notebook in the remote computer (using shell > commands such as math < notebook.nb I don't know) as if I was running > them on the local machine with the graphic interface? in such a way > that it loads the notebook, it evaluate cells and it saves it so > that I can download it and open it on another machine to watch the > plots and everything? > thank you very much in advance, > Davide === Subject: Re: Scaling a part of a composite image Hi Alexei, to specify your arrow, you may use a mix of coordinates and scaled coordinates like e.g.: Polygon[{pt1, Scaled[10^-2 {0, -2, -2}, pt2], Scaled[10^-2 {0, 3, 2}, pt2]}] Daniel In an image composed of at least two (or more) parts combined using > Show, I would like to programmatically scale one of these two images > with respect to the size of the whole composite image. > Do you know, how to do this in Mathematica 6? Is it possible in Mathematica 6 to determine programmatically the total size of the Image? To be more concrete: the function below draws a 3D trajectory - a > solution of a system of three ODE. In addition it draws a triangle > attached to the trajectory. The latter plays the role of an arrow head > showing the direction of the trajectory. Parameters in the argument > are: point is a list of initial values {x0,y0,z0} of the trajectory, > tmax is the calculation time, col is the color of both the trajectory > and the arrow head, arrpos is the time fixing the position of the arrow > on the trajectory, and arrsize scales the arrow size. The subfunction > arr defines the arrow using 2 closely-lying points taken on the trajectory. directedTrajectory3D[point_List, tmax_, col_, arrpos_, arrsize_] := > Module[{p0, eq4, eq5, eq6, pt1, pt2, s}, > arr[pt1_List, pt2_List] := Module[{r}, > r = (pt1 - pt2)2 /. List -> Plus // Sqrt; > Graphics3D[ {col, > Polygon[{pt1, {pt2[[1]], pt2[[2]] - 0.2*r, > pt2[[3]] - 0.2*r}, {pt2[[1]], pt2[[2]] + 0.3*r, > pt2[[3]] + 0.2*r} }]}]]; > > eq4 = x[0] == point[[1]]; > eq5 = y[0] == point[[2]]; > eq6 = z[0] == point[[3]]; > s = NDSolve[{eq1, eq2, eq3, eq4, eq5, eq6}, {x, y, z}, {t, 0, > tmax}]; > p0 = ParametricPlot3D[ > Evaluate[{x[t], y[t], z[t]} /. s], {t, 0, 30}, PlotRange -> All, > PlotStyle -> col, AxesLabel -> {x, y, z}]; > > Show[{p0, > arr[Evaluate[{x[arrpos], y[arrpos], z[arrpos]} /. s] // Flatten, > Evaluate[{x[arrpos - 0.5*arrsize], y[arrpos - 0.5*arrsize], > z[arrpos - 0.5*arrsize]}] /. s // Flatten]}] > ]; One can try with the example of Lorentz system from help: Clear[eq1, eq2, eq3]; > eq1 = > !(*SuperscriptBox[x, [Prime], > MultilineFunction->None])[t] == -3 (x[t] - y[t]); > eq2 = > !(*SuperscriptBox[y, [Prime], > MultilineFunction->None])[t] == -x[t] z[t] + 26.5 x[t] - y[t]; > eq3 = > !(*SuperscriptBox[z, [Prime], > MultilineFunction->None])[t] == x[t] y[t] - z[t]; directedTrajectory3D[{1, 0, 1}, 30, Red, 5, 0.1] > A strong drawback is that in this function one needs to rescale the > arrow sizes by hand each time. Compare two images with the same > trajectory in which the arrow is placed the first time at t=5 and then > at t=15 with the same arrsize=0.1. directedTrajectory3D[{1, 0, 1}, 30, Red, 5, 0.1] > directedTrajectory3D[{1, 0, 1}, 30, Red, 15, 0.1] I would like to find a programmatic way of scaling the arrows so that > they would be always visible and the same size. === Subject: Re: Abort/Interrupt doesn't work? > Alt+. and Alt+, don't seem to work (anymore?) in Mathematica 7 on my XP > machine. Interrupt, both from keyboard and Evaluation menu, is ignored. > Abort pops up the evaluation dialog, but aborting there throws an unhandled > win32 exception. Sounds familiar to anyone? > I already re-installed, to no avail. Does nothing abort for you - e.g. a simple infinite loop While[True,x] or is it only on some specific code that you are executing? In the latter case, the problem probably does not lie with the interrupt mechanism at all. Are you using J/Link or Mathlink perhaps. If the simple loop fails to abort on a freshly loaded Mathematica, the only thing I can think of is a machine fault, so : 1) Does it work on another machine? 2) Have you got some flakey memory, or a bit of hard disk corruption (run the diagnostics)? 3) Are you running 7.0.1? 4) Is it possible (bit of a long shot) that your CD has got damaged in some way? David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Abort/Interrupt doesn't work? No, doesn't sound familiar. Although Abort doesn't always work quickly, it generally works well. Are you using the correct Alt key? On my PC only the left Alt key works in combination with the period. > Alt+. and Alt+, don't seem to work (anymore?) in Mathematica 7 on my XP > machine. Interrupt, both from keyboard and Evaluation menu, is ignored. > Abort pops up the evaluation dialog, but aborting there throws an unhand= led > win32 exception. Sounds familiar to anyone? > I already re-installed, to no avail. === Subject: Re: Abort/Interrupt doesn't work? Work OK for me in Mathematica 7.0.1 under Windows XP Professional SP3. > Alt+. and Alt+, don't seem to work (anymore?) in Mathematica 7 on my XP > machine. Interrupt, both from keyboard and Evaluation menu, is ignored. > Abort pops up the evaluation dialog, but aborting there throws an unhandled > win32 exception. Sounds familiar to anyone? > I already re-installed, to no avail. -- 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: Image Analysis: identifying objects with Mathematica 7.0 Hi All! I would appreciate any input on the following problem: After scanning my samples with TEM, I get images (JPEG or TIFF) which other molecule. Approximately half of the popoulation is that of dimmers, while the other half contains trimmers, monomers, etc. I would like to run some statistics on the samples. I read Theodore Gray's post in the Wolfram Blog about the new capabilities of image processing in Mathematica 7.0.1 and I would like to ask if it is possible to do the following in Mathematica: Pick out a square that contains the dimmers, define that square as a new image, and then let Mathematica search for such an image within the original image. I know that Mathematica has a new function MorphologicalComponents that is apparently the key to getting this done, but I don't really understand how to use it. It is also supposed to return the coordinates of the located images, but I don't know how to extract this output from the function. Gideon === Subject: Re: Help with ScriptSource in GUIKit but I still have problems. Your first suggestion: GUIRun[Widget[Button, { Text -> Update, BindEvent[Action, Script[update[]]], Script[{}, ScriptSource -> targetNB.m] }]] Fails with error message: GUIRun::err : The following GUIKit runtime error occurred : Unable to load Script source :targetNB.m. Both targetNB.m and the notebook that calls it are in the folder specified by Directory[] - is that OK, or do I have to put targetNB.m in a special location? I am not sure what targetNB.m should contain - at the moment it has a single line of code: update[] := Print[Clicked]; Is that correct? In the real life version, I want to execute an entire notebook (1500 individual cells, all grouped into a single cell for execution). Can I simply wrap update[] (or some other function definition)around the whole notebook? Your second example works, but gives the error/warning: SetDelayed::write: Tag Null in Null[] is Protected. In this example, does update[] have to be defined in the same notebook as the GUI? If so, this kinda defeats the object, doesn't it? Paul. -----Original Message----- === Subject: Re: Help with ScriptSource in GUIKit On Apr 11, 12:52 am, Paul Ellsmore Update, BindEvent[action, > Script[{Print[Clicked]}]]}], IncludedScriptContexts -> {$Context}]; I want the button to execute a large block of code, and the GUIKit > documentation suggests I use the ScriptSource function: In[1827]:= Needs[GUIKit`]; ref = GUIRun[Widget[Button, {text -> Update, BindEvent[action, > Script[{}, ScriptSource -> targetNB.m]]}], IncludedScriptContexts -> {$Context}]; In this test case, targetNB.m just has the code Print[Clicked] in it. > Nothing happens when I click the button, no error message, no clicked g= ets > printed. I have put the GUI notebook and the targetNB.m file in the same > folder, and set Directory to that folder. The documentation for ScriptSou= rce > is appalling (no surprise there), but I assume that the contents of > targetNB.m will effectively be pasted into the Script function. Is this t= oo > naive? Note that if I specify a non-existent m file for ScriptSource, I get no > error message. Am I doing something clearly dumb? Is there a better way t= o > make some GUI action run a separate notebook or m file? BTW, I realise that GUIKit is (pretty much) obsolete, and I will be (am, = in > parallel) developing a V7 GUI from built-in code, but we have a lot of > legacy V5 notebooks, and GUIKit is actually a pretty easy way to interfac= e > with them (apart from little issues like this one!). > Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 > Usually, the Script[{}, ScriptSource -> targetNB.m] is called once inside a GUI construct to load a large set of external definitions; it works kinda like Get[] but automatically loads into the script context which isn't known until after the GUI is run/loaded. Using this concept, the BindEvent action should just call to a function defined in this external file. GUIRun[Widget[Button, { Text -> Update, BindEvent[Action, Script[update[]]], Script[{}, ScriptSource -> targetNB.m] }]] Although, after writing numerous large GUIKit apps, I prefer the following: update[] := Print[Clicked]; GUIRun[Widget[Button, {Text -> Update, BindEvent[Action, Script [update[]]]}], IncludedScriptContexts->{Global`}] This way, as your program is running, you can make changes to your functions and the modifications are available immediately because they are not buried in some private context. Additionally, you could define your own package, or context, if you don't want full access to the Global` space. === Subject: Mathematica 7.0.1 system load when idleing having installed Mathematica 7.0.1 (Student edition) for Windows (Win XP SP3), I have noticed that as soon as the MathKernel.exe is loaded, my CPU usage goes up to 30% every 3 seconds. This behavior is visible when I leave my system idle, and I have observed it so far also on another Windows system. It didn't occur in the 7.0.0 version. Using the ProcessExplorer and ProcessMonitor tools, I found out that actually the system load is not directly caused by the MathKernel, but by a process called svchost.exe (of which there are typically many running in the background). The MathKernel (and svchost) constantly generate calls to the Windows Registry querying for example HKLM SystemCurrentControlSetServicesTcpipParametersInterfaces and some other possibly network related things. I find this behavior very annoying especially when you are working with a laptop... Does anybody else has experienced this? === Subject: Should I be using Mathematica at all? Hello again, I have had several questions answered by this group, for which I am very grateful. Now I have a more general topic, which I know will not have single, clear answers. I just would like to hear your opinions. I have some (fairly complicated) legacy Mathematica v5 software which we currently use in-house. Our intention is to turn this software into a saleable product. At the moment, I am contemplating upgrading to V7, writing a GUI for our code (which has no compatibility issues with V7) and distributing it using PlayerPro. To protect our IP, I will be using Encode to make it impossible for it to be reverse engineered. Does anyone know how secure this will actually be? Is it more or less secure than a compiled C++ program would be, for instance? Are there any particular issues I should be aware of? It turns out that there are some serious problems for us using PlayerPro (apart from the price!) which are making us reconsider using Mathematica at all. Top of the list is the inability of Wolfram to offer a trial license for PlayerPro. What this would mean is that we would be losing 100 or so every time someone ordered a trial version but did not subsequently buy the package, because there is no way for us to get our PlayerPro license back. This is not viable. The best Wolfram can offer is to give our prospective client a trial version of the full Mathematica package (say for 15 days). As a workaround, this is very clunky, when I requested my trial of V7 it took 4 days to get the license. I think that, these days, people expect to go to a website, download a trial version and start working with it immediately. So, I am considering our options, in particular open source code, such as C++, and I'd be interested in your opinions about this. Our V5 code doesn't involve any exotic maths, but it makes extensive use of SetDelayed, and these definitions are frequently nested within long and complicated Do loops. Speed is crucial to our application, so is there any, in principle, reason why Mathematica might be able to do things significantly faster than a compiled C++ program (assuming the C++ code is written by someone who knows what they are doing)? Is there a better language than C++, bearing in mind the need to compile (or encode in some way) and distribute the resulting code? I know there used to be a compiler for Mathematica once upon a time, is there any easy way to get from mathematica code to a compilable program. I should stress that we are very happy with Mathematica in terms of developing our application, it's just generating anything that we could sell that is problematical. I have some experience of writing VB, Visual C and similar applications, but these never had a large graphical content. Our code will require a lot of plotting of data (2D only, but lots of curves which need to be interactive in some sense). Mathematica can do everything we want in this respect, but I am less sure about the open source code. I am sure there are add-on packages, but never having used them I don't know whether they can match Mathematica's built in abilities, any comments? If anyone out there has experience of preparing Mathematica code for sale using PlayerPro, are there any pitfalls I should know about? Finally, would anyone care to recommend a consultant(s) who could translate our Mathematica code into C++? I know this is a bit of a vague set of questions, but I'll be happy with vague answers too! Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 === Subject: Re: Mathematica behavior using highlighting and keyboard Apple still does, except that the printed book is now an even longer PDF. One thing I miss going from Cocoa (Mac OS X) development to Mathematica is the degree of flexibility I have in Cocoa. The Interface builder provides guides to ensure proper placement, etc., which are missed in Mathematica. I know that Mathematica has to be cross-platform, and there are different UI paradigms in Linux and Windows, but from my perspective, Wolfram should have adopted something like the Apple Guidelines as a best in class solution. george > Just for historical interest, I'm looking right now at an attractive > 144-page softbound copy of Apple Computer's thoughtful 1987 manual on > Human Interface Guidelines: The Apple Desktop Interface (published > and > sold through Addison-Wesley) that I just took down from my bookshelf. > It includes about a dozen pages (and 30 index entries) on the topic of > Selection, that include much of what you discuss above. Nice to > know > that software companies once thought carefully about these issues -- > not > to mention publishing them and living by them. === Subject: Re: Scaling JPEGs or TIFFs inside PDF slides (using Illustrator)? AES, Nobody is in a position to 'insist' that a person should stay entirely within Mathematica! And, in fact, today the dominant mode for communication of technical material is to go outside of it. Mathematica notebooks are not even an acceptable mode of publication. Nevertheless, in the aspects of learning, research, development and communication Mathematica has and is becoming better and better. The active and dynamic features of Mathematica are ORDERS OF MAGNITUDE better than static documents, or even documents that link to animations or deployed demonstrations. Consider using Workbench to write an application that contains not only one or more packages but also folders of notebooks or slideshows that are relatively finished and that present various common topics or developed results of your subject matter. The folders could also contain other kinds of files - maybe a PDF paper you have written on the subject matter. You might even have an organized directory of folders. The packages would contain the accumulated routines and documentation that were a major result of your efforts. There is no reason to let this active knowledge slip through your fingers - or have it scattered in many unorganized notebooks. If you were giving a lecture and someone asked a question outside a fixed presentation, using the active knowledge in the application, you could often quickly redo the presentation or even do new ones on the fly. Instead of writing on a whiteboard you might write in a new Mathematica notebook and obtain neat results without all the typos and sloppiness that can creep into static hand written material. It is much easier to bring outside static material into a Mathematica application than to bring Mathematica into a basically static medium. But, for the most part, this is for the future because not everybody can read Mathematica applications as they can read PDF files. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ My question for the PDF profis here is: When I do this rescaling of a raster image within a PDF document, using Illustrator, is Illustrator actually building a complete new (rescaled) raster image inside the PDF document, and keeping it in the PDF along with the originally placed version? Or does it just keep the rescaled version and discard the original one? Or does it just insert a brief command for the image to be rescaled on the fly any time the PDF is projected or printed? ------------- [And as an addendum, I'm copying this post to cssmm frankly to tweak some of the people who argue that all presentations in the future should and must be done directly from Mathematica notebooks and nothing else (and, secondarily, that _all_ of the capabilities I've mentioned above should and must be built into and carried out from one single, massive, eventually un-learnable and un-documentable Mathematica application. I have no objection at all to making presentations direct from a live Mathematica notebook in situations for example where this might be a not too lengthy, single-topic or one-shot discussion, maybe in a class or group meeting or informal situation, of material that can be covered from a single Mathematica notebook. That makes total sense. But suppose you have a collection of literally many hundreds if not thousands of slides and graphics, some generated by Mathematica, others collected from all over the place, over many years; and you're continually re-organizing and re-purposing and revising these (or copies of them), for presentations at different levels, to different audiences, or in different formats, on screen, in reports, in papers, in books. Suppose, as would be the case if you insisted on the Mathematica notebook only approach, that these materials may have come from many dozens of different Mathematica notebooks, assembled over a dozen plus years, in a half-dozen successive versions of Mathematica (so that some of these notebooks will not even execute any more; and those that still do are likely produce different results than they originally did). So, to do this repurposing, or assembling a new presentation from a lot of varied existing sources, you're going to try to pull out and reassemble bits and pieces from these dozens of notebooks, into a new notebook for your upcoming presentation? And debug that? And then, every time you want to make even some small but significant change in one or a few slides in a many megabyte notebook, you have to re-edit and re-run it? Insane!! In the approach I'm suggesting, and using, any time I want to add a live or interactive demo as one part of a presentation -- and I've been programming interactive onscreen demos for teaching, for research, for professional presentations, and for my own education, using multiple computer tools, since the late 1980s[1] -- it's trivially easy to just add a link to that Mathematica demo or animation (or Flash or QuickTime or whatever material) from within the PDF (or PowerPoint, or Keynote, or whatever) presentation or online document. Mathematica has long been a truly great (even insanely great) tool, overall approach, documentation, and interface, strikes me as just plain insane. ----------------- topic of this post (and which I think is still pretty good nearly two decades later), you can take a look at the link below. Those of you too junior to recall Apple's Knowledge Navigator buzz-phrase, or MIT's Athena Experiment, or the concept of the 3M-3K computer, may find it interesting. [also at ] === Subject: Re: Controlling axes lengths in Plots The Presentations package should be able to do that. It has the primitives XTickScale and YTickScale for drawing free standing scales. It also makes it easy to combine various elements in one drawing statement. So think of a piece of paper. 1) Make your plots without a frame or ticks, FrameLabel or PlotLabel. 2) Inset each plot in a fixed 'frame' on the piece of paper. 3) For each plot you can then draw tick scales just outside the frame region. The TickScale routines allow you specify that a given length on the piece of paper corresponds to a given scale. 4) You can add any other things on the piece of paper such as Text labels. This might require a certain amount of work if each plot has different scales and labels around it. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Has anybody found a good technique to assume absolute control over the lengths of the axes in a 2D plot? I often have to build several graphs to be overlaid using transitions in presentation software and want to keep the plot area consistent for smooth transitions. ImageSize only gives control over dimensions of the resulting graphic. If there are frame labels or legends that change in size from one graph to the next than the whole graphic is constrained by ImageSize, shrinking my plot area. I have several workarounds, all of which break eventually. What I would really like is a FrameSize->{} option that overrides ImageSize and lets me set the dimensions of the plot area directly. Daniel === Subject: How to evaluate a notebook programmatically? In one notebook, gui.nb, I have the code for a user interface. In another, functional.nb I have around 3000 lines of code, in several hundred cells. I want to click a button (or something similar) in gui.nb, and tell Mathematica to execute all the cells in functional.nb. Functional.nb will use values for global variables that have been assigned in gui.nb, and gui.nb will display the results of the execution of functional.nb. Seems straightforward. Now in functional.nb, we group all the cells together, so that we can manually execute them all with a single shift-click. What is the programmatical equivalent of this? I have looked through all the tutorials etc on controlling notebooks from the front end, frontendtokens etc., but nothing seems to do quite what I want. The options seem to be: Option 1. Merge all the cells in functional.nb, and assign that cell to a Function, which can then be called from gui.nb. This is highly undesirable, because if an error occurs, we find out about it at the end of 3000 lines of code, with no idea where the error occurred. The cell structure in Mathematica is just too valuable to throw away. I guess that using workbench might mitigate some of these issues, but that means my colleagues and I all having to learn a new (and complicated) tool. Option 2. Assign each of the (hundreds of!) cells to a separate function, and call each of them in turn from gui.nb. A lot of hard work here with the potential for errors in naming and ordering the functions in the two notebooks, and probably an increase in execution time. Option 3. Make all the cells in functional.nb initialization cells, then get gui.nb to open functional.nb each time we want to evaluate it, and then close it again. Very clunky, and again probably slow. I am sure there are better options than these? Any ideas? Paul. Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 ------=_NextPart_000_0010_01C9BB7F.DD815090

 

In one notebook, “gui.nb”, I have the = code for a user interface. In another, “functional.nb” I have around = 3000 lines of code, in several hundred cells. I want to click a button (or = something similar) in gui.nb, and tell Mathematica to execute all the cells in functional.nb. Functional.nb will use values for global variables that = have been assigned in gui.nb, and gui.nb will display the results of the = execution of functional.nb. Seems straightforward.

 

Now in functional.nb, we group all the cells = together, so that we can manually execute them all with a single shift-click. What is = the programmatical equivalent of this? I have looked through all the = tutorials etc on controlling notebooks from the front end, frontendtokens etc., but = nothing seems to do quite what I want. The options seem to = be:

 

Option 1. Merge all the cells in functional.nb, and = assign that cell to a Function, which can then be called from gui.nb. This is = highly undesirable, because if an error occurs, we find out about it at the end = of 3000 lines of code, with no idea where the error occurred. The cell structure = in Mathematica is just too valuable to throw away. I guess that using = workbench might mitigate some of these issues, but that means my colleagues and I = all having to learn a new (and complicated) tool.

 

Option 2. Assign each of the (hundreds of!) cells to = a separate function, and call each of them in turn from gui.nb. A lot of = hard work here with the potential for errors in naming and ordering the = functions in the two notebooks, and probably an increase in execution = time.

 

Option 3. Make all the cells in functional.nb = initialization cells, then get gui.nb to open functional.nb each time we want to = evaluate it, and then close it again. Very clunky, and again probably = slow.

 

I am sure there are better options than these? Any = ideas?

 

 

Paul.

 

 

 

Dr. Paul A. Ellsmore

 

Nanion Limited

Oxford Centre for Innovation

Mill = Street

Oxford

United Kingdom

OX2 0JX

 

Tel: +44 (0) 1865 811175

Fax: +44 (0) 1865 248594

 

------=_NextPart_000_0010_01C9BB7F.DD815090-- === Subject: About Reduce and domains Hi Mathematica community, I remarqued in many outputs with reduce, that mathematica treats some parameters as complexe numbers and consequently distinguich between Re part and Im part: For example: (Re[d]<0&&Re[a]<0&& ...) || (Re[d]<0&&Re[a]==0&&Im[a]<0&& ...) || (Re [d]<0&&Re[a]==0&&Im[a]>0&&...) || (Re[d]<0&&Re[a]>0&&...) || (Re[d] ==0&&Im[d]<0&&Re[a]<0&&...) ||... In the help I have read that Reduce[expr,vars] assumes by default that quantities appearing algebraically in inequalities are real, while all other quantities are complex. But is there a mean to force mathematica in the way that it does not distinguich between real part and imaginary part in the output and consequently to have: d<0 && a<0 ...|| d==0 && a>0 || ...without specifying a domain which means without Reduce[expr,vars,doms]? === Subject: Re: Adding text to RegionPlot >I would like to add text at specific (x,y) locations for a 2D >graphic generated by RegionPlot (meaning, I'd rather not use the >graphic tool and add text by hand). Is there a way to do this? I >get mathematica complaints that RegionPlot is not a type of >graphics. >For example, this code fails: >RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange >-> {{0, 3}, {0, 1}},Graphics[Text[mytext, {1.5, 1}]] >Apparently I'm using Graphics[Text[]] incorrectly. How can I get >such a simple function of putting text at a specific location to >work in RegionPlot? This does what you want RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange -> {{0, 3}, {0, 1}}, Epilog -> {Text[mytext, {1.5, 1}]}] However, you have chosen the coordinates for the text to be on the edge of the plot which causes the text to be partially obscured. A better choice might be RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange -> {{0, 3}, {0, 1}}, Epilog -> {Text[mytext, Scaled@{.5, .95}]}] === >I found what appears to be a new tile associated with Barnsley's > triangular affine. >The fourth transform algorithm is my own. >Riddle rotation of Barnsley affine: fractal animation http://www.mathematica-users.org/mathematica/images/d/db/affine_riddle.avi Clear[f, dlst, pt, cr, ptlst, M, p, a, b, c, n] >rotate[theta_] := {{Cos[theta], -Sin[theta]}, {Sin[theta], Cos[theta]}}; >n0 = 4; >dlst = Table[ Random[Integer, {1, n0}], {n, 10000}]; >a = b = c = 0.5; >M = {{{-1 + b, -1/2 + b/2 + a/2}, {0, a}}, {{b + c/2 - 1/2, >b/2 - c/4 + > 1/4}, {1 - c, c/2 - 1/2}}, {{c/2, -1/2 + a/2 - c/4}, {-c, -1 + a + > c/2}}, rotate[-Pi/((7/4 - >a/2 - b/2 - c/2)) + n*Pi/20].{{1/2 - a/2 - > b/2 - c/2, 3/4 - a/4 - b/4 - c/4}, {1 - a/3 - b/3 - c/3, 1/2 - a/6 - b/6 - > c/6}}} >a0 = Table[Det[M[[i]]], {i, 1, 4}] >FullSimplify[Apply[Plus, a0]] >rotate[-Pi/((7/4 - a/2 - b/2 - c/2))] >in = {{1 - b, 0}, {1 - b, 0}, {1/2, 1}, {1 - b, 0}}; >Length[in] >f[j_, {x_, y_}] := M[[j]]. {x, y} + in[[j]] >pt = {0.5, 0.5}; >cr[n_] := Flatten[Table[If[i == j == k == 1, {}, > RGBColor[i, j, k]], {i, 0, 1}, {j, 0, 1}, {k, 0, 1}]][[1 + Mod[n + > 1, 7]]]; >ptlst[n_] := Table[{cr[dlst[[j]]], Point[pt = f[dlst[[j]], Sequence[pt]]]}, > {j, Length[dlst]}]; >Table[Show[Graphics[Join[{PointSize[.001]}, ptlst[n]]], AspectRatio - Automatic, PlotRange -> All], {n, 0, 20}] Users of Mathematica version 7 can achieve a faster display of the result by using a single Point primitive with the VertexColors option instead of a long list of (color, Point) pairs. Here's a modified version using that optimization: Clear[f, dlst, pt, cr, ptlst, M, p, a, b, c, n]; rotate[theta_] := {{Cos[theta], -Sin[theta]}, {Sin[theta], Cos[theta]}}; n0 = 4; dlst = Table[Random[Integer, {1, n0}], {n, 10000}]; a = b = c = 0.5; M = {{{-1 + b, -1/2 + b/2 + a/2}, {0, a}}, {{b + c/2 - 1/2, b/2 - c/4 + 1/4}, {1 - c, c/2 - 1/2}}, {{c/2, -1/2 + a/2 - c/4}, {-c, -1 + a + c/2}}, rotate[-Pi/((7/4 - a/2 - b/2 - c/2)) + n*Pi/20].{{1/2 - a/2 - b/2 - c/2, 3/4 - a/4 - b/4 - c/4}, {1 - a/3 - b/3 - c/3, 1/2 - a/6 - b/6 - c/6}}} a0 = Table[Det[M[[i]]], {i, 1, 4}] FullSimplify[Apply[Plus, a0]] rotate[-Pi/((7/4 - a/2 - b/2 - c/2))] in = {{1 - b, 0}, {1 - b, 0}, {1/2, 1}, {1 - b, 0}}; Length[in] f[j_, {x_, y_}] := M[[j]].{x, y} + in[[j]] pt = {0.5, 0.5}; colors = List @@ # & /@ Flatten[Table[ If[i == j == k == 1, {}, RGBColor[i, j, k]], {i, 0, 1}, {j, 0, 1}, {k, 0, 1}]]; cr[n_] := colors[[1 + Mod[n + 1, 7]]]; ptlst[n_] := Point[Developer`ToPackedArray[ Table[pt = f[dlst[[j]], Sequence[pt]], {j, Length[dlst]}]], VertexColors -> Developer`ToPackedArray[cr /@ dlst]]; ListAnimate[ Table[Graphics[{AbsolutePointSize[1], ptlst[n]}, PlotRange -> {{-.1, 1.25}, {-.7, 1.1}}], {n, 0, 20}]] Chris Hill Wolfram Research === Subject: Dynamic popupmenu AND dynamic variables Ok, I finally got a working parts I needed, however, to work smart, I really hate to hardwire the creation of each group of popupmenus with unique variable names (I have a hundred to go!). Is there any way to create a rule, function etc so I can pass data for the menus and generate unique variable names within. I tried using module but it fails to work. Is this doable? use this code for showing me: mainMenu = {hey, you, now} stuff = {{a, 1, r}, {b, ee, 23}, {eg,rt,yy}}; f[e_] := Switch[e, hey, 1, you, 2, now, 3]; CreatePalette[ { Labeled[ Row[ { PopupMenu[Dynamic[x], mainMenu, Appearance -> Palette], Dynamic[y = stuff[[f[x], 1]]; PopupMenu[Dynamic[y], stuff[[f[x]]], Appearance -> Palette]], ActionMenu[ , { Insert :> NotebookWrite[InputNotebook[], y], Wrap :> NotebookApply[InputNotebook[], RowBox[{y, [, [SelectionPlaceholder], ]}]] }, ImageSize -> {4, 10}, FrameMargins -> 0 ] } ] , lbl, Left] } ] I want to create parameters for mainmenu and stuff; somehow uniquely you. === Subject: Mathematica User groups,where to find them? I am trying to find any local Mathematica user groups in my area (south Fla.) === Subject: Bug fixing reporting and fixing rate of Mathematica I have a strong QA background and so it should come to no surprise I am concerned about how QA is done and perceived by users. Please long standing users of Mathematica, how would you rate and describe your experience hope WRI doesn't consider Bugs trade secrets! === Subject: Re: How to find current ViewAngle, ViewPoint during Rotating graphics? > Is there a way to display the current ViewAngle and/or View point of a 3D > graphics as one is rotating it with the mouse? Here is an example showing how to connect Manipulate controls to the options of Graphics3D. The trick is to use Dynamic and the correct initial values: Manipulate[ Graphics3D[Cuboid[], ViewPoint -> Dynamic[vp], ViewVertical -> Dynamic[vv], ViewAngle -> Dynamic[va], ViewCenter -> Dynamic[vc], SphericalRegion -> Dynamic[sr], Method -> {RotationControl -> Dynamic[rc]}], {{vp, ViewPoint /. Options[Graphics3D], ViewPoint[Rule]}, InputField}, {{vv, {0, 0, 1}, ViewVertical[Rule]}, InputField}, {{va, Automatic, ViewAngle[Rule]}, InputField}, {{vc, {{1/2, 1/2, 1/2}, {1/2, 1/2}}, ViewCenter[Rule]}, InputField}, {{sr, True, SphericalRegion[Rule]}, {True, False}}, {{rc, ArcBall, Method}, {Globe, ArcBall}}] Note that the Globe setting locks ViewVertical->{0, 0, 1} like Plot3D does it. Enjoy! Alexander === Subject: Re: How to find current ViewAngle, ViewPoint during Rotating graphics? > Mathematica 7. Is there a way to display the current ViewAngle and/or View point of a 3D > graphics as one is rotating it with the mouse? Sometimes I am not sure what is the best view angle to use initially, but > after I rotate the 3D graphics and find a good angle I like, there does not > seem to be a way to determine its value from the front end. I was expecting > may be that a mouse right-click on the graphics or something similar would > bring up some information about the current state of the graphics. Any one knows a trick way to find this information? > This has come up when version 6 came out and the ViewPoint Selector was removed. The concept is: Graphics3D[Cylinder[], ViewPoint -> Dynamic[vp]] Dynamic[vp] === Subject: Re: How to find current ViewAngle, ViewPoint during Rotating graphics? > Mathematica 7. Is there a way to display the current ViewAngle and/or View point of a 3D > graphics as one is rotating it with the mouse? Sometimes I am not sure what is the best view angle to use initially, but > after I rotate the 3D graphics and find a good angle I like, there does not > seem to be a way to determine its value from the front end. I was expecting > may be that a mouse right-click on the graphics or something similar would > bring up some information about the current state of the graphics. Any one knows a trick way to find this information? I don't know if this qualifies for tricky: if you recall that everything is an expression, and since version 6 this is true also for displayed graphics, then it is just the most natural thing to do... Put this in front of the displayed Graphics3D and evaluate the resulting expression: AbsoluteOptions@ hth, albert === Subject: Re: How to find current ViewAngle, ViewPoint during Rotating graphics? > Make a Plot, say, Plot3D[(x - 3) (y - 2), {x, 0, 5}, {y, 0, 5}, > ImageSize -> 300] Then in the output, position the cursor to the left of the plot and type > 'AbsoluteOptions['. Next position the cursor to the right of the plot and > type ',ViewPoint]'. Evaluate and you will obtain the current ViewPoint. > You > can rotate the image and reevaluate to get the new ViewPoint. Then copy > the > ViewPoint into the original plot statement. Without the ImageSize option it also works but I get warning messages > after > rotating. > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ this 3D plot ParametricPlot3D[{Sin[u], Cos[u], 0.05*u}, {u, 0, 5*2*Pi}, PlotStyle -> {Tube[thick]}, ViewPoint -> {2.645, 2.057138, 0.468316}, ViewAngle -> Automatic, Axes -> False, Boxed -> False, ImageSize -> 300] And the above ViewPoint value was copied as a result of the method you described, yet the resulting image orientation does not match that which I copied the ViewPoint from. Here is a screen shot. http://12000.org/tmp/041209/viewpoint.PNG Basically, I am trying to make a spring which is oriented sideways instead of up-down. This is on Mathematica 7 ps. You are right above getting a warning when not using ImageSize. --Nasser === Subject: Re: How to find current ViewAngle, ViewPoint during Rotating graphics? Make a Plot, say, Plot3D[(x - 3) (y - 2), {x, 0, 5}, {y, 0, 5}, ImageSize -> 300] Then in the output, position the cursor to the left of the plot and type 'AbsoluteOptions['. Next position the cursor to the right of the plot and type ',ViewPoint]'. Evaluate and you will obtain the current ViewPoint. You can rotate the image and reevaluate to get the new ViewPoint. Then copy the ViewPoint into the original plot statement. Without the ImageSize option it also works but I get warning messages after rotating. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Mathematica 7. Is there a way to display the current ViewAngle and/or View point of a 3D graphics as one is rotating it with the mouse? Sometimes I am not sure what is the best view angle to use initially, but after I rotate the 3D graphics and find a good angle I like, there does not seem to be a way to determine its value from the front end. I was expecting may be that a mouse right-click on the graphics or something similar would bring up some information about the current state of the graphics. Any one knows a trick way to find this information? --Nasser === Subject: Re: Replace Table[Sum...]...] with Functional code I use the following two functions to analyze time series: mm[data_,period_] := Table[Sum[(Log[data[[t]]] - Log[data[[t-i]]])/ > Sqrt[i], {i,1,period}] / period, {t, period+1, Length[data]}] mr[data_,period_] := Table[Sum[Log[data[[t-i]]/data[[-i + t-1]]] * > (Sqrt[i] - Sqrt[i-1]), {i,1,period}],{t, period+2, Length[data]}] They have a similar structure, Table[Sum[...]...], which sums a > bunch of stuff from the time series at each point in the series. I'd like to convert them into functional programing constructs, but > as the increments in the Table function come into play in the Sum, > I haven't been able to figure out a way to do it. I've tried Map with Partition and a bunch of other things, > but I could use some pointers. Any help much appreciated. Here is a fourth version of mm. Why I transposed things in the third > version is beyond me! This one is both faster and more elegant. mm[data_, period_] := Partition[Log@data,period+1,1]. > (Append[-#,Tr@#]&[1/(Sqrt@Range[period,1,-1]*period)]) These eek out a tiny bit more speed: mm3[v_List, n_Integer] := With[{u = Log[v]}, Dot[Drop[u, n] - Partition [Most[u], n, 1], 1/Sqrt@Range[n, 1, -1]] / n]; mr3[v_List, n_Integer] := Dot[Partition[Log[Take[v, {2, -2}]/Drop[v, -2]], n, 1], Sqrt@Range[n, 1, -1] - Sqrt@Range[n - 1, 0, -1]]; === Subject: Re: Replace Table[Sum...]...] with Functional code Here's a simpler version (I think): functionalMR2[data_, period_] := ListConvolve[Rest@# - Most@# &@Sqrt@Range[0, period], Log[Rest@data/Most@data]] Comparing it with yours: functionalMR[data_, period_] := Module[{kernel, ls}, kernel = Table[(Sqrt[i] - Sqrt[i - 1]), {i, period}]; ls = ListCorrelate[{1, 1}, data, {1, -1}, 1, Times, Log[#2/#1] &]; ListConvolve[kernel, ls, {-1, 1}, 0]] data = Array[a, 10]; Table[functionalMR[data, p] == functionalMR2[data, p], {p, 0, 10}] {True, True, True, True, True, True, True, True, True, True, True} I haven't looked at Ray Koopman's code; it may be the same as mine, for all I know. Bobby >> mm[data_, period_] := >> Table[ >> Sum[(Log[data[[t]]] - Log[data[[t - i]]])/Sqrt[i], >> {i, 1, period}]/period, >> {t, period + 1, Length[data]}] >> mm2[data_, period_] := Module[ >> {logData = Log[data], d = Sqrt[Range[period, 1, -1]]}, >> Mean[#/d] & /@ >> (Drop[logData, period] - >> Most[Partition[logData, period, 1]])] >> data = Array[x, {500}]; >> period = Random[Integer, {20, 100}] >> 41 >> Timing[r1 = mm[data, period];] >> {0.459393,Null} >> Timing[r2 = mm2[data, period];] >> {0.228474,Null} >> %/%% >> {0.497339,1} >> r1 == r2 >> True >> Bob Hanlon >> I use the following two functions to analyze time series: >> mm[data_, period_] := Table[Sum[(Log[data[[t]]] - Log[data[[t - i]]]) /= > Sqrt[i], {i, 1, period}] / period, {t, period + 1, Length[data]}] >> mr[data_, period_] := Table[Sum[Log[data[[t - i]] / data[[-i + t - 1]]]= > * (Sqrt[i] - Sqrt[i - 1]), {i, 1, period}],{t, period + 2, > Length[data]}] >> They have a similar structure, Table[Sum[...]...], which sums a bunch >> of = > stuff from the time series at each point in the series. >> I'd like to convert them into functional programing constructs, but as >> th= > e increments in the Table function come into play in the Sum, I haven't > bee= > n able to figure out a way to do it. >> I've tried Map with Partition and a bunch of other things, but I could >> us= > e some pointers. >> Any help much appreciated. By using Table and Sum you are repeating a lot of calculations. Once > period has been set all the possible values of (Sqrt[i] - Sqrt[i - > 1]) and Log[data[[t - i]] / data[[-i + t - 1]]] are set. Therefore: kernel=Table[(Sqrt[i]-Sqrt[i-1]),{i,period}]; ls=ListCorrelate[{1,1},data,{1,-1},1,Times,Log[#2/#1]&]; so now combine them: ListConvolve[kernel,ls,{-1,1},0] functionalMR[data_,period_]:=Module[{kernel,ls}, > kernel=Table[(Sqrt[i]-Sqrt[i-1]),{i,period}]; > ls=ListCorrelate[{1,1},data,{1,-1},1,Times,Log[#2/#1]&]; > ListConvolve[kernel,ls,{-1,1},0] > ] This is a little bit slower than Ray Koopman's code but I just like > using ListCorrelate and ListConvolve as replacements for Table[Sum > [ ...]...] :) Mike > -- DrMajorBob@bigfoot.com === Subject: Best practices of coding using Mathematica? As a new user of Mathematica, where would I find coding style info towards good coding. I don't want to get into bad habits of coding. Any docs === Subject: Re: how to build pattern for a square matrix of reals? > You called l a lower diagonal vector and u an upper diagonal vector -- > neither of which makes any sense. Only matrices, not vectors, can be upper > or lower diagonal. I also noticed that you want 0 (an integer) to be treated as if it were > Real. So here's a rendition of your TridiagonalSolve: tridiagonal[___] := False > tridiagonal[lower : {0 | 0., __Real}, d : {__Real}, > upper : {__Real, 1 | 1.}, b : {__Real}] /; > Equal @@ Length /@ {lower, d, upper, b} := True Notice I'd never, EVER use l as a variable name, as it's > indistinguishable from 1 for many of us. I used the lower and upper > names because you're thinking of them that way, even though vectors can't > physically BE lower or upper. And here's a replacement for the second line of code, where I would NOT > redefine the built-in Solve: realQ[0] = True; > realQ[x_] := MatchQ[x, _Real] > realQ[_] = False; > commensurable[a_ /; MatrixQ[a, realQ], b : {__Real}] /; > Union@Dimensions@a == {Length@b} := True > commensurable[__] = False; Bobby fully get what I wanted. I guess it would be better if I explained initially what is all about: > I have some simple Fortran routines for solving tri-diagonal, and then > regular, system of linear equations, that I'm wrapping, through > Mathlink, for use from Mathematica. I want Mathematica to do arguments > checking for me, and this could be achieved through specifying > corresponding patterns for functions signature in the MathLink > template file. So, my functions are: > TridiagonalSolve[l, d, u, b] - for tridiagonal solver > Solve[A, b] - for regular solver > If the dimension of system is n in both cases, then here: > l - lower diagonal vector, of size n, with first element set to 0 > d - diagonal vector, of size n > u - upper diagonal vector, of size n, with last element set to 0 > b - right-side vector, of size n > A - matrix of the system, of size nxn So, I want to check that dimensions of all vectors match, for > tridiagonal solver function, and also that vector l has 0 as first, > and vector u has 0 as last element. Also, for regular solver > function, I want to check that dimensions of system matrix, and the > length of the right-side vector match. Of course, I also want to > check that A is matrix of reals, and that l, d,u and b are vectors of > reals. So here are final patterns I came up with (these seem to work > fine, but I'd appreciate any further suggestions on improvement): TridiagonalSolve[l_/;(VectorQ[l,MatchQ[#,_Real]&]&&l[[1]] > ==0),d_/;VectorQ[d,MatchQ[#,_Real]&],u_/;(VectorQ[u,MatchQ[#,_Real]&] > &&u[[-1]]==0),b_/;VectorQ[b,MatchQ[#,_Real]&]]/;Length[l]==Length[d] > ==Length[u]==Length[b]:=OK Solve[A_/;(MatrixQ[A,MatchQ[#,_Real]&]&&Equal@@Dimensions > [A]),b_/;VectorQ[b,MatchQ[#,_Real]&]]/;Dimensions[A][[2]]==Length > [b]:=OK > -- > DrMajor...@bigfoot.com As for names used, I have these routines in a package of mine, and I use different names anyway, so I haven't noticed name clashing issue with built-in Solve; I used above names just as an example. As for lower/upper tridiagonal vector: indeed terms are meaningless, and I apologize for this too - it is one of these occasions when non-native English speaker translates terms from his own language verbatim. As for using or not the name l as an argument/variable name - I consider this nitpicking these days. It could have been argued back then in the time of terminals and small resolution fonts, but today with my Mathematica or Emacs font, these characters look different, and more importantly, if you put 1 in the place of l above, Mathematica won't italicize, nor color it, so it's quite distinguishable. Finally - the most important note: Google interface, that I'm using for sending, is breaking lines on its own, so before eventually trying to remove *all* blanks within them. === Subject: Re: Change in NSolve algorithm > What surprised me about Wilkinson's polynomial example, which should > return Range[20], is the following. Mathematica Help says that: NSolve[eqns,vars,n] gives results to n- > digit precision. Consequently, omitting n should imply machine > precision. Nevertheless: sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x] {1 > ., > 2.00000000000096,2.99999999986639,4.0000000049587,4.99999990255529,6.00 > = > 000083841557+1.13297570609149*10^-9 > I,7.00008136819274-0.0000108589979212047 I, > 8.00087475000192+0.000151959812492809 I, > 9.0002388679906+0.000147736991612302 I, > 10.000992367067-0.000579336748622785 I, > 11.0030045370741-0.00438286449628658 I, > 12.0383486261734-0.102068022121597 I, > 13.1275500318654+0.0361732078353353 I, > 13.9803341855889+0.0168546889387958 I, > 14.9015299203113-0.0418410427904214 I, > 15.8215727528799+0.0440619301323384 I, > 16.9944217046715-0.00669060159139528 I, > 18.0000979553809-0.000170510501593321 I, > 18.999972121053+0.00014011316501936 I, > 19.9999979459428+1.38662076005353*10^-6 I} while sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x, > $MachinePrecision] > {1.000000000000000,2.000000000000000,3.000000000000000,4.000000000000000,5 > .= > 000000000000000,6.000000000000000,7.000000000000000,8.000000000000000,9.000 > = > 000000000000,10.00000000000000,11.00000000000000,12.00000000000000,13.00000 > = > 000000000,14.00000000000000,15.00000000000000,16.00000000000000,17.00000000 > = > 000000,18.00000000000000,19.00000000000000,20.00000000000000} Even with 2 digits precision the result is correct! sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x, 2] > {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10 > .,11.,12.,13.,14.,15.,16.,17.,18.,19= > .,20.} So, I would say that your example indicates a misbehavior or a bug in > NSolve. Any comments? Yes. $MachinePrecision is not the same as MachinePrecision. Try the latter and see what happens. Andrzej Kozlowski > Alberto >> Has anyone noticed that the algorithm used by NSolve has >> changed in V7? >> ... >> On the other hand, V7 fares slightly worse with Wilkinson's >> polynomial: >> sols = x/.NSolve[Expand[Product[x-i, {i,1,20}] == 0,x]]; >> Norm[Table[sols[[i]] - i, {i, 1, 20}]] >> ... >> Mark McClure === Subject: Re: Change in NSolve algorithm > What surprised me about Wilkinson's polynomial example, which should > return Range[20], is the following. Mathematica Help says that: NSolve[eqns,vars,n] gives results to n- > digit precision. Consequently, omitting n should imply machine > precision. Nevertheless: sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x] {1.,2.00000000000096,2.99999999986639,4.0000000049587,4.99999990255529,6.00= > 000083841557+1.13297570609149*10^-9 > I,7.00008136819274-0.0000108589979212047 I, > 8.00087475000192+0.000151959812492809 I, > 9.0002388679906+0.000147736991612302 I, > 10.000992367067-0.000579336748622785 I, > 11.0030045370741-0.00438286449628658 I, > 12.0383486261734-0.102068022121597 I, > 13.1275500318654+0.0361732078353353 I, > 13.9803341855889+0.0168546889387958 I, > 14.9015299203113-0.0418410427904214 I, > 15.8215727528799+0.0440619301323384 I, > 16.9944217046715-0.00669060159139528 I, > 18.0000979553809-0.000170510501593321 I, > 18.999972121053+0.00014011316501936 I, > 19.9999979459428+1.38662076005353*10^-6 I} while sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x, > $MachinePrecision] > {1.000000000000000,2.000000000000000,3.000000000000000,4.000000000000000,5.= > 000000000000000,6.000000000000000,7.000000000000000,8.000000000000000,9.000= > 000000000000,10.00000000000000,11.00000000000000,12.00000000000000,13.00000= > 000000000,14.00000000000000,15.00000000000000,16.00000000000000,17.00000000= > 000000,18.00000000000000,19.00000000000000,20.00000000000000} Even with 2 digits precision the result is correct! sols = x /. NSolve[Expand[Product[x - i, {i, 1, 20}] == 0, x], x, 2] > {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.,11.,12.,13.,14.,15.,16.,17.,18.,19= > .,20.} So, I would say that your example indicates a misbehavior or a bug in > NSolve. Any comments? Yes, WorkingPrecision -> $MachinePrecision will use Mathematica's arbitrary precision arithmetic with $MachinePrecision number of digits (around 16 on most machines). WorkingPrecision -> MachinePrecision will actually use the FPU to do the calculations. === Subject: Re: Adding text to RegionPlot > I would like to add text at specific (x,y) locations for a 2D graphic > generated by RegionPlot (meaning, I'd rather not use the graphic tool > and add text by hand). Is there a way to do this? I get mathematica > complaints that RegionPlot is not a type of graphics. For example, this code fails: RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange - {{0, 3}, {0, 1}},Graphics[Text[mytext, {1.5, 1}]] Apparently I'm using Graphics[Text[]] incorrectly. How can I get > such a simple function of putting text at a specific location to work > in RegionPlot? > Combine the two graphics using Show[RegionPlot[...], Graphics[Text[...]]] or, better: use RegionPlot[..., Epilog -> {Text[...]}] === Subject: Re: Adding text to RegionPlot > I would like to add text at specific (x,y) locations for a 2D graphic > generated by RegionPlot (meaning, I'd rather not use the graphic tool > and add text by hand). Is there a way to do this? I get mathematica > complaints that RegionPlot is not a type of graphics. For example, this code fails: RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange - {{0, 3}, {0, 1}},Graphics[Text[mytext, {1.5, 1}]] Apparently I'm using Graphics[Text[]] incorrectly. How can I get > such a simple function of putting text at a specific location to work > in RegionPlot? Jim All built-in 2D plotters have Epilog which provides a 2D graphics overlay. RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange -> {{0, 3}, {0, 1}}, Epilog -> Text[mytext, {1.5, 0.8}]] === Subject: Re: Adding text to RegionPlot > I would like to add text at specific (x,y) locations for a 2D graphic > generated by RegionPlot (meaning, I'd rather not use the graphic tool > and add text by hand). Is there a way to do this? I get mathematica > complaints that RegionPlot is not a type of graphics. For example, this code fails: RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange - {{0, 3}, {0, 1}},Graphics[Text[mytext, {1.5, 1}]] Apparently I'm using Graphics[Text[]] incorrectly. How can I get > such a simple function of putting text at a specific location to work > in RegionPlot? RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange -> {{0, 3}, {0, 1}}, Epilog -> Text[my text, {1.3, 1}]] This will cut off your text, though, since it is centered at {1.3,1}. You need to leave a bit of vertical room for it, something like this. RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange -> {{0, 3}, {0, 1.2}}, Epilog -> Text[my text, {1.3, 1}]] You can also combine graphics with Show, instead of packing a lot into Epilog. plot1 = RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}]; plot2 = Graphics[{Red, FontSize -> 14, FontFamily -> Helvetica, Text[My text, {1.3, 1}]}]; Show[{plot1, plot2}, PlotRange -> {{0, 3}, {0, 1.2}}] Note also that you don't need RegionPlot for your example. plot1 = Plot[1/x^2, {x, 1, 3}, Filling -> 0]; plot2 = Graphics[{Red, FontSize -> 14, FontFamily -> Helvetica, Text[My text, {1.3, 1}]}]; Show[{plot1, plot2}, PlotRange -> {{0, 3}, {0, 1.2}}, AxesOrigin -> {0, 0}] -- Helen Read University of Vermont === Subject: Re: Adding text to RegionPlot Hi Jim, you can generally add text to any plot using the Epilog option: e.g.: RegionPlot[..., Epilog -> {Text[mytext, {1.5, 1}]}] === Subject: Re: Adding text to RegionPlot Use Epilog, RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange -> {{0, 3}, {0, 1.1}}, Epilog -> {Text[mytext, {1.5, 1}]}, AspectRatio -> Automatic] One has to wonder why the default AspectRatio for RegionPlot is 1 and all the examples in Help use iterators that result in a square region (except the example in Options, AspectRatio). An AspectRatio of 1 will normally distort the shape of the region. With the Presentations package you don't have to use Epilog or Show and you can just draw one thing after another without any jumping of graphics levels. Needs[Presentations`Master`] Draw2D[ {RegionDraw[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}], RegionDraw[y <= Sqrt[x] && x <= 2, {x, 0, 3}, {y, 0, 3}, PlotStyle -> Opacity[.3, Orange], MaxRecursion -> 4], Text[mytext, {1.5, 1}]}, PlotRange -> {{0, 3}, {0, 1.5}}, Frame -> True ] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I would like to add text at specific (x,y) locations for a 2D graphic generated by RegionPlot (meaning, I'd rather not use the graphic tool and add text by hand). Is there a way to do this? I get mathematica complaints that RegionPlot is not a type of graphics. For example, this code fails: RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange -> {{0, 3}, {0, 1}},Graphics[Text[mytext, {1.5, 1}]] Apparently I'm using Graphics[Text[]] incorrectly. How can I get such a simple function of putting text at a specific location to work in RegionPlot? Jim === Subject: Re: Adding text to RegionPlot RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange -> {{0, 3}, {0, 1}}, Epilog -> Text[mytext, {1.5, .8}]] Show[RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange -> {{0, 3}, {0, 1}}], Graphics[Text[mytext, {1.5, .8}]]] Bob Hanlon I would like to add text at specific (x,y) locations for a 2D graphic generated by RegionPlot (meaning, I'd rather not use the graphic tool and add text by hand). Is there a way to do this? I get mathematica complaints that RegionPlot is not a type of graphics. For example, this code fails: RegionPlot[y <= (1/x^2) && y >= 0, {x, 1, 3}, {y, 0, 1}, PlotRange -> {{0, 3}, {0, 1}},Graphics[Text[mytext, {1.5, 1}]] Apparently I'm using Graphics[Text[]] incorrectly. How can I get such a simple function of putting text at a specific location to work in RegionPlot? Jim === Subject: Re: Importing a large image... > So, my fellow denizens of the group. I have a very large TIFF image--roughly 700MB in size. Its dimension are 43201 by 15601. It is single color with a bit depth > of 8. without maxing out the memory. I actually do not need to read in the whole file: I'd be happen with > being able to break the file into a number of smaller TIFFs which tile > it completely and then process each on independently (I am needing to > act on the data in various ways to yield a processed result for > further analysis down the line). This is all for a larger project > for a consulting client of mine. Any suggestions for how to programmatically carve up the image without > having to completely read it in first? I am looking for quick > solutions rather than ones that require a lot of programming. Either > it can be done pretty simply, or (more likely) Mathematica chokes on > these very large files. (Photoshop, on the other hand, does not choke on it at all, nor do > some other programs that are optimized for image analysis such as ENVI > (http://www.ittvis.com/ProductServices/ENVI.aspx): but I don't want to > work with these... nor do I have them....) Naturally, Mathematica can't be good for any task. Sometimes you have to use other programs too :) So I'd recommend trying ImageMagick's convert tool: http://www.imagemagick.org/ convert -crop 200x200 yourfile.tiff out%d.png will break the image into 200x200 pixel tiles. Now I can't guarantee that it won't run out of memory, and I did have trouble with the TIFF files ImageMagick generated in the past (that's why I used PNG as the output in the example), but it's certainly worth a try. Of course this leads to a suggestion for the Import function: to allow > reading in only a part of an image at a time. Feel free to respond to the list, but also CC me on the replies so > that I get them sooner than the usual turnaround. > === Subject: How to build a Tag Cloud Graph? Let say, I have a simple list of sales numbers in different products. The first element of the sublist is a product, the second is a product group and the 3rd is the turnover. Like this one: sales={{Beef,Meat, 2343},{Milk,Drink, 234}, {Water,Drink, 234}, {Beer, Drink, 1546}, {Coke, Drink, 1223}, {Pork, Meat, 1223}} QUESTION: How to construct a Tag Cloud Plot in the way as it defined in wikipedia: ...Tags are usually single words and are typically listed alphabetically, and the importance of a tag is shown with font size or color... For full details see: http://en.wikipedia.org/wiki/Tag_cloud It should be a frame with words in alphabetical order with different font color for different product group. Condition: For displaying products with huge and very small numbers a maximum and minimum font size should apply. Plotty === Subject: Re: problem with mathematica :( > Hi Mathematica community, > I have this system of equations: > Reduce[{i >= iP, v + a*t/(1 - d) == vP + a*tP/(1 - d), > t/d^(x/a) == tP/d^(xP/a), a*i + 1*x == a*iP + 1*xP, > t/d^(i/-1) == tP/d^(iP/-1), > z - c*x*(x - a)/(2*a) == zP - c*xP*(xP - a)/(2*a),iP==0}, > {iP,tP,vP,xP,zP},Backsubstitution->True] > But mathematica still in running until I abort.Could you tell me what > is the problem? > Salut, you know: iP==0. Usi this and the assumptions d>0 , a!=0 and all variables are real: In[1]:= sys = {i >= iP, v + a*(t/(1 - d)) == vP + a*(tP/(1 - d)), t/d^(x/a) == tP/d^(xP/a), a*i + 1*x == a*iP + 1*xP, t/d^(i/-1) == tP/d^(iP/-1), z - c*x*((x - a)/(2*a)) == zP - c*xP*((xP - a)/(2*a)), iP == 0}; tosolvefor = {iP, tP, vP, xP, zP}; In[3]:= simpsys = FullSimplify[And @@ sys /. iP -> 0, Inequality[a, Unequal, 0, Less, d]] Out[3]= d^i*t == tP && t/d^(x/a) == tP/d^(xP/a) && (a*(t - tP))/(-1 + d) + vP == v && a*i + x == xP && a*c*x + c*xP^2 + 2*a*z == c*x^2 + a*c*xP + 2*a*zP && i >= 0 In[4]:= vars = Union[Cases[simpsys, s_Symbol /; ! NumericQ[s], Infinity]]; In[5]:= tosolvefor = Intersection[tosolvefor, vars]; I'll delete the parts telling us about real variables: In[6]:= soln = DeleteCases[ Reduce[And[simpsys, Im[vars] == 0 && a != 0 && 0 < d], tosolvefor, Backsubstitution -> True], Element[_, Reals], 2] Out[6]= (a != 0 && 0 < d < 1 && i >= 0 && tP == d^i*t && vP == ((-a)*t + a*d^i*t - v + d*v)/(-1 + d) && xP == a*i + x && zP == (1/2)*((-a)*c*i + a*c*i^2 + 2*c*i*x + 2*z)) || (a != 0 && d > 1 && i >= 0 && tP == d^i*t && vP == ((-a)*t + a*d^i*t - v + d*v)/(-1 + d) && xP == a*i + x && zP == (1/2)*((-a)*c*i + a*c*i^2 + 2*c*i*x + 2*z)) and to compact this, use e.g: In[7]:= LogicalCompact = Block[{common}, #1 //. Or[r1___, x_And, r2___, y_And, r3___ /;((common = Intersection[x, y]) =!= True) :> (common && Or @@ DeleteCases[{x, y}, Alternatives @@ common, 2]) || r1 || r2 || r3] & ; In[8]:= LogicalCompact[soln] Out[8]= tP == d^i*t && vP == ((-a)*t + a*d^i*t - v + d*v)/(-1 + d) && xP == a*i + x && zP == (1/2)*((-a)*c*i + a*c*i^2 + 2*c*i*x + 2*z) && i >= 0 && a != 0 && (0 < d < 1 || d > 1) HTH, Peter === Subject: Re: problem with mathematica :( >> Hi Mathematica community, >> I have this system of equations: >> Reduce[{i >= iP, v + a*t/(1 - d) == vP + a*tP/(1 - d), >> t/d^(x/a) == tP/d^(xP/a), a*i + 1*x == a*iP + 1*xP, >> t/d^(i/-1) == tP/d^(iP/-1), 0}, >> {iP,tP,vP,xP,zP},Backsubstitution->True] >> But mathematica still in running until I abort.Could you tell me what >> is the problem? Remove the inequality unless you really need it. It makes the problem > much much more difficult. > Actually it looks like you can re-add it once the equation part is solved= : Reduce[{v + (a t)/(1 - d) == vP + (a tP)/(1 - d), t/d^(x/a) == tP/d^(xP/a), a i + 1 x == a iP + 1 xP, t/d^(i/-1) == tP/d^(iP/-1), z - (c x (x - a))/(2 a) == zP - (c xP (xP - a))/(2 a), iP == 0}, {iP, tP, vP, xP, zP}, Backsubstitution -> True] Reduce[% && i >= iP, {iP, tP, vP, xP, zP}, Reals] === Subject: Re: problem with mathematica :( > Hi Mathematica community, > I have this system of equations: > Reduce[{i >= iP, v + a*t/(1 - d) == vP + a*tP/(1 - d), > t/d^(x/a) == tP/d^(xP/a), a*i + 1*x == a*iP + 1*xP, > t/d^(i/-1) == tP/d^(iP/-1), > z - c*x*(x - a)/(2*a) == zP - c*xP*(xP - a)/(2*a),iP==0}, > {iP,tP,vP,xP,zP},Backsubstitution->True] > But mathematica still in running until I abort.Could you tell me what > is the problem? Remove the inequality unless you really need it. It makes the problem much much more difficult. === Subject: Re: ODE problem a) x*y'[x])'[x] is nonsense, you mean D[x*y'[x],x] b) x=0 is a singular point of the ode, you can't start in a singular point Jens > What went wrong in the foolwoing > s = NDSolve[{(x*y'[x])'[x] + Sin[y[x]]*y[x] == 0, y[0] == 1, > y'[0] == 0}, y[x], {x, 0, 30}]; > Plot[Evaluate[{y[x]} /. s], {x, 0, 30}, PlotStyle -> Automatic] > === Subject: How include a online help for Package in the Documentation Center I have developped the Documentation Help for package (for Mathematica 5) using BrowserCategories. They work in version 7, however I realize that in version 7 the Help for packages is included applying other pattern (including several directories: Guides, ReferencePages, etc.?. Where can be found a detailed description about its? Guillermo === Subject: Re: How include a online help for Package in the Documentation Center Basically you use Workbench. It works well for documenting a single package, but needs some work for extended applications. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have developped the Documentation Help for package (for Mathematica 5) using BrowserCategories. They work in version 7, however I realize that in version 7 the Help for packages is included applying other pattern (including several directories: Guides, ReferencePages, etc.?. Where can be found a detailed description about its? Guillermo === Subject: Re: How include a online help for Package in the Documentation Center Take a look at the notebook Documentation Center Notes at http://scientificarts.com/worklife/notebooks/index.html This topic has been discussed quite a bit on this group. Also, A WorkLife FrameWork (the beta version 3.0 which is the one I use daily) has tools to do the conversion automatically for you. Hope this helps, David On Mar 28, 6:40 am, Guillermo Sanchez I have developped the Documentation Help for package (for Mathematica > 5) using BrowserCategories. They work in version 7, however I realize > that in version 7 the Help for packages is included applying other > pattern (including several directories: Guides, ReferencePages, etc.?. > Where can be found a detailed description about its? > Guillermo === Subject: Re: Kernel is quitting on me with two months worth of coding, a boss breathing on my neck, and a program that can crash not only the kernel but now the front end, depending on how I use it. I had to deal with some problems with our Premier Service license, it looks like it will be solved but at bureaucracy speeds, so I give it a month or two until I can send my notebook to Wolfram tech support. In the meantime, I was hoping that if I update the status of the problem here somebody will see something that points to where my problem is. I followed some people's suggestions and I Removed ALL variables that are declared and used in Modules. In order to avoid further problems, for each Module I created a special variable that is assigned the number or list that gets Returned (this variable cannot be Removed). This didn't work. Then, I inserted Print[MemoryInUse[]] commands everywhere in all modules to keep track of the memory usage, hoping to catch a memory leak in action. Not only this didn't give me anything (memory is fine until crash), but this made a full crash of both the kernel and the front end...The only new bit of information is that before shutting down, Mathematica gives an error message: A Mathlink communication error has occurred which Mathematica is unable to recover from. Funny thing is, I am *not* using Mathlink at all! I thought that maybe this could point to only a few functions that internally use Mathlink... The other new symptom is that the crash has become more stable now. Normally it will crash the *second* time I use my driver Module. I still don't know what this means, but it could be useful. Fernando PS: by the way it feels bad to crash Mathematica at will ! yours was a very useful answer. I was also afraid that there could be > a memory leak somewhere. However, I don't know how to track down the > offending code. Any ideas? > I Remove-d all variables from my modules (which were all properly > defined as local anyway), except the one that gets returned as the > output of the module. How could I do that? There are also hidden > variables created inside each Module when computations are made, I > guess I have to pray for those to be disposed of. > Do you think that renaming all variables from all modules so that > there are no two variables named the same could help? I mean, even if > they are local to the module, could they collide and cause the leak? Fernando > Hi all, I am testing a very long worksheet, and all the pieces seem to be > working (separately). When I use the loop that puts them all > together, > the kernel quits after a few seconds (or at least, the equivalent of > the kernel quitting: everything goes undefined and in a weird > color). > I've tried following the computation step by step and everything > seems > normal until it just hangs. Also it seems to hang at different > places > everytime, but that *could* be that I am testing with a different > random initial condition every time. > I've checked if it is memory usage, it shouldn't be since the > MaxMemoryUsed never goes above 15MB. I tried with $HistoryLength=0 > just in case. The kernel in Debugger mode also just quits. > There is almost no symbolic manipulation either, just operations on > lists with numeric values. > I can't reproduce the error with simpler algorithms, and submitting > the whole worksheet for other to find a bug seems too much. My question is then: What kind of things can cause this behavior?? I > have really no clue since there are no error or warning messages, > just > an ugly quit. I would appreciate at any pointers to where can I > start > looking at... >> I suspect you have a memory leak in a Module. I know Mathematica >> is > supposed to be garbage collected but in my experience I have found >> routines that leak, my recommendation is to use Remove on any >> variables created in modules. I don't know what kind of code you >> are writing but I have also been able to cause some Mathematica >> routines to crash on input that doesn't seem particularly special, >> in particular I've seen SingularValueDecomposition fail on >> seemingly = > innocuous numeric input. >> Hope this helps, >> Ssezi === Subject: rules on vector sequence I need to generate all the vectors, of a given length N, that have these three properties: 1- the entries have to be among -2,-1,0,1,2 2- the sum of all the entries has to be 0 3- only two or four of the entries can be different from 0 do you have any suggestions on how i can do that? i tried something but without success.. expecially i don't know how to implement the third rule.. thank you in advance! Filippo === Subject: Re: rules on vector sequence > I need to generate all the vectors, of a given length N, that have > these three properties: 1- the entries have to be among -2,-1,0,1,2 > 2- the sum of all the entries has to be 0 > 3- only two or four of the entries can be different from 0 do you have any suggestions on how i can do that? i tried something > but without success.. expecially i don't know how to implement the > third rule.. > thank you in advance! > Filippo filippo[n_Integer, nz_Integer] := Join @@ (Permutations[PadRight[#, n]] & /@ Select[Tuples[{-2, -1, 0, 1, 2}, nz], Total[#] == 0 &]); n : length of vector nz : number of entries not explicitly set to 0 filippo[4, 2] ==> {{-2,2,0,0},{-2,0,2,0},{-2,0,0,2},{2,-2,0,0}, {2,0,-2,0},{2,0,0,-2},{0,-2,2,0},{0,-2,0,2},{0,2,-2,0},{0,2,0,-2}, {0,0,-2,2},{0,0,2,-2},{-1,1,0,0},{-1,0,1,0},{-1,0,0,1},{1,-1,0,0}, {1,0,-1,0},{1,0,0,-1},{0,-1,1,0},{0,-1,0,1},{0,1,-1,0},{0,1,0,-1}, {0,0,-1,1},{0,0,1,-1},{0,0,0,0},{1,-1,0,0},{1,0,-1,0},{1,0,0,-1}, {-1,1,0,0},{-1,0,1,0},{-1,0,0,1},{0,1,-1,0},{0,1,0,-1},{0,-1,1,0}, {0,-1,0,1},{0,0,1,-1},{0,0,-1,1},{2,-2,0,0},{2,0,-2,0},{2,0,0,-2}, {-2,2,0,0},{-2,0,2,0},{-2,0,0,2},{0,2,-2,0},{0,2,0,-2},{0,-2,2,0}, {0,-2,0,2},{0,0,2,-2},{0,0,-2,2}} === Subject: Re: rules on vector sequence Here's a faster version: Clear[sums, insertions, insertPositions] insertPositions[{x__}] := Flatten@Position[Unitize@{x, 1}, 1] insertions[x : {__List}] := Union @@ insertions /@ x insertions[x_List] := Insert[x, 0, #] & /@ insertPositions@x sums[1] = {}; sums[2] = {{-2, 2}, {-1, 1}, {1, -1}, {2, -2}}; sums[3] = Union @@ (Permutations@PadLeft[#, 3, 0] & /@ sums@2); sums[4] = Module[{nonZero = {-2, -1, 1, 2}}, Union @@ Permutations /@ Join[Select[Tuples@{nonZero, nonZero, nonZero, nonZero}, 0 == Total@# &], insertions@insertions@sums@2] ]; sums[n_Integer /; n > 4] := Union @@ (Permutations@PadLeft[#, n, 0] & /@ sums@4) Timing[new = sums@17; Length@new] {1.67356, 86224} Timing[Length@sums@18] {2.2947, 110772} Timing[Length@sums@19] {3.07204, 140220} Timing[Length@sums@20] {4.13911, 175180} This is no longer recursive, so it won't store huge results (and use up memory), like the previous solution. The new, slightly faster insertions is not really important, since it's used only for sums[4]. The older insertions would do just as well. Bobby > wow i have to study how this works! ; ) >> Here's a solution: >> Clear[sums, insertions] >> insertions[x : {__List}] := Union @@ insertions /@ x >> insertions[x_List] := Union[Insert[x, 0, #] & /@ Range[1 + Length@x]] >> sums[1] = {}; >> sums[2] = {{-2, 2}, {-1, 1}, {1, -1}, {2, -2}}; >> sums[4] = Module[{nonZero = {-2, -1, 1, 2}}, >> Union @@ >> Permutations /@ >> Join[Select[Tuples@{nonZero, nonZero, nonZero, nonZero}, >> 0 == Total@# &], insertions@insertions@sums@2] >> ]; >> sums[len_?Positive] := sums[len] = insertions@sums[len - 1] >> Timing[Length@sums@17] >> {7.9271, 86224} >> sums@3 >> {{-2, 0, 2}, {-2, 2, 0}, {-1, 0, 1}, {-1, 1, 0}, {0, -2, 2}, {0, -1, >> 1}, {0, 1, -1}, {0, 2, -2}, {1, -1, 0}, {1, 0, -1}, {2, -2, 0}, {2, >> 0, -2}} >> Length@sums@4 >> 60 >> Length@sums@5 >> 220 >> s6 = sums@6; >> Length@s6 >> Total /@ s6 // Union >> Total /@ Unitize@s6 // Union >> Length@s6 == Length@Union@s6 >> 600 >> {0} >> {2, 4} >> True >> Bobby > I need to generate all the vectors, of a given length N, that have > these three properties: 1- the entries have to be among -2,-1,0,1,2 > 2- the sum of all the entries has to be 0 > 3- only two or four of the entries can be different from 0 do you have any suggestions on how i can do that? i tried something > but without success.. expecially i don't know how to implement the > third rule.. > thank you in advance! > Filippo > --DrMajorBob@bigfoot.com > -- DrMajorBob@bigfoot.com === Subject: Re: rules on vector sequence wow i have to study how this works! ; ) > Here's a solution: Clear[sums, insertions] > insertions[x : {__List}] := Union @@ insertions /@ x > insertions[x_List] := Union[Insert[x, 0, #] & /@ Range[1 + Length@x]] > sums[1] = {}; > sums[2] = {{-2, 2}, {-1, 1}, {1, -1}, {2, -2}}; > sums[4] = Module[{nonZero = {-2, -1, 1, 2}}, > Union @@ > Permutations /@ > Join[Select[Tuples@{nonZero, nonZero, nonZero, nonZero}, > 0 == Total@# &], insertions@insertions@sums@2] > ]; > sums[len_?Positive] := sums[len] = insertions@sums[len - 1] Timing[Length@sums@17] {7.9271, 86224} sums@3 {{-2, 0, 2}, {-2, 2, 0}, {-1, 0, 1}, {-1, 1, 0}, {0, -2, 2}, {0, -1, > 1}, {0, 1, -1}, {0, 2, -2}, {1, -1, 0}, {1, 0, -1}, {2, -2, 0}, {2, > 0, -2}} Length@sums@4 60 Length@sums@5 220 s6 = sums@6; > Length@s6 > Total /@ s6 // Union > Total /@ Unitize@s6 // Union > Length@s6 == Length@Union@s6 600 {0} {2, 4} True Bobby > I need to generate all the vectors, of a given length N, that have >> these three properties: >> 1- the entries have to be among -2,-1,0,1,2 >> 2- the sum of all the entries has to be 0 >> 3- only two or four of the entries can be different from 0 >> do you have any suggestions on how i can do that? i tried something >> but without success.. expecially i don't know how to implement the >> third rule.. >> thank you in advance! >> Filippo > > -- > DrMajorBob@bigfoot.com === Subject: Re: rules on vector sequence > I need to generate all the vectors, of a given length N, that have > these three properties: 1- the entries have to be among -2,-1,0,1,2 > 2- the sum of all the entries has to be 0 > 3- only two or four of the entries can be different from 0 do you have any suggestions on how i can do that? i tried something > but without success.. expecially i don't know how to implement the > third rule.. > thank you in advance! > Filippo Treat the third rule as defining two separate problems. s = Join[Union[Sort/@Select[Tuples[{-2,-1,1,2},2],Tr@#==0&]], Union[Sort/@Select[Tuples[{-2,-1,1,2},4],Tr@#==0&]]] {{-2,2},{-1,1},{-2,-2,2,2},{-2,-1,1,2},{-1,-1,1,1}} Then pad each sublist out to the desired length and get all its permutations. Join@@(Permutations@PadLeft[#,4]& /@ s) {{0, 0, -2, 2}, {0, 0, 2, -2}, {0, -2, 0, 2}, {0, -2, 2, 0}, {0, 2, 0, -2}, {0, 2, -2, 0}, {-2, 0, 0, 2}, {-2, 0, 2, 0}, {-2, 2, 0, 0}, {2, 0, 0, -2}, {2, 0, -2, 0}, {2, -2, 0, 0}, {0, 0, -1, 1}, {0, 0, 1, -1}, {0, -1, 0, 1}, {0, -1, 1, 0}, {0, 1, 0, -1}, {0, 1, -1, 0}, {-1, 0, 0, 1}, {-1, 0, 1, 0}, {-1, 1, 0, 0}, {1, 0, 0, -1}, {1, 0, -1, 0}, {1, -1, 0, 0}, {-2, -2, 2, 2}, {-2, 2, -2, 2}, {-2, 2, 2, -2}, {2, -2, -2, 2}, {2, -2, 2, -2}, {2, 2, -2, -2}, {-2, -1, 1, 2}, {-2, -1, 2, 1}, {-2, 1, -1, 2}, {-2, 1, 2, -1}, {-2, 2, -1, 1}, {-2, 2, 1, -1}, {-1, -2, 1, 2}, {-1, -2, 2, 1}, {-1, 1, -2, 2}, {-1, 1, 2, -2}, {-1, 2, -2, 1}, {-1, 2, 1, -2}, {1, -2, -1, 2}, {1, -2, 2, -1}, {1, -1, -2, 2}, {1, -1, 2, -2}, {1, 2, -2, -1}, {1, 2, -1, -2}, {2, -2, -1, 1}, {2, -2, 1, -1}, {2, -1, -2, 1}, {2, -1, 1, -2}, {2, 1, -2, -1}, {2, 1, -1, -2}, {-1, -1, 1, 1}, {-1, 1, -1, 1}, {-1, 1, 1, -1}, {1, -1, -1, 1}, {1, -1, 1, -1}, {1, 1, -1, -1}} === Subject: Re: rules on vector sequence Not practical for n>~6 : n = 4; elements = {-2, -1, 0, 1, 2}; rules[entry_] := Total[entry] == 0 && (Count[entry, 0] == (n - 2) || Count[entry, 0] == (n - 4) ) Select[Tuples[elements, n], rules[#] &] -Francesco > I need to generate all the vectors, of a given length N, that have > these three properties: 1- the entries have to be among -2,-1,0,1,2 > 2- the sum of all the entries has to be 0 > 3- only two or four of the entries can be different from 0 do you have any suggestions on how i can do that? i tried something > but without success.. expecially i don't know how to implement the > third rule.. > thank you in advance! > Filippo > === Subject: Re: rules on vector sequence Filippo, Generate all possible vectors with Tuples then select (with Cases or Select) the ones that comply with 2 and 3. Use Total for 2 and Count for 3. > I need to generate all the vectors, of a given length N, that have > these three properties: 1- the entries have to be among -2,-1,0,1,2 > 2- the sum of all the entries has to be 0 > 3- only two or four of the entries can be different from 0 do you have any suggestions on how i can do that? i tried something > but without success.. expecially i don't know how to implement the > third rule.. > thank you in advance! > Filippo === Subject: Using a variable set elsewhere within a function that has attribute Hello Mathematica users, I am trying to use a variable defined elsewhere within Manipulate. I have assigned an expression to the variable that involves another variable. That second variable should not be assigned to anything outside of manipulate, however, within Manipulate, I want that second variable to change as I drag a slider and anything that uses the first variable to change accordingly. I am not quite sure I am saying this right, but this example should make clear what I mean: ode = x'[t] == r x[t] - x[t]^2; Manipulate[ ode, {r, 0.1, 1} ] I do not get any warnings or errors, but the result is not as you might expect: in the output the equation is displayed without a value for r and the slider does nothing. Manipulate[ Evaluate[ode], {r, 0.1, 1} ] does what you expect. The output contains a value for r which changes as the slider is dragged. Now I want to use ode for something else. Manipulate[ Plot[x[t] /. NDSolve[{Evaluate[ode], x[0] == 0.1}, x, {t, 0, 10}], {t, 0, 10}], {r, 0, 1} ] Here I get errors: NDSolve::dsvar: 0.0002042857142857143` cannot be used as a variable. >> ReplaceAll::reps: {NDSolve[{(x^[Prime])[0.000204286]==r x[0.000204286]-x[<<1>>]^2,x[0]==0.1},x,<<1>>]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >> [...] It looks like it takes a number for t when it should not, and not a number for r when it should. What I want is of course a plot of x vs. t that changes as I change r by dragging the slider. I've tried many things, including changing the attributes of Manipulate, but no good results. I am not even sure what the problem exactly is... How do I solve this problem? What is the best way to do what I want to do? Daan === Subject: Re: Using a variable set elsewhere within a function that has > Hello Mathematica users, I am trying to use a variable defined elsewhere within Manipulate. I > have assigned an expression to the variable that involves another > variable. That second variable should not be assigned to anything > outside of manipulate, however, within Manipulate, I want that second > variable to change as I drag a slider and anything that uses the first > variable to change accordingly. I am not quite sure I am saying this > right, but this example should make clear what I mean: ode = x'[t] == r x[t] - x[t]^2; > Manipulate[ > ode, > {r, 0.1, 1} > ] I do not get any warnings or errors, but the result is not as you might > expect: in the output the equation is displayed without a value for r > and the slider does nothing. Manipulate[ > Evaluate[ode], > {r, 0.1, 1} > ] does what you expect. The output contains a value for r which changes as > the slider is dragged. Now I want to use ode for something else. Manipulate[ > Plot[x[t] /. NDSolve[{Evaluate[ode], x[0] == 0.1}, x, {t, 0, 10}],= {t, > 0, 10}], > {r, 0, 1} > ] Here I get errors: NDSolve::dsvar: 0.0002042857142857143` cannot be used as a variable. > ReplaceAll::reps: {NDSolve[{(x^[Prime])[0.000204286]==r > x[0.000204286]-x[<<1>>]^2,x[0]==0.1},x,<<1>>]} is neither a list of > replacement rules nor a valid dispatch table, and so cannot be used for > replacing. > [...] It looks like it takes a number for t when it should not, and not a > number for r when it should. What I want is of course a plot of x vs. t that changes as I change r by > dragging the slider. I've tried many things, including changing the > attributes of Manipulate, but no good results. I am not even sure what > the problem exactly is... How do I solve this problem? What is the best way to do what I want to do= ? > Daan I'm not a manipulate guru but a quick fix would be: Manipulate[ f = NDSolve[{x'[t] == r x[t] - x[t]^2, x[0] == 1/10}, x, {t, 0, 10}][[1, 1, 2]]; Plot[f[t], {t, 0, 10}], {r, 0, 1} ] === Subject: Re: Using a variable set elsewhere within a function that has attribute ode = x'[t] == r x[t] - x[t] 2; Manipulate[ode /. r -> [ScriptR], {[ScriptR], 0.1, 1}] Jens > Hello Mathematica users, I am trying to use a variable defined elsewhere within Manipulate. I > have assigned an expression to the variable that involves another > variable. That second variable should not be assigned to anything > outside of manipulate, however, within Manipulate, I want that second > variable to change as I drag a slider and anything that uses the first > variable to change accordingly. I am not quite sure I am saying this > right, but this example should make clear what I mean: ode = x'[t] == r x[t] - x[t]^2; > Manipulate[ > ode, > {r, 0.1, 1} > ] I do not get any warnings or errors, but the result is not as you might > expect: in the output the equation is displayed without a value for r > and the slider does nothing. Manipulate[ > Evaluate[ode], > {r, 0.1, 1} > ] does what you expect. The output contains a value for r which changes as > the slider is dragged. Now I want to use ode for something else. Manipulate[ > Plot[x[t] /. NDSolve[{Evaluate[ode], x[0] == 0.1}, x, {t, 0, 10}], {t, > 0, 10}], > {r, 0, 1} > ] Here I get errors: NDSolve::dsvar: 0.0002042857142857143` cannot be used as a variable. > ReplaceAll::reps: {NDSolve[{(x^[Prime])[0.000204286]==r > x[0.000204286]-x[<<1>>]^2,x[0]==0.1},x,<<1>>]} is neither a list of > replacement rules nor a valid dispatch table, and so cannot be used for > replacing. > [...] It looks like it takes a number for t when it should not, and not a > number for r when it should. What I want is of course a plot of x vs. t that changes as I change r by > dragging the slider. I've tried many things, including changing the > attributes of Manipulate, but no good results. I am not even sure what > the problem exactly is... How do I solve this problem? What is the best way to do what I want to do? > Daan > === Subject: Does mathematica7 support fontconfig? Does mathematica7 support fontconfig ? === Subject: Re: Does mathematica7 support fontconfig? > Does mathematica7 support fontconfig ? It does. I'll pick fonts you install in ~/.fonts, for example. === Subject: Problem loading file I'm doing some large computations in Mathematica, and I'm having problems loading a data file. I did a computation, and stored the output to a file ( Factor[parameters[s,t]] >> paramData.txt). The file is big: 2.3 gb. When I try to open it: << paramData.txt or Get[paramData.txt] I get an error Get::noopen: Cannot open paramData.txt But with a smaller example: In[19]:= {1, 2, 3} >> testFILE In[21]:= << testFILE Out[21]= {1, 2, 3} everything works fine. Any ideas what the problem is? Is there a limit to the size of a file that Mathematica will load? === Subject: Re: Problem loading file Yes, I think there is a limit, and I think it is 2GB (2^31 bytes or 2147483648 bytes), so you are just over the limit. You might try using ReadList and read some of it and process, read some more and process, etc, like David Bailey suggests in http://forums.wolfram.com/mathgroup/archive/2007/Nov/msg00044.html -Bob I'm doing some large computations in Mathematica, and I'm having > problems loading a data file. I did a computation, and stored the > output to a file ( Factor[parameters[s,t]] >> paramData.txt). The > file is big: 2.3 gb. When I try to open it: > << paramData.txt > or > Get[paramData.txt] > I get an error > Get::noopen: Cannot open paramData.txt But with a smaller example: > In[19]:= {1, 2, 3} >> testFILE In[21]:= << testFILE Out[21]= {1, 2, 3} everything works fine. Any ideas what the problem is? Is there a > limit to the size of a file that Mathematica will load? === Subject: manipulate, NDSolve, Evaluate I am trying to combine, NDSolve with a ODE then using Plot[evaluate] to show the results, and then I would like to take it to the next step and use Manipulate. I am working a cell membranes capacitance based on the wall thickness. I would like the plot to show the the membrane voltage vs time,(I have done this with NDSolve and Plot), but I would like to use a slider that reflects the difference in the cell membranes thickness which affects the capacitance. Is this possible? Prof. Jake === Subject: Re: manipulate, NDSolve, Evaluate yes Jens > I am trying to combine, NDSolve with a ODE then using Plot[evaluate] to > show the results, and then I would like to take it to the next step and > use Manipulate. I am working a cell membranes capacitance based on the wall thickness. > I would like the plot to show the the membrane voltage vs time,(I have > done this with NDSolve and Plot), but I would like to use a slider that > reflects the difference in the cell membranes thickness which affects > the capacitance. > Is this possible? > Prof. Jake === Subject: Re: manipulate, NDSolve, Evaluate If you've already done it for a specific wall thickness it should be very easy to do the same in a Manipulate for variable thickness values. Please post more details if you want more specific assistence. > I am trying to combine, NDSolve with a ODE then using Plot[evaluate] to > show the results, and then I would like to take it to the next step and > use Manipulate. I am working a cell membranes capacitance based on the wall thickness. = > I would like the plot to show the the membrane voltage vs time,(I have > done this with NDSolve and Plot), but I would like to use a slider that > reflects the difference in the cell membranes thickness which affects > the capacitance. > Is this possible? > Prof. Jake === Subject: Re: manipulate, NDSolve, Evaluate Here is what I have done so far. (* First is an injected current that is applied to the cell*) i[t_] := If[t < 10 || t > 60, 0, 1] (* now to plot the above equation *) Plot[i[t], {t, 0, 100}, PlotStyle -> {Red, Thick}] (* The equation for an RC circuit. Note the IC, and that c = 1. *) RCSoln1[R_, c_: 1, v0_: 0] := NDSolve[{v'[t] == 1/c (i[t] - v[t]/R), v[0] == v0}, v, {t, 0, 100}] (* Now plotting the above equation, and assigning R = 1 *) Plot[Evaluate[v[t] /. {RCSoln1[1]}], {t, 0, 100}, PlotStyle -> {Red, Thick}] (* Now let R = 1, and change the value of the capacitance in the plot to see what differences this makes *) RCSoln1a[R_: 1, c_, v0_: 0] := NDSolve[{v'[t] == 1/c (i[t] - v[t]/R), v[0] == v0}, v, {t, 0, 100}] p1 = Plot[Evaluate[v[t] /. {RCSoln1a[1]}], {t, 0, 100}, PlotStyle -> {Blue, Thick}] p2 = Plot[Evaluate[v[t] /. {RCSoln1a[5]}], {t, 0, 100}, PlotStyle -> {Red, Thick}] Show[p1, p2] Now compare the difference in the way the plots look when you change the R (resistance) vs the c (capacitance). In order for the capacitance to change like shown. What could cause the changes in the resistance and the capacitance? ? What I would like is: to use Manipulate with a slider to vary c and R. I tried to use this equation. NDSolve[{v'[t] == 1/(a*c) (i[t] - v[t]/(b*R), v[0] == v0}, v, {t, 0, 100}]. I changed the equation by putting (a*c) and (b*R). Then with the plot I thought I could add: Manipulate[Plot[Evaluate[v[t] /. {RCSoln1a[1]}], {t, 0, 100}, ,{a, 0, 5}, (b, 0, 5) PlotStyle -> {Blue, Thick}]] It did not work. This is just the beginning of the text book that I am writing. Thus I did not go into the finer details of the soma's wall thickness and how it changes capacitance. I just wanted to show in a graphic manner what could happen and illustrate a basic equivalent circuit for a cell membrane. Later on in the book, I go into more details. Can you help me now? Prof Jake > If you've already done it for a specific wall thickness it should be > very easy to do the same in a Manipulate for variable thickness > values. Please post more details if you want more specific assistence. > >> I am trying to combine, NDSolve with a ODE then using Plot[evaluate] to >> show the results, and then I would like to take it to the next step and >> use Manipulate. >> I am working a cell membranes capacitance based on the wall thickness. = >> > > >> I would like the plot to show the the membrane voltage vs time,(I have >> done this with NDSolve and Plot), but I would like to use a slider that >> reflects the difference in the cell membranes thickness which affects >> the capacitance. >> Is this possible? >> Prof. Jake >> > === Subject: Re: Solve problem In[1]:= a1 /. Cases[{{b1 -> -2, a1 -> -1}, {b1 -> 0.5, a1 -> 3}}, r : (a1 -> (i_)?Positive), Infinity] Out[1]= 3 In[2]:= a1 /. Cases[{{a1 -> 1, b1 -> 3}}, r : (a1 -> (i_)?Positive), Infinity] Out[2]= 1 Adriano Pascoletti 2009/3/27 Bruno Campanini {{b1 -> -2, a1 -> -1 }, {b1 -> 0.5, a1 -> 3}} > or like > {{a1 -> 1, b1 -> 3}} How can I get the positive value for a1, which is 3 > in the first case and 1 in the second one? Bruno === Subject: Re: finding all definitions matching a pattern >Assume we have a number of definitions associated with a symbol F, >for example: >F[0] = 3; >F[1] = 7; >F[3] = 11; >What I need is an automated way to generate the list of definitions, >something like In[1] := getdefs[F] Out[1] = {{0,3},{1,7},{3,11}} f[0] = 3; f[1] = 7; f[3] = 11; In[4]:= Flatten /@ Apply[List, DownValues[f], 3] Out[4]= {{0, 3}, {1, 7}, {3, 11}} === Subject: Re: Asking PlotRange to take a Dynamic value > Hi Andrew, the whole Plot is dynamic, not simple the PlotRange. Therefore, put the Dynamic around Plot, not around z: Manipulate[ Dynamic@Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.01, n}, PlotStyle -> {Red, Blue, Blue, Blue}, PlotRange -> {{1, z}, {0, 55}}], Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small positive a 0.2, 0.25 & 0.3, 12, Bold], Row[{Style[x, Bold], from 1 to , PopupMenu[Dynamic[z], {10, 500, 10000, 500000}]}], {n, 0.1, Dynamic[z], Appearance -> Labeled}] Allow me some criticism. I do not see the point of the manipulate, it simple hides part of the plot. Would it not make more sense, if you would manipulate e.g. the PlotRange and always draw the whole plot? Daniel > I apologise in advance for what is probably a stupid question, but I > would appreciate some help in persuading PlotRange to take a Dynamic > value - or suggesting another way to go about things entirely! For teaching purposes I wanted to draw a series of graphs of Log[x] > vs. x^a for small positive values of a at different scales (simply to > illustrate how Log[x] is eventually < x^a, for any positive a). I > thought I would use Manipulate to allow students to explore this > interactively. E.g for x=0 to 10: Manipulate[ > Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.001, n}, > PlotStyle -> {Red, Blue, Blue, Blue}, > PlotRange -> {{0, 10}, {0, 3}}], > Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small > positive a 0.2, 0.25 & 0.3, 12, Bold], > Style[x = 0 to 10, 12, Bold], {n, 0.01, 10, > Appearance -> Labeled}] & for x=0 to 500,000: Manipulate[ > Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.001, n}, > PlotStyle -> {Red, Blue, Blue, Blue}, > PlotRange -> {{0, 500000}, {0, 55}}], > Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small > positive a 0.2, 0.25 & 0.3, 12, Bold], > Style[x = 0 to 500,000, 12, Bold], {n, 0.01, 500000, > Appearance -> Labeled}] But rather than a series of separate graphs I thought it would be more > elegant to combine them in one plot with a Dynamic value to choose the > scale, e.g.: Manipulate[ > Plot[{Log[x], x^0.2, x^0.25, x^0.3}, {x, 0.01, n}, > PlotStyle -> {Red, Blue, Blue, Blue}, > PlotRange -> {{1, Dynamic[z]}, {0, 55}}], > Style[Log[x] vs. !(*SuperscriptBox[x, a]) for small > positive a 0.2, 0.25 & 0.3, 12, Bold], > Row[{Style[x, Bold], from 1 to , > PopupMenu[Dynamic[z], {10, 500, 10000, 500000}]}], {n, 0.1, > Dynamic[z], Appearance -> Labeled}] Unfortunately, although the graphs will plot, with continually > updating axes, what I really want is to change the plot range for each > value of x & fix it so one can see the curves evolving more easily. I > hope the 2 individual examples above make it clear what I hoped for - > essentially, to click from one to the next with the PopupMenu. The > error message reads (e.g. for x=10): Plot::prng: Value of option PlotRange -> {{1,10},{0,55}} is not All, > Full, Automatic, a positive machine number, or an appropriate list of > range specifications. > > What's gone wrong? PlotRange -> {{1,10},{0,55}} looks like an > appropriate list of range specifications to me! Any advice appreciated > Andrew Graham Jens-Peer, Daniel - thank you! 1) I'm a fool - of course, PlotRange -> {{1, z}, {0, 55}}, not PlotRange -> {{1, Dynamic[z]}, {0, 55}} 2) Daniel, the aesthetic point is well taken Much appreciated Andrew === Subject: Re: What's going on here (Table-generated lists)? >> What is going on here? Is it something like Plot does a special scan = of >> its first argument before Evaluating it, and if it doesn't start out a= s >> a List, it concludes that it's all one thing and plots it with the sam= e >> color, as opposed to an explicitly provided list of separate colors? Yes, that is right. In newer versions of Mathematica, Plot[] is a complicated function that= > tries to guess whether the argument you provided needs to be evaluated > symbolically before substituting in numerical values for the plot > variable, or not. Of course it cannot always guess right. In this cas= e > it doesn't evaluate the Table before starting the plotting, so it think= s > that it'll have only one thing to plot, and thus it uses only one colou= r. IMO this is quite silly. If it is able to plot all five lines, it > should be able to figure out that it needs five colours ... attribute and why Plot is doing what it's doing. I fully understand why the HoldAll attribute is generally useful and why it's used here, but I still don't see why it doesn't make sense for Plot to recognize a list as an actual list and plot each with a different color. Shouldn't it be manually evaluating its argument, then plotting with different colors if it ends up with a list? Is there any particular situation where you'd want the current behavior -- not the HoldAll, but rather the plotting what ends up being a list of functions with the same color? -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis Always forgive your enemies -- nothing annoys them so much. -- Oscar Wilde === Subject: Re: What's going on here (Table-generated lists)? > attribute and why Plot is doing what it's doing. I fully understand why the HoldAll attribute is generally useful and why > it's used here, but I still don't see why it doesn't make sense for Plot > to recognize a list as an actual list and plot each with a different > color. Shouldn't it be manually evaluating its argument, then plotting > with different colors if it ends up with a list? Is there any particular situation where you'd want the current behavior > -- not the HoldAll, but rather the plotting what ends up being a list of > functions with the same color? I think it is a general problem: how many colors would you expect for this: Plot[Table[x^n, {n, 0, Floor[x]}], {x, 1, 10}, PlotRange -> All] or for this: f[x_] := (Pause[120]; Exp[x]) f[x_?NumericQ] := {Exp[x], Log[x]} Plot[f[x], {x, 0, 1}] Of course Plot could be programmed so that it detects more unambiguous cases and not only explicit Lists, but it also need to be reasonably fast, so there always is a limit on what it can handle as intended. I think the current behaviour is not too bad and there is a very simple workaround with which you can control exactly what it will do... albert === Subject: Re: What's going on here (Table-generated lists)? > Of course Plot could be programmed so that it detects more unambiguous > cases and not only explicit Lists, but it also need to be reasonably > fast, so there always is a limit on what it can handle as intended. I see your point about weird corner cases, but I don't see how expilcit List detection would cause a problem with speed. It would have to do it exactly once per call to Plot; it evaluates its argument, if its Head is a List, then it plots each element of that list with a different color; if not, then it plots whatever it can with one color. It seems to me that would be far more preferable as it's the behavior the user would reasonably expect. -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis You've got me wondering / If you know that I am wondering about you -- India Arie === Subject: Re: Cycling through windows with a keyboard shortcut > CTRL+F6 can be used to cycle through notebook windows (at least on > Windows), but it is not a very convenient keyboard shortcut. To use > it, one either has to use both hands, or move one hand from the normal > position. I'd like to associate a more accessible keyboard shortcut with this > function. Is there a front end token for cycling through windows? If > no, is there any other way one can implement cycling through windows > (both notebooks and documentation) without using the kernel? > I'm not on Windows. On my Mac cycling is done with cmd-<. This is not done by Mathematica but the System. Does Ctrl-F6 work for you in other applications too? Then I think you should try to alter this key-combination in Windows (if it's possible there) Peter -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: Cycling through windows with a keyboard shortcut I think the standard way to cycle thru multiple windows of the same > application on a Mac is CMD-` (backtick). I tried the CMD-< and I get > a beep. Great! How can I have been using Macs for 24 years, and never learned > that? This shortcut was introduced in Mac OS X 10.0 in 2001. So you've only been missing it for 8 years :) -Rob === Subject: Re: Cycling through windows with a keyboard shortcut > CTRL+F6 can be used to cycle through notebook windows (at least on > Windows), but it is not a very convenient keyboard shortcut. To use > it, one either has to use both hands, or move one hand from the normal > position. I'd like to associate a more accessible keyboard shortcut with this > function. Is there a front end token for cycling through windows? = If > no, is there any other way one can implement cycling through windows > (both notebooks and documentation) without using the kernel? I'm not on Windows. On my Mac cycling is done with cmd-<. This is not > done by Mathematica but the System. Does Ctrl-F6 work for you in other > applications too? Then I think you should try to alter this > key-combination in Windows (if it's possible there) Peter > -- > _________________________________________________________________ > Peter Breitfeld, Bad Saulgau, Germany --http://www.pBreitfeld.de I think the standard way to cycle thru multiple windows of the same application is CMD-` (backtick) on a Mac. I tried the CMD-< and I get a beep. There was a post about this same issue a while back -- see http://forums.wolfram.com/mathgroup/archive/2007/Aug/msg00999.html for another possible way. -Bob === Subject: Re: Cycling through windows with a keyboard shortcut I think the standard way to cycle thru multiple windows of the same > application on a Mac is CMD-` (backtick). I tried the CMD-< and I get > a beep. > Great! How can I have been using Macs for 24 years, and never learned that? === Subject: Re: Looking for help with Reduce command for use with my Calculus My first post to this newsgroup :-) I'm a mathematics instructor at a two-year college. Currently, I'm > trying to explain implicit differentiation and implicitly defined > functions to my students. To illustrate, I'm using the famous folium of Descartes: > x^3 + y^3 = 6xy I want to generate all the pairs of real (x,y) solutions for x taking > integer values from -4 to 3, and to then plot these pairs as points on > the curve defined by the equation. So far I've come up with: pts = Table[{i, Reduce[curve /. {x -> i}, y, Reals] // N}, {i, -4, 3}] which gives me a table with rows like: -4 y=2.2143 or like: 2 y=-3.75877 [Or] y=0.694593 [Or] y=3.06418 where the [Or] is the logical or symbol. Of course this is not what I want. I want a list of pairs like: (-4,2.2143), (2,-3.75877), (2,0.694693), (2,3.06418), etc... so I can plot them as points. Can any of you Mathematica mavens provide this neophyte with an elegant > solution? Gary Join @@ N @ Table[ Cases[Reduce[x^3 + y^3 == 6 x y, y, Reals], y == u_ :> {x, u}, {0, Infinity}], {x, -4, 3}] === Subject: Grid Mathematica 7 Idle Kernel Timeout I just finished upgrading our Grid Mathematica cluster from 6 to 7 today. I've been doing calculations that take about 12 hours per kernel for the last few months, so the switch from 8 to 20 kernels is a welcomed improvement. However, I'm having a problem keeping my slaves connected: there appears to be an idle timeout and it causes the slaves to disconnect. I have all the settings possible for timeout set to 0 (indefinite). The problem is fixed by occasionally printing status information back to the master notebook. Prior to the upgrade, I'd connect the slaves on launch and have them active without disconnect for weeks at a time. === Subject: Option instead of a function argument: is it possible? If we need to write functions depending upon several parameters the latter are usually passed to the function as its arguments. I wonder however, if you know a way to pass some parameters to a function in the same way as options are passed to operators in Mathematica. That is, if the default value of the parameter in question is OK, you do not even mention such a parameter among the function arguments. If you need to specify such a parameter you include an argument having the form Option->optionValue. Let me explain precisely within a simple example what I would like to: 1. Consider a function that solves a system of 2 ordinary differential equations and draws a trajectory on the (x, y) plane: trajectory1[eq1_, eq2_, point_, tmax_] := Module[{s, eq3, eq4}, eq3 = x[0] == point[[1]]; eq4 = y[0] == point[[2]]; s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}]; ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, PlotRange -> All]] Equations can be fixed say, like these: eq1 = x'[t] == -y[t] - x[t]^2; eq2 = y'[t] == 2 x[t] - y[t]^3; and initial conditions are passed by the parameter point. The function can be called: trajectory1[eq1, eq2, {1, 1}, 30] 2. Assume now that I need to specify the accuracy goal and MaxSteps parameters. Then the function will take a slightly different form: trajectory2[eq1_, eq2_, point_, tmax_, accuracyGoal_, maxSteps_] := Module[{s, eq3, eq4}, eq3 = x[0] == point[[1]]; eq4 = y[0] == point[[2]]; s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, AccuracyGoal -> accuracyGoal, MaxSteps -> maxSteps]; ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, PlotRange -> All]] and also called: trajectory2[eq1, eq2, {1, 1}, 30, 10, 1000] However, I would like to achieve a function trajectory3[eq1_, eq2_, point_, tmax_] that can be addressed both as trajectory3[eq1, eq2, {1, 1}, 30] (if I agree with the default values of the AccuracyGoal and MaxSteps) and as trajectory3[eq1, eq2, {1, 1}, 30, AccuracyGoal->10, MaxSteps->10000], if a change in these options is necessary. Is it possible? -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Re: Option instead of a function argument: is it possible? If we need to write functions depending upon several parameters the > latter are usually passed to the function as its arguments. I wonder > however, if you know a way to pass some parameters to a function in the > same way as options are passed to operators in Mathematica. That is, if > the default value of the parameter in question is OK, you do not even > mention such a parameter among the function arguments. If you need to > specify such a parameter you include an argument having the form > Option->optionValue. Let me explain precisely within a simple example what I would like to: 1. Consider a function that solves a system of 2 ordinary differential > equations and draws a trajectory on the (x, y) plane: trajectory1[eq1_, eq2_, point_, tmax_] := > Module[{s, eq3, eq4}, > eq3 = x[0] == point[[1]]; > eq4 = y[0] == point[[2]]; > s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}]; > ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, > PlotRange -> All]] Equations can be fixed say, like these: eq1 = x'[t] == -y[t] - x[t]^2; > eq2 = y'[t] == 2 x[t] - y[t]^3; and initial conditions are passed by the parameter point. The function > can be called: trajectory1[eq1, eq2, {1, 1}, 30] 2. Assume now that I need to specify the accuracy goal and MaxSteps > parameters. Then the function will take a slightly different form: trajectory2[eq1_, eq2_, point_, tmax_, accuracyGoal_, maxSteps_] := > Module[{s, eq3, eq4}, > eq3 = x[0] == point[[1]]; > eq4 = y[0] == point[[2]]; > s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, > AccuracyGoal -> accuracyGoal, MaxSteps -> maxSteps]; > ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, > PlotRange -> All]] and also called: trajectory2[eq1, eq2, {1, 1}, 30, 10, 1000] However, I would like to achieve a function trajectory3[eq1_, eq2_, point_, tmax_] that can be addressed both as trajectory3[eq1, eq2, {1, 1}, 30] (if I agree with the default values of the AccuracyGoal and MaxSteps) > and as trajectory3[eq1, eq2, {1, 1}, 30, AccuracyGoal->10, MaxSteps->10000], if a change in these options is necessary. Is it possible? Sure, you just need optional arguments to your function. Here's a simple example. f[x_, y_: 3, z_: 2] := x *y + z y and z are optional arguments. If you don't specify them, the default values (3 and 2 respectively) are used. Try evaluating these: f[x] f[x,5] f[x,-4,6] -- Helen Read University of Vermont === Subject: Re: Option instead of a function argument: is it possible? why not pass the options to the function, i.e., myfunction[arg1_,arg2_,opts___]:= (NDSolve[arg1,Sequence @@ FilterRules[{opts},Options[NDSolve]]]; Plot[arg2,Sequence @@ FilterRules[{opts},Options[Plot]]) it is a bit clumsy in Mathematica 6 and 7 and FilterOptions[] was significant better but it should work. Jens If we need to write functions depending upon several parameters the > latter are usually passed to the function as its arguments. I wonder > however, if you know a way to pass some parameters to a function in the > same way as options are passed to operators in Mathematica. That is, if > the default value of the parameter in question is OK, you do not even > mention such a parameter among the function arguments. If you need to > specify such a parameter you include an argument having the form > Option->optionValue. Let me explain precisely within a simple example what I would like to: 1. Consider a function that solves a system of 2 ordinary differential > equations and draws a trajectory on the (x, y) plane: trajectory1[eq1_, eq2_, point_, tmax_] := > Module[{s, eq3, eq4}, > eq3 = x[0] == point[[1]]; > eq4 = y[0] == point[[2]]; > s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}]; > ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, > PlotRange -> All]] Equations can be fixed say, like these: eq1 = x'[t] == -y[t] - x[t]^2; > eq2 = y'[t] == 2 x[t] - y[t]^3; and initial conditions are passed by the parameter point. The function > can be called: trajectory1[eq1, eq2, {1, 1}, 30] 2. Assume now that I need to specify the accuracy goal and MaxSteps > parameters. Then the function will take a slightly different form: trajectory2[eq1_, eq2_, point_, tmax_, accuracyGoal_, maxSteps_] := > Module[{s, eq3, eq4}, > eq3 = x[0] == point[[1]]; > eq4 = y[0] == point[[2]]; > s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, > AccuracyGoal -> accuracyGoal, MaxSteps -> maxSteps]; > ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, > PlotRange -> All]] and also called: trajectory2[eq1, eq2, {1, 1}, 30, 10, 1000] However, I would like to achieve a function trajectory3[eq1_, eq2_, point_, tmax_] that can be addressed both as trajectory3[eq1, eq2, {1, 1}, 30] (if I agree with the default values of the AccuracyGoal and MaxSteps) > and as trajectory3[eq1, eq2, {1, 1}, 30, AccuracyGoal->10, MaxSteps->10000], if a change in these options is necessary. Is it possible? > === Subject: Re: Option instead of a function argument: is it possible? Something like this: trajectory3[eq1_, eq2_, point_, tmax_, solveOptions___] := Module[{s, eq3, eq4}, eq3 = x[0] == point[[1]]; eq4 = y[0] == point[[2]]; s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, solveOptions]; ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, PlotRange -> All]] ? If we need to write functions depending upon several parameters the > latter are usually passed to the function as its arguments. I wonder > however, if you know a way to pass some parameters to a function in the > same way as options are passed to operators in Mathematica. That is, if > the default value of the parameter in question is OK, you do not ev= en > mention such a parameter among the function arguments. If you need to > specify such a parameter you include an argument having the form > Option->optionValue. Let me explain precisely within a simple example what I would like to: 1. Consider a function that solves a system of 2 ordinary differential > equations and draws a trajectory on the (x, y) plane: trajectory1[eq1_, eq2_, point_, tmax_] := > Module[{s, eq3, eq4}, > eq3 = x[0] == point[[1]]; > eq4 = y[0] == point[[2]]; > s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}]; > ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tm= ax}, > PlotRange -> All]] Equations can be fixed say, like these: eq1 = x'[t] == -y[t] - x[t]^2; > eq2 = y'[t] == 2 x[t] - y[t]^3; and initial conditions are passed by the parameter point. The function > can be called: trajectory1[eq1, eq2, {1, 1}, 30] 2. Assume now that I need to specify the accuracy goal and MaxSteps > parameters. Then the function will take a slightly different form: trajectory2[eq1_, eq2_, point_, tmax_, accuracyGoal_, maxSteps_] := > Module[{s, eq3, eq4}, > eq3 = x[0] == point[[1]]; > eq4 = y[0] == point[[2]]; > s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, > AccuracyGoal -> accuracyGoal, MaxSteps -> maxSteps]; > ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tm= ax}, > PlotRange -> All]] and also called: trajectory2[eq1, eq2, {1, 1}, 30, 10, 1000] However, I would like to achieve a function trajectory3[eq1_, eq2_, point_, tmax_] that can be addressed both as trajectory3[eq1, eq2, {1, 1}, 30] (if I agree with the default values of the AccuracyGoal and MaxSteps) > and as trajectory3[eq1, eq2, {1, 1}, 30, AccuracyGoal->10, MaxSteps->10000], if a change in these options is necessary. Is it possible? > -- > Alexei Boulbitch, Dr., habil. > Senior Scientist IEE S.A. > ZAE Weiergewan > 11, rue Edmond Reuter > L-5326 Contern > Luxembourg Phone: +352 2454 2566 > Fax: +352 2454 3566 Website:www.iee.lu This e-mail may contain trade secrets or privileged, undisclosed or other= wise confidential information. If you are not the intended recipient and ha= ve received this e-mail in error, you are hereby notified that any review, = copying or distribution of it is strictly prohibited. Please inform us imme= r your co-operation. === Subject: Re: Option instead of a function argument: is it possible? Alexei, eq1 = x'[t] == -y[t] - x[t]^2; eq2 = y'[t] == 2 x[t] - y[t]^3; Options[trajectory2] = {TrajectoryAccuracyGoal -> Automatic, TrajectoryMaxSteps -> 10000}; trajectory2[eq1_, eq2_, point_, tmax_, OptionsPattern[]] := Module[{s, eq3, eq4, accuracyGoal, maxSteps}, accuracyGoal = OptionValue[TrajectoryAccuracyGoal]; maxSteps = OptionValue[TrajectoryMaxSteps]; eq3 = x[0] == point[[1]]; eq4 = y[0] == point[[2]]; s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, AccuracyGoal -> accuracyGoal, MaxSteps -> maxSteps]; ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, PlotRange -> All]] trajectory2[eq1, eq2, {1, 1}, 30] trajectory2[eq1, eq2, {1, 1}, 30, TrajectoryMaxSteps -> 200, TrajectoryAccuracyGoal -> 2] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ If we need to write functions depending upon several parameters the latter are usually passed to the function as its arguments. I wonder however, if you know a way to pass some parameters to a function in the same way as options are passed to operators in Mathematica. That is, if the default value of the parameter in question is OK, you do not even mention such a parameter among the function arguments. If you need to specify such a parameter you include an argument having the form Option->optionValue. Let me explain precisely within a simple example what I would like to: 1. Consider a function that solves a system of 2 ordinary differential equations and draws a trajectory on the (x, y) plane: trajectory1[eq1_, eq2_, point_, tmax_] := Module[{s, eq3, eq4}, eq3 = x[0] == point[[1]]; eq4 = y[0] == point[[2]]; s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}]; ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, PlotRange -> All]] Equations can be fixed say, like these: eq1 = x'[t] == -y[t] - x[t]^2; eq2 = y'[t] == 2 x[t] - y[t]^3; and initial conditions are passed by the parameter point. The function can be called: trajectory1[eq1, eq2, {1, 1}, 30] 2. Assume now that I need to specify the accuracy goal and MaxSteps parameters. Then the function will take a slightly different form: trajectory2[eq1_, eq2_, point_, tmax_, accuracyGoal_, maxSteps_] := Module[{s, eq3, eq4}, eq3 = x[0] == point[[1]]; eq4 = y[0] == point[[2]]; s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, AccuracyGoal -> accuracyGoal, MaxSteps -> maxSteps]; ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, PlotRange -> All]] and also called: trajectory2[eq1, eq2, {1, 1}, 30, 10, 1000] However, I would like to achieve a function trajectory3[eq1_, eq2_, point_, tmax_] that can be addressed both as trajectory3[eq1, eq2, {1, 1}, 30] (if I agree with the default values of the AccuracyGoal and MaxSteps) and as trajectory3[eq1, eq2, {1, 1}, 30, AccuracyGoal->10, MaxSteps->10000], if a change in these options is necessary. Is it possible? -- Alexei Boulbitch, Dr., habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you are not the intended recipient and have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform you for your co-operation. === Subject: Re: Option instead of a function argument: is it possible? If we need to write functions depending upon several parameters the > latter are usually passed to the function as its arguments. I wonder > however, if you know a way to pass some parameters to a function in the > same way as options are passed to operators in Mathematica. That is, if > the default value of the parameter in question is OK, you do not even > mention such a parameter among the function arguments. If you need to > specify such a parameter you include an argument having the form > Option->optionValue. Let me explain precisely within a simple example what I would like to: 1. Consider a function that solves a system of 2 ordinary differential > equations and draws a trajectory on the (x, y) plane: trajectory1[eq1_, eq2_, point_, tmax_] := > Module[{s, eq3, eq4}, > eq3 = x[0] == point[[1]]; > eq4 = y[0] == point[[2]]; > s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}]; > ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, > PlotRange -> All]] Equations can be fixed say, like these: eq1 = x'[t] == -y[t] - x[t]^2; > eq2 = y'[t] == 2 x[t] - y[t]^3; and initial conditions are passed by the parameter point. The function > can be called: trajectory1[eq1, eq2, {1, 1}, 30] 2. Assume now that I need to specify the accuracy goal and MaxSteps > parameters. Then the function will take a slightly different form: trajectory2[eq1_, eq2_, point_, tmax_, accuracyGoal_, maxSteps_] := > Module[{s, eq3, eq4}, > eq3 = x[0] == point[[1]]; > eq4 = y[0] == point[[2]]; > s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, > AccuracyGoal -> accuracyGoal, MaxSteps -> maxSteps]; > ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, > PlotRange -> All]] and also called: trajectory2[eq1, eq2, {1, 1}, 30, 10, 1000] However, I would like to achieve a function trajectory3[eq1_, eq2_, point_, tmax_] that can be addressed both as trajectory3[eq1, eq2, {1, 1}, 30] (if I agree with the default values of the AccuracyGoal and MaxSteps) > and as trajectory3[eq1, eq2, {1, 1}, 30, AccuracyGoal->10, MaxSteps->10000], if a change in these options is necessary. Is it possible? > > This ca be done e.g like this. You can now pass any options of NDSolve to your function trajectories3: Options[trajectory3]=Options[NDSolve]; trajectory3[eq1_, eq2_, point_, tmax_, opts:OptionsPattern[]] := Module[{s, eq3, eq4}, eq3 = x[0] == point[[1]]; eq4 = y[0] == point[[2]]; s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, Evaluate[opts]]; ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, PlotRange -> All]] Peter -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: Looking for help with Reduce command for use with pts = {x, y} /. {Reduce[ {x^3 + y^3 == 6 x*y, -4 <= x <= 3, Element[x, Integers], Element[y, Reals]}, {x, y}] // ToRules} /. Root[a__] :> N[Root[a]] {{-4, 2.214295128870666}, {-3, 1.3601929545492113}, {-2, 0.6443707092521711}, {-1, 0.1659055841222127}, {0, 0}, {1, -2.528917957294362}, {1, 0.16744919110853515}, {1, 2.3614687661858267}, {2, -3.7587704831436337}, {2, 0.6945927106677213}, {2, 3.064177772475912}, {3, (1/2)*(-3 - 3*Sqrt[5])}, {3, (1/2)*(-3 + 3*Sqrt[5])}, {3, 3}} Bob Hanlon My first post to this newsgroup :-) I'm a mathematics instructor at a two-year college. Currently, I'm trying to explain implicit differentiation and implicitly defined functions to my students. To illustrate, I'm using the famous folium of Descartes: x^3 + y^3 = 6xy I want to generate all the pairs of real (x,y) solutions for x taking integer values from -4 to 3, and to then plot these pairs as points on the curve defined by the equation. So far I've come up with: pts = Table[{i, Reduce[curve /. {x -> i}, y, Reals] // N}, {i, -4, 3}] which gives me a table with rows like: -4 y=2.2143 or like: 2 y=-3.75877 [Or] y=0.694593 [Or] y=3.06418 where the [Or] is the logical or symbol. Of course this is not what I want. I want a list of pairs like: (-4,2.2143), (2,-3.75877), (2,0.694693), (2,3.06418), etc... so I can plot them as points. Can any of you Mathematica mavens provide this neophyte with an elegant solution? Gary === Subject: Re: Solve problem Select[{{b1 -> -2, a1 -> -1}, {b1 -> 0.5, a1 -> 3}}, a1 > 0 /. # &] ? Jens > I have a Solve[...] which gives me solutions like > {{b1 -> -2, a1 -> -1 }, {b1 -> 0.5, a1 -> 3}} > or like > {{a1 -> 1, b1 -> 3}} How can I get the positive value for a1, which is 3 > in the first case and 1 in the second one? Bruno > === Subject: Re: Solve problem > I have a Solve[...] which gives me solutions like > {{b1 -> -2, a1 -> -1 }, {b1 -> 0.5, a1 -> 3}} > or like > {{a1 -> 1, b1 -> 3}} How can I get the positive value for a1, which is 3 > in the first case and 1 in the second one? Bruno Hello Bruno, maybe you think of the following: A system of equations - yust as it came in my mind :-) In[42]:= gls={2 x+3 y==2,7 x-5 y^2==3} Out[42]= {2 x+3 y==2,7 x-5 y^2==3} the solution In[43]:= lsg=Solve[gls,{x,y}] // N Out[43]= {{x->0.506033,y->0.329311}, {x->4.64397,y->-2.42931}} extracting values In[45]:= temp={x,y} /. lsg Out[45]= {{0.506033,0.329311},{4.64397,-2.42931}} Selecting positive solution: In[49]:= Select[temp,#[[2]]>0&] Out[49]= {{0.506033,0.329311}} Mike === Subject: Re: Solve problem >I have a Solve[...] which gives me solutions like {{b1 -> -2, a1 --1 }, {b1 -> 0.5, a1 -> 3}} or like {{a1 -> 1, b1 -> 3}} >How can I get the positive value for a1, which is 3 in the first >case and 1 in the second one? It isn't clear to me what you mean by get in these cases. But here are three possibilities that might be close to what you want In[1]:= sol = {{b1 -> -2, a1 -> -1}, {b1 -> 0.5, a1 -> 3}}; In[2]:= Cases[sol, _?(Positive[a1 /. #] &)] Out[2]= {{b1->0.5,a1->3}} In[4]:= Cases[a1 /. # & /@ sol, _?Positive] Out[4]= {3} In[5]:= Cases[{b1, a1} /. # & /@ sol, {_, _?Positive}] Out[5]= {{0.5,3}} === Subject: Re: finding all definitions matching a pattern F[0] = 3; F[1] = 7; F[3] = 11; and DownValues[F] /. Verbatim[RuleDelayed][Verbatim[HoldPattern][F[a_]], b_] :> {a, b} Jens Assume we have a number of definitions associated with a symbol F, for > example: > F[0] = 3; > F[1] = 7; > F[3] = 11; What I need is an automated way to generate the list of definitions, > something like > In[1] := getdefs[F] > Out[1] = {{0,3},{1,7},{3,11}} Would you know how to write this function getdefs? I am having > trouble extracting any useful information from a call to Definition[F] > since it seems to wrap its output somehow. Roman. > === Subject: Re: finding all definitions matching a pattern Roman. === Subject: Re: finding all definitions matching a pattern Hi Roman, maybe there is a better way but this seems to work F[0] = 3; F[1] = 7; F[3] = 11; getdefs[func_] := Module[{args}, ({#[[1]] /. f_[func[args__]] -> args , #[[1, 1]]} &) /@DownValues[func]] getdefs[F] {{0, 3}, {1, 7}, {3, 11}} Assume we have a number of definitions associated with a symbol F, for > example: > F[0] = 3; > F[1] = 7; > F[3] = 11; What I need is an automated way to generate the list of definitions, > something like > In[1] := getdefs[F] > Out[1] = {{0,3},{1,7},{3,11}} Would you know how to write this function getdefs? I am having > trouble extracting any useful information from a call to Definition[F] > since it seems to wrap its output somehow. Roman. > === Subject: Re: finding all definitions matching a pattern Assume we have a number of definitions associated with a symbol F, for > example: > F[0] = 3; > F[1] = 7; > F[3] = 11; What I need is an automated way to generate the list of definitions, > something like > In[1] := getdefs[F] > Out[1] = {{0,3},{1,7},{3,11}} Would you know how to write this function getdefs? I am having > trouble extracting any useful information from a call to Definition[F] > since it seems to wrap its output somehow. Definition just gives a visual representation. What you are after is DownValues: f[0] = 3; f[1] = 7; f[3] = 11; In[21]:= DownValues[f] Out[21]= {HoldPattern[f[0]] :> 3, HoldPattern[f[1]] :> 7, HoldPattern[f[3]] :> 11} The format is more complicated since it can deal with all kind of definitions, not only the ones you have in mind. If you are sure that only definitions like the ones you mentioned are present, you could extract the list you want with e.g.: In[16]:= Transpose[{DownValues[f][[All, 1, 1, 1]], DownValues[f][[All, 2]]}] Out[16]= {{0, 3}, {1, 7}, {3, 11}} hth, albert === Subject: Re: Solve problem a1 /. Select[{{b1 -> -2, a1 -> -1}, {b1 -> 0.5, a1 -> 3}}, (a1 /. #) > 0 &] {3} Cases[{{b1 -> -2, a1 -> -1}, {b1 -> 0.5, a1 -> 3}}, (a1 -> x_ /; x > 0) :> x, Infinity] {3} Or instead of using Solve use Reduce and include constraint on a1 Bob Hanlon I have a Solve[...] which gives me solutions like {{b1 -> -2, a1 -> -1 }, {b1 -> 0.5, a1 -> 3}} or like {{a1 -> 1, b1 -> 3}} How can I get the positive value for a1, which is 3 in the first case and 1 in the second one? Bruno === Subject: Re: Solve problem > a1 /. Select[{{b1 -> -2, a1 -> -1}, {b1 -> 0.5, a1 -> 3}}, > (a1 /. #) > 0 &] {3} Cases[{{b1 -> -2, a1 -> -1}, {b1 -> 0.5, a1 -> 3}}, > (a1 -> x_ /; x > 0) :> x, Infinity] {3} Or instead of using Solve use Reduce and include constraint on a1 Ok Bob. such useful info. Bruno === Subject: Re: How do I hide all input in a Mathematica notebook? > Hi I am using Mathematica to prepare a report for my boss. It has lots > of tables and pie charts - the sort of things bosses love. It also > has a lot of Mathematica commands which scares the wossname out of > him. At the moment I am hiding the input cell by cell but this is a pain. > Is there a one click/one command solution? Mike www.walkingrandomly.com Mike, You might modify your notebook's stylesheet, with the following additional cell: Cell[StyleData[Input], CellOpen -> False] Vince Virgilio === Subject: Re: How do I hide all input in a Mathematica notebook? > Hi I am using Mathematica to prepare a report for my boss. It has lots > of tables and pie charts - the sort of things bosses love. It also > has a lot of Mathematica commands which scares the wossname out of > him. At the moment I am hiding the input cell by cell but this is a pain. > Is there a one click/one command solution? Mike www.walkingrandomly.com One thing you might want to look at is using Cell Grouping to group all of the things you want to hide in one such group and then hide/ show only that group depending on who you want to look at it. The difficulty lies in structuring the notebook so that is easy to do. Once cells are in a Group, you can double-click on any cell bracket in that Group at multiple levels and the other cells in the Group will be hidden or unhidden. I don't think it matters if a cell is an Input cell or a Text cell or any other type, so you can mix/match cell types in any group, and they do not have to be contiguous either, but if they aren't then some of the intervening cells not in the group will also be hidden. Play around with this Grouping (I think this is new as of version 6 so keep that in mind) and see if that helps. HTH... -Bob === Subject: Re: How do I hide all input in a Mathematica notebook? Here is an old trick that is probably not documented anymore: Alt-click (option-click on a Mac) a cell bracket will select all cell brackets of the same type. Alt-click on an input cell will select all input cells. Then you can use Cell > Cell Properties > Open to toggle the input cells between open and closed. Dangling problem is that although the cells are hidden, vertical space between the cells is not. This can leave large unexplained whitespace in your report. If anyone has a suggestion to get around this, please post. Daniel === Subject: Re: Detecting CD driver availability You might try with FileType[d:], which returns None if the CD is not inserted and Directory if it is. The problem is that, in my version 7.0.1.0 on Vista, the dialog pop-up has a strange behavior: if, from the file system window, I apply Eject twice, the pop-up window does not appear. If I apply Eject once (as normally expected) it appears. You could check if this is the same for XP. By the way, I do not know how to eject a CD programmatically from Mathematica. Such a command does not seem to be present ADL > Hi ! Unfortunately, it dosn't work. ... === Subject: Re: Detecting CD driver availability > By the way, I do not know how to eject a CD programmatically from > Mathematica. Such a command does not seem to be present On my PCs, under Windows XP, this works: Run[nircmd.exe cdrom close d:] Run[nircmd.exe cdrom open d:] NirCmd is a freeware utility you can get from http://www.nirsoft.net/utils/nircmd.html Saludos! === Subject: Re: Detecting CD driver availability Hi ! Unfortunately, it dosn't work. Here what happens on a PC running Windows XP Pro SP2 and Mathematica 7.0.0. We start having a void CD driver: DirectoryQ[d:] True (why ??) SetDirectory[d:] SetDirectory::cdir: Cannot set current directory to d:. >> $Failed Now I put a DVD into driver: SetDirectory[d:] d: ResetDirectory[] C:Docs The DVD is now removed so I get SetDirectory[d:] SetDirectory::cdir: Cannot set current directory to d:. >> $Failed and also the Abort, Retry, Cancel dialogs pops up; please note that during the first test it didn't. What I need is managing the absence of optical media without the human intervention on the dialogue box. Ignacio === Subject: Re: help^please >> The only way you could be faced with a requirement >> like that, is as a >> college exercise! If you get help to solve your >> exercises, that will >> leave you no more skilled than before - so there >> would not be any point, >> would there? True, but there are enough exercises around. The problem is that i have no teacher so sometimes things get on my nerves so to speak :) Now with the answers; at least i have an idea. The solutions could contain something totally beyond my imagination and this is where teachers come into play but as i said . . . no instructor nor a college education. > >> David Bailey >> http://www.dbaileyconsultancy.co.uk > Are you saying that this question just came out of the blue - that you were not given a course on the use of Mathematica, and access to the software to experiment! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Stylesheets and export to HTML I am struggling to export to HTML with Mathematica 7. The default behaviour of the old HTMLSave as implemented through the menu item 'Save Special as' was to produce a CSS file from the notebook stylesheet in the process (option CSS->Automatic). On Mathematica 5.2 you get a properly formatted HTML web page by using any of the stylesheets in Mathematica and also when using any personally created stylesheet. I cannot get Mathematica 7 to produce a corresponding CSS file when using the menu item Save As:Web page (or XHTML+MathML) with any included stylesheet except the Default one. So the web page thus produced has no formatting. Is this normal and where can I change the default behaviour to save a CSS file in the HTMLFolder folder when exporting to HTML ? A. Berkani === Subject: Two versions on the same system Good morning, Is it possible to run different versions of Mathematica on the same machine ? I noticed that there is only one user and one global folders where all preferences, etc. are stored. Aren't the preferences files for different versions likely to conflict or get corrupted ? A. Berkani === Subject: Re: Two versions on the same system > Good morning, Is it possible to run different versions of Mathematica on the same machine > ? I noticed that there is only one user and one global folders where all > preferences, etc. are stored. Aren't the preferences files for different > versions likely to conflict or get corrupted ? > A. Berkani Read the post from a couple of days ago about the same exact question. Was on Mar 25 it started and was by someone named Danielle. See either MathGroup at http://forums.wolfram.com/mathgroup/archive/2009/Mar/msg00907.html atica/browse_frm/thread/13b40440279e3b10?hl=en# -Bob === Subject: Re: Two versions on the same system Simply install each version into its own subdirectory works just fine. HTH ....Terry > Good morning, Is it possible to run different versions of Mathematica on the same machine > ? I noticed that there is only one user and one global folders where all > preferences, etc. are stored. Aren't the preferences files for different > versions likely to conflict or get corrupted ? > A. Berkani === Subject: Strange behaviour Good morning, I am seeing a strange behaviour in Mathematica 5.2 (on a Mac 10.5.6). Everything seems to be working fine, but when I try to get help for a command using the question mark: ?Plot the command takes ages to give the result as if the communication with the Kernel was problematic in this case. However, and this is very strange, if I move the cursor or press an arrow key while the application is busy (Processing... is displayed on the top of the notebook window), then immediately the output gets displayed. I don't remember if this behaviour was present when I upgraded to Leopard 10.5.6 because I didn't use Mathematica during that period. But I don't recall seeing it when I was using 10.5.2. Is this an incompatibility issue of version 5.2 with Leopard 10.5.6 or is there something corrupted in the preferences for the application on my machine ? A. Berkani === Subject: Re: pdf export problem I continue to have the problem using the direct Save As dialog to export to .pdf so perhaps there is some bug there, but at least I can avoid it. Interestingly, the problem is there for cells with text style, but the same cells changed to input or equation produce fine pdf. So... problem not completely solved, but sidestepped. -David === Subject: Re: pick out an element from list list = Range[5]; NestList[Rest[#] - First[#] &, list, Length[list] - 1] {{1, 2, 3, 4, 5}, {1, 2, 3, 4}, {1, 2, 3}, {1, 2}, {1}} David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ i have a list with n element.i want to pick out an element from the = list, and to deduct the element from all the other residual elements. This = process is the first step. i must apply all elements of the list, invariably. Namely, in conclusion, i will obtain n list with n-1 elements. now, i = will try to explain as numerically. let element number of the list be 2500. = and i am picking out the first element of the list. and i'm deducting the = first element from the residual elements of the list. and now, i have a list = with 2499 elements.after that, i'm passing the second element, and i'm = applying the same processes. =C4=B1 can't do this, can anyone help me??? === Subject: Re: pick out an element from list If L is your list (Delete[L, #1] - L[[#1]] & ) /@ Range[Length[L]] gives you the result. Example In[3]:= L = RandomInteger[100, {5}] Out[3]= {63, 59, 75, 17, 99} In[4]:= (Delete[L, #1] - L[[#1]] & ) /@ Range[Length[L]] Out[4]= {{-4, 12, -46, 36}, {4, 16, -42, 40}, {-12, -16, -58, 24}, {46, 42, 58, 82}, {-36, -40, -24, -82}} Adriano Pascoletti 2009/3/28 bahadir and to deduct the element from all the other residual elements. This proc= ess > is the first step. i must apply all elements of the list, invariably. > Namely, in conclusion, i will obtain n list with n-1 elements. now, i wil= l > try to explain as numerically. let element number of the list be 2500. an= d i > am picking out the first element of the list. and i'm deducting the first > element from the residual elements of the list. and now, i have a list wi= th > 2499 elements.after that, i'm passing the second element, and i'm applyin= g > the same processes. =FD can't do this, can anyone help me??? === Subject: pick out an element from list i have a list with n element.i want to pick out an element from the list, and to deduct the element from all the other residual elements. This process is the first step. i must apply all elements of the list, invariably. Namely, in conclusion, i will obtain n list with n-1 elements. now, i will try to explain as numerically. let element number of the list be 2500. and i am picking out the first element of the list. and i'm deducting the first element from the residual elements of the list. and now, i have a list with 2499 elements.after that, i'm passing the second element, and i'm applying the same processes. ı can't do this, can anyone help me??? === Subject: Re: pick out an element from list > i have a list with n element.i want to pick out an element from the list,= and to deduct the element from all the other residual elements. This proce= ss is the first step. i must apply all elements of the list, invariably. Na= mely, in conclusion, i will obtain n list with n-1 elements. now, i will tr= y to explain as numerically. let element number of the list be 2500. and i = am picking out the first element of the list. and i'm deducting the first e= lement from the residual elements of the list. and now, i have a list with = 2499 elements.after that, i'm passing the second element, and i'm applying = the same processes. =C4=B1 can't do this, can anyone help me??? I'm not sure if I follow but: v = RandomReal[{0, 1}, 10]; First@NestWhile[Rest[#] - First[#] &, v, Length[#] > 1 &] Which is same thing as: Take[v, -2].{-1, 1} === Subject: Re: pick out an element from list > i have a list with n element.i want to pick out an element from the list,= and to deduct the element from all the other residual elements. This proce= ss is the first step. i must apply all elements of the list, invariably. Na= mely, in conclusion, i will obtain n list with n-1 elements. now, i will tr= y to explain as numerically. let element number of the list be 2500. and i = am picking out the first element of the list. and i'm deducting the first e= lement from the residual elements of the list. and now, i have a list with = 2499 elements.after that, i'm passing the second element, and i'm applying = the same processes. =C4=B1 can't do this, can anyone help me??? The process simplifies. If the intial list is {a, b, c, d} then the first step gives {a, b-a, c-a, d-a}. The second step gives {a, b-a, (c-a)-(b-a), (d-a)-(b-a)} = {a, b-a, c-b, d-b}. Finally, the third step gives {a, b-a, c-b, (d-b)-(c-b)} = {a, b-a, c-b, d-c}. In[1]:= (#-Join[{0},Most@#]&) @ {a,b,c,d,e,f} Out[1]= {a, -a+b, -b+c, -c+d, -d+e, -e+f} === Subject: Re: rules on vector sequence >that have these three properties: >1- the entries have to be among -2,-1,0,1,2 >2- the sum of all the entries has to be 0 >3- only two or four of the entries can be different from 0 >do you have any suggestions on how i can do that? i tried something >but without success.. expecially i don't know how to implement the >third rule.. thank you in advance! Filippo Rule 1 lists 5 distinct values. So, each vector can be thought of as a N digit number base 5. And for N = 5, Range[5^4, 5^5 - 1] will be a list of all possible vectors of length 5 encoded as a number base 5. I can implement rule 3 as: test = Pick[Range[5^4, 5^5 - 1], Total[Unitize[IntegerDigits[#, 5] - 2]] & /@ Range[5^4, 5^5 - 1], 2 | 4]; IntegerDigits[value, 5] - 2 converts each encoded vector to the form specified by rule 1. Unitize sets each non-zero value to 1. And Pick chooses just those values with either 2 or 4 non-zero values. Rule 2 can be implemented as: Cases[test, _?(Total[IntegerDigits[#, 5]] == 10 &)] Here, I look for a total of 10 rather than 0 since the digits for base 5 numbers run from 0 to 4. There are a total of In[33]:= Length@Cases[test, _?(Total[IntegerDigits[#, 5]] == 10 &)] Out[33]= 180 vectors of length 5 meeting your conditions above. The first 5 are: In[35]:= (IntegerDigits[#, 5] - 2) & /@ Cases[test, _?(Total[IntegerDigits[#, 5]] == 10 &)][[;; 5]] Out[35]= {{-1, -2, 0, 1, 2}, {-1, -2, 0, 2, 1}, {-1, -2, 1, 0, 2}, {-1, -2, 1, 2, 0}, {-1, -2, 2, 0, 1}} I'll leave it to you to generalize the above for arbitrary length vectors. Also, note I've not tried to optimize any of this code. If N gets large, this code won't run all that fast as things like IntegerDigits are being done more than once for the same values. === Subject: Re: What's going on here (Table-generated lists)? >attribute and why Plot is doing what it's doing. >I fully understand why the HoldAll attribute is generally useful and >why it's used here, but I still don't see why it doesn't make sense >for Plot to recognize a list as an actual list and plot each with a >different color. Plot does this when the argument provided is a list, That is Plot[{x,x^2},{x,0,1}] will plot two curves in two different colors. But Plot[Table[x^n,{n,2}],{x,0,1}] will plot two curves with one color. >Shouldn't it be manually evaluating its argument, >then plotting with different colors if it ends up with a list? You start by saying you understand the HoldAll attribute, why it is useful and why Plot is doing what it is doing. Yet, you ask a question here that implies you don't understand these things. What answer are you looking for here? === Subject: Re: What's going on here (Table-generated lists)? It's not entirely unavoidable, but there are cases where it's almost so. For instance, Plot[x /. Solve[x^3 - x^2 + b x + 1 == 0, x], {b, -5, 5}] For different b values there are 1, 2, or 3 solutions. Colors COULD be assigned after the points are calculated, but what colors should be used, and where? Or look at the colors in the evaluated version: Plot[x /. Solve[x^3 - x^2 + b x + 1 == 0, x]//Evaluate, {b, -5, 5}] Bobby >I still don't see why it doesn't make sense >>for Plot to recognize a list as an actual list and plot each with a >>different color. >> Plot does this when the argument provided is a list, That is >> Plot[{x,x^2},{x,0,1}] >> will plot two curves in two different colors. But Plot[0.5{x,x^2}, {x,0,1}] will not plot two curves in two different colors -- right? -- > despite the fact that evaluating 0.5{x,x^2} by itself > displays as {0.5 x, 0.5 x^2} ); and Plot[{0.5x, 0.5x^2}, {x, 0, 1}] does plot two curves in two different colors > What answer are you looking for here? In my case (I'm not the OP), not an explanation of why this happens > (I've come to sort of understand this); but as purely curiosity > questions (since this behavior of Plot comes up time after time): 1) Is having this weird and confusing behavior in the Plot[] command > somehow necessary, unavoidable, for reasons deep in the fundamental > structure of Mathematica? -- or is this merely a bad design choice made > long ago, that one would wish could now be extirpated (but probably > can't be)? 2) Does Wolfram have any understanding of how much the string of > endless gotchas like this damage the usability of Mathematica for > ordinary users (as contrasted to full time professional programmers)? 3) Should maybe evaluating 0.5{x,x^2} by itself display as { {0.5 x, 0.5 x^2} } since that's what it really is? (Or should Plot[] maybe strip off the > outer { }'s if given this as the function to be plotted?) > -- DrMajorBob@bigfoot.com === Subject: Re: What's going on here (Table-generated lists)? >I still don't see why it doesn't make sense >for Plot to recognize a list as an actual list and plot each with a >different color. Plot does this when the argument provided is a list, That is Plot[{x,x^2},{x,0,1}] will plot two curves in two different colors. But Plot[0.5{x,x^2}, {x,0,1}] will not plot two curves in two different colors -- right? -- despite the fact that evaluating 0.5{x,x^2} by itself displays as {0.5 x, 0.5 x^2} ); and Plot[{0.5x, 0.5x^2}, {x, 0, 1}] does plot two curves in two different colors > What answer are you looking for here? In my case (I'm not the OP), not an explanation of why this happens (I've come to sort of understand this); but as purely curiosity questions (since this behavior of Plot comes up time after time): 1) Is having this weird and confusing behavior in the Plot[] command somehow necessary, unavoidable, for reasons deep in the fundamental structure of Mathematica? -- or is this merely a bad design choice made long ago, that one would wish could now be extirpated (but probably can't be)? 2) Does Wolfram have any understanding of how much the string of endless gotchas like this damage the usability of Mathematica for ordinary users (as contrasted to full time professional programmers)? 3) Should maybe evaluating 0.5{x,x^2} by itself display as { {0.5 x, 0.5 x^2} } since that's what it really is? (Or should Plot[] maybe strip off the outer { }'s if given this as the function to be plotted?) === Subject: Plots, Lists, and line colors (Was: What's going on here (Table-generated lists)?) So far we know that Plot[{x, x^2, x^3}, {x, 0, 1}] gives 3 default colors Plot[{{x, x^2, x^3}}, {x, 0, 1}] gives 3 default colors Plot[{x, x^2, x^3}, {x, 0, 1}, PlotStyle -> {Red, Green, Blue}] gives 3 designated colors Plot[Table[x^n, {n, 1, 3}], {x, 0, 1}, PlotStyle -> {Red, Green, Blue}] gives single color -- and it's NOT Red But if you Evaluate the table you get 3 designated colors Plot[0.8 {x, x^2, x^3}, {x, 0, 1}, PlotStyle -> {Red, Green, Blue}] gives single color, not Red Plot[List[x, x^2, x^3], {x, 0, 1}, PlotStyle -> {Red, Green, Blue}] gives 3 designated colors (meaning, List[] gets evaluated, even though Table didn't?) Plot[List[{x, x^2, x^3}], {x, 0, 1}, PlotStyle -> {Red, Green, Blue}] gives 3 designated colors (List in this variant form also gets evaluated?) QUIZ: What will the following give? Plot[0.5 List[{x, x^2, x^3}], {x, 0, 1}, PlotStyle -> {Red, Green,Blue}] Plot[List[0.5 {x, x^2, x^3}], {x, 0, 1}, PlotStyle -> {Red, Green, Blue}] === Subject: Re: Option instead of a function argument: is it possible? >1. Consider a function that solves a system of 2 ordinary >differential equations and draws a trajectory on the (x, y) plane: >trajectory1[eq1_, eq2_, point_, tmax_] := >Module[{s, eq3, eq4}, >eq3 = x[0] == point[[1]]; >eq4 = y[0] == point[[2]]; >s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}]; >ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, >PlotRange -> All]] >Equations can be fixed say, like these: >eq1 = x'[t] == -y[t] - x[t]^2; >eq2 = y'[t] == 2 x[t] - y[t]^3; >and initial conditions are passed by the parameter point. The >function can be called: >trajectory1[eq1, eq2, {1, 1}, 30] >2. Assume now that I need to specify the accuracy goal and MaxSteps >parameters. Then the function will take a slightly different form: trajectory3[eq1_, eq2_, point_, tmax_] >that can be addressed both as >trajectory3[eq1, eq2, {1, 1}, 30] >(if I agree with the default values of the AccuracyGoal and >MaxSteps) and as >trajectory3[eq1, eq2, {1, 1}, 30, AccuracyGoal->10, >MaxSteps->10000], >if a change in these options is necessary. Is it possible? Yes, rewriting your function as: trajectory1[eq1_, eq2_, point_, tmax_, opts___] := Module[{s, eq3, eq4}, eq3 = x[0] == point[[1]]; eq4 = y[0] == point[[2]]; s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, opts]; ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, PlotRange -> All]] will do the trick Even better would be to use the function FilterRules as: trajectory1[eq1_, eq2_, point_, tmax_, opts___] := Module[{s, eq3, eq4}, eq3 = x[0] == point[[1]]; eq4 = y[0] == point[[2]]; s = NDSolve[{eq1, eq2, eq3, eq4}, {x, y}, {t, tmax}, Sequence@@FilterR= ules[{opts},Options[NDSolve]]]; ParametricPlot[Evaluate[{x[t], y[t]} /. s], {t, 0, tmax}, PlotRange -> All]] Using FilerRules will prevent passing invalid options to NDSolve. Also, for more complex problems using FilterRules allows you to include options for other functions and pass only the appropriate options on to each function you have in the body of your code. Finally, I note you can alter the AccuracyGoal and MaxSteps without changing your original code. For example, doing SetOptions[NDSolve, AccuracyGoal->10] before evaluating your code will cause it to work with an AccuracyGoal of 10. === Subject: Re: UNDO and Mathematica - how useless is it? I think that some, at least, of the important WRI developers do take noti= > ce > of what is on MathGroup. So give detail and make a good case and I think > they will consider it. They may not necessarily do it because it may be > difficult, but there are a number of changes I've seen that did appear to > come from MathGroup complaints and suggestions. David Park > djmp...@comcast.nethttp://home.comcast.net/~djmpark/ I agree that the definition of what UNDO means can be problematic with > Mathematica, but if you talk about only the editing of the notebook > itself with regard to UNDO, then it becomes much easier, doesn't it?. > If we only talk about the editing changes of a notebook wouldn't the > UNDO be trivial to implement? For any sort of calculations just put in different data and re-execute > the notebook or cell. Part of each cell definition is a timestamp (look at the low-level > code by doing a Cell/Show Expression if you want to see). With this > information and some sort of keyboard input data structure going back > in time any number of levels would be just a question of undoing that > level of keyboard input and go back to the previous version of the > text wouldn't it, then a simple re-execution of the cell gets you back > where you were? It seems that because the problem is difficult to provide a perfect > solution, the currently worthless solution is any better? What would be bad about providing an UNDO that only worked on the > state of the text that forms the notebook or cell? That way any change > could be undone, and if needed then a simple re-execution of the cell/ > notebook would get the old calculation back. Yes, I realize what about > if the calculation took 4 days to complete, you surely dont want to > undo that if the result is truly valid, but perhaps a cell could be > marked as Don't Change with UNDO or something like that (just like > you can mark it as visible or editable or ???) Would this give people > all the ability of a multi-level undo without the possibility of > loosing valuable calculations?? Would someone at Wolfram PLEASE comment about the state of the UNDO > debate and what is and isn't possible and what the various problems > with certain solutions are??? -BOB A useful undo function is extremely helpful in bringing down the barrier for novices, because they will feel free to experiment without fear of breaking things. Maybe the following would be doable in Mathematica: for each _individual_ Input cell, keep track of a certain number of undo steps. The undo history could be reachable through some right-click menu bound to the individual cell bracket. Of course that's a lot of separate undo histories to keep track of, but one could limit the depth and provide a way to clear the history. The reason I'm proposing undo for individual Input cells is that these cells can then be rearranged arbitrarily, and there would be less potential for conflict with interactive output. Of course, NotebookWrite and other notebook manipulation features are a big stumbling block (for undo... otherwise they're great). Maybe one would have to restrict the cell history changes made by textual editing. A less ambitious proposal would be to at least implement a full undo history counting from the time a user first starts editing an input cell. In a large cell where I want to edit several places, even this modest undo would give me some peace of mind (OK, I've learned to live without undo by making backup copies of cells and notebooks, but it would be hard to deny that frustration with non-undoable typos is a constant feature of Mathematica). Jens === Subject: Re: UNDO and Mathematica - how useless is it? Yes, often the perfect is the enemy of the useful. I would think it would be enough to just undo text editing. I wouldn't even worry about the 4-day calculation. It is not that common, and if it is important to save it then the user could have saved it in a file. And if an UNDO changed the Input cell then maybe the calculation was no good anyway. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ It seems that because the problem is difficult to provide a perfect solution, the currently worthless solution is any better? What would be bad about providing an UNDO that only worked on the state of the text that forms the notebook or cell? That way any change could be undone, and if needed then a simple re-execution of the cell/ notebook would get the old calculation back. Yes, I realize what about if the calculation took 4 days to complete, you surely dont want to undo that if the result is truly valid, but perhaps a cell could be marked as Don't Change with UNDO or something like that (just like you can mark it as visible or editable or ???) Would this give people all the ability of a multi-level undo without the possibility of loosing valuable calculations?? -BOB === Subject: Re: UNDO and Mathematica - how useless is it? > I think that some, at least, of the important WRI developers do take noti= ce > of what is on MathGroup. So give detail and make a good case and I think > they will consider it. They may not necessarily do it because it may be > difficult, but there are a number of changes I've seen that did appear to > come from MathGroup complaints and suggestions. David Park > djmp...@comcast.nethttp://home.comcast.net/~djmpark/ > I agree that the definition of what UNDO means can be problematic with Mathematica, but if you talk about only the editing of the notebook itself with regard to UNDO, then it becomes much easier, doesn't it?. If we only talk about the editing changes of a notebook wouldn't the UNDO be trivial to implement? For any sort of calculations just put in different data and re-execute the notebook or cell. Part of each cell definition is a timestamp (look at the low-level code by doing a Cell/Show Expression if you want to see). With this information and some sort of keyboard input data structure going back in time any number of levels would be just a question of undoing that level of keyboard input and go back to the previous version of the text wouldn't it, then a simple re-execution of the cell gets you back where you were? It seems that because the problem is difficult to provide a perfect solution, the currently worthless solution is any better? What would be bad about providing an UNDO that only worked on the state of the text that forms the notebook or cell? That way any change could be undone, and if needed then a simple re-execution of the cell/ notebook would get the old calculation back. Yes, I realize what about if the calculation took 4 days to complete, you surely dont want to undo that if the result is truly valid, but perhaps a cell could be marked as Don't Change with UNDO or something like that (just like you can mark it as visible or editable or ???) Would this give people all the ability of a multi-level undo without the possibility of loosing valuable calculations?? Would someone at Wolfram PLEASE comment about the state of the UNDO debate and what is and isn't possible and what the various problems with certain solutions are??? -BOB === Subject: simpler way to get a particular banded matrix? The following command constructs a matrix (typically denoted M0, it arises in filter banks in general, in Burrus, Gopinath, & Guo intro to wavelets and wavelet transforms: a primer in particular). I'm sure there's a way to do this without typing out all 5 bands. Here's what i did: SparseArray[Band[{1,1}]->H,{6,6}]+ SparseArray[Band[{2,3}]->H,{6,6}]+ SparseArray[Band[{3,5}]->H,{6,6}]+ SparseArray[Band[{-2,-3},{1,1},{-1,-1}]->rH,{6,6}]+ SparseArray[Band[{-3,-5},{1,1},{-1,-1}]->rH,{6,6}] where H={h0,h1,h2,h3,h4,h5}; rH=Reverse[H]; I get what I want: h0 0 0 0 0 0 h2 h1 h0 0 0 0 h4 h3 h2 h1 h0 0 0 h5 h4 h3 h2 h1 0 0 0 h5 h4 h3 0 0 0 0 0 h5 Any easier ways to get this? TIA and vale, rip -- NB eddress is r i p 1 AT c o m c a s t DOT n e t === Subject: Re: simpler way to get a particular banded matrix? The following command constructs a matrix (typically denoted M0, it > arises in filter banks in general, in Burrus, Gopinath, & Guo intro to > wavelets and wavelet transforms: a primer in particular). I'm sure there's a way to do this without typing out all 5 bands. Here's > what i did: SparseArray[Band[{1,1}]->H,{6,6}]+ > SparseArray[Band[{2,3}]->H,{6,6}]+ > SparseArray[Band[{3,5}]->H,{6,6}]+ > SparseArray[Band[{-2,-3},{1,1},{-1,-1}]->rH,{6,6}]+ > SparseArray[Band[{-3,-5},{1,1},{-1,-1}]->rH,{6,6}] where H={h0,h1,h2,h3,h4,h5}; > rH=Reverse[H]; I get what I want: h0 0 0 0 0 0 > h2 h1 h0 0 0 0 > h4 h3 h2 h1 h0 0 > 0 h5 h4 h3 h2 h1 > 0 0 0 h5 h4 h3 > 0 0 0 0 0 h5 Any easier ways to get this? TIA and vale, > rip -- > NB eddress is r i p 1 AT c o m c a s t DOT n e t To error on the side of readability, I'd probably go with: mat[n_Integer] := With[ {vRow = Join[ ConstantArray[0, n - 1], Table[ToExpression[h <> ToString[i]], {i, n - 1, 0, -1}], ConstantArray[0, n - 1]] }, Table[Take[vRow, {2 n + 1, 3 n} - 2 i], {i, n}] ]; === Subject: Re: simpler way to get a particular banded matrix? The following command constructs a matrix (typically denoted M0, it > arises in filter banks in general, in Burrus, Gopinath, & Guo intro to > wavelets and wavelet transforms: a primer in particular). I'm sure there's a way to do this without typing out all 5 bands. Here's > what i did: SparseArray[Band[{1,1}]->H,{6,6}]+ > SparseArray[Band[{2,3}]->H,{6,6}]+ > SparseArray[Band[{3,5}]->H,{6,6}]+ > SparseArray[Band[{-2,-3},{1,1},{-1,-1}]->rH,{6,6}]+ > SparseArray[Band[{-3,-5},{1,1},{-1,-1}]->rH,{6,6}] where H={h0,h1,h2,h3,h4,h5}; > rH=Reverse[H]; I get what I want: h0 0 0 0 0 0 > h2 h1 h0 0 0 0 > h4 h3 h2 h1 h0 0 > 0 h5 h4 h3 h2 h1 > 0 0 0 h5 h4 h3 > 0 0 0 0 0 h5 Any easier ways to get this? TIA and vale, > rip -- > NB eddress is r i p 1 AT c o m c a s t DOT n e t To error on the side of readability, I'd probably go with: mat[n_Integer] := With[ > {vRow = Join[ > ConstantArray[0, n - 1], > Table[ToExpression[h <> ToString[i]], {i, n - 1, 0, -1}], > ConstantArray[0, n - 1]] > }, > Table[Take[vRow, {2 n + 1, 3 n} - 2 i], {i, n}] > ]; but I'll play with it. Vale, Rip -- NB eddress is r i p 1 AT c o m c a s t DOT n e t === Subject: Re: pick out an element from list list = {a, b, c, d}; n = 1; Drop[list - #, {n++}] & /@ list {{b - a, c - a, d - a}, {a - b, c - b, d - b}, {a - c, b - c, d - c}, {a - d, b - d, c - d}} Bob Hanlon > i have a list with n element.i want to pick out an element from the > list, and to deduct the element from all the other residual elements. > This process is the first step. i must apply all elements of the list, > invariably. Namely, in conclusion, i will obtain n list with n-1 > elements. now, i will try to explain as numerically. let element > number of the list be 2500. and i am picking out the first element of > the list. and i'm deducting the first element from the residual > elements of the list. and now, i have a list with 2499 elements.after > that, i'm passing the second element, and i'm applying the same > processes. =EF=BF=BD=EF=BF=BD can't do this, can anyone help me??? === Subject: Re: rules on vector sequence And if i'll need to tweak the rules now i know how it works! Filippo > a = Range[-2, 2]; n = 4; Select[Tuples[ > Table[a, {n}]], (Total[#] == > 0) && > ((n - Count[#, 0] == 2) || (n - Count[#, 0] == 4)) &] Bob Hanlon > I need to generate all the vectors, of a given length N, that have >> these three properties: >> 1- the entries have to be among -2,-1,0,1,2 >> 2- the sum of all the entries has to be 0 >> 3- only two or four of the entries can be different from 0 >> do you have any suggestions on how i can do that? i tried something >> but without success.. expecially i don't know how to implement the >> third rule.. >> thank you in advance! >> Filippo === Subject: Re: rules on vector sequence a = Range[-2, 2]; n = 4; Select[Tuples[ Table[a, {n}]], (Total[#] == 0) && ((n - Count[#, 0] == 2) || (n - Count[#, 0] == 4)) &] Bob Hanlon > I need to generate all the vectors, of a given length N, that have > these three properties: 1- the entries have to be among -2,-1,0,1,2 > 2- the sum of all the entries has to be 0 > 3- only two or four of the entries can be different from 0 do you have any suggestions on how i can do that? i tried something > but without success.. expecially i don't know how to implement the > third rule.. > thank you in advance! > Filippo === Subject: Re: Interpolation with Method->Spline Setting all first derivatives is not a requirement for *ordinary *interpolation. That is, if you use the example data that I gave, but leave out the Method->Spline, you get a polynomial interpolation with 0 derivative at the first endpoint, just as you'd expect. It is only with Spline that it seems not to work. It wouldn't make sense to require all derivatives to be specified. (This would render the interpolation less useful since we often don't know what the derivatives ought to be, and in such cases we'd like to leave the interpolation free to optimize other properties.) The problem of fitting a spline through points in an interval is ambiguous to the extent of two boundary conditions, one at each end of the interval. A frequent choice is to arbitrarily require the curvature at the endpoints to be 0--but another common choice is to specify some other derivative there, which is what I'd like to do. You have to set the first derivative value for ALL points in your > series. In other case Mathematica will ignor the third number for > first point. > I add random numbers as third element for your points (and reevaluate > interpolation each time after addition) and the interpolated data > curve was changed only when I set all points with derivative value. > All data must be with derivative or all without it. > John_V had written I upgraded to Mathematica 7.01 today so I could try the new Method->Spline option of the Interpolation function. I've experimented with it, and it appears to give the natural spline (second derivative = 0 at the data endpoints). I would like to specify the *first *derivative at the endpoints. It is possible to do this for splines outside of Mathematica (e.g., Numerical Recipes describes it), and Mathematica permits it for ordinary polynomial interpolation, so I tried using the same syntax. Here's an example: In[53]:= exampData = {{{0.}, 0., 0.}, {{0.5}, 0.00042}, {{1.}, 0.0013}, {{1.5}, 0.00614}, {{2.}, 0.026}, {{2.2}, 0.0622}, {{2.4}, 0.153}, {{2.6}, 0.188}} Out[53]= {{{0.}, 0., 0.}, {{0.5}, 0.00042}, {{1.}, 0.0013}, {{1.5}, 0.00614}, {{2.}, 0.026}, {{2.2}, 0.0622}, {{2.4}, 0.153}, {{2.6}, 0.188}} Notice that the first data input has an extra 0 after the function value to specify a 0 first derivative at x=0. This works for polynomial interpolation. However, for spline interpolation: In[54]:= f = Interpolation[exampData, Method -> Spline] Out[54]= InterpolatingFunction[] If you plot this (e.g., Plot[f[x], {x, 0, 1}] ) you'll see that f clearly has a negative slope at x=0. In[56]:= f[0.1] Out[56]= -0.0000687322 Unfortunately for me, f represents a physical quantity for which negative values are impossible (and cause mischief in later calculations). This was why I was trying to specify the 0 derivative at x=0: in hopes of making the spline behave itself near the endpoint so I could enjoy its other nice properties (minimum curvature) elsewhere. This is a new and not-yet-well-documented feature, so maybe there's a syntax or a workaround to do what I want. Does anyone know of one? John === Subject: Re: Interpolation with Method->Spline You have to set the first derivative value for ALL points in your series. In other case Mathematica will ignor the third number for first point. I add random numbers as third element for your points (and reevaluate interpolation each time after addition) and the interpolated data curve was changed only when I set all points with derivative value. All data must be with derivative or all without it. === Subject: irrational and real exponents Hello MathGroup: Originally I was confused also about imaginary exponents also but help cleared that up. Help for Power also has this sentence: For certain special arguments, Power automatically evaluates to exact values. Does this imply that for irrational and real exponents, they are truncated to rationals before they are evaluated? Roger Williams Franklin Laboratory === Subject: Re: irrational and real exponents Hi Roger, No, I would rather think at cases like e.g.: E^(Pi I), 0.1^0, 0.1^Infinity Daniel > Hello MathGroup: Originally I was confused also about imaginary exponents also but help > cleared that up. Help for Power also has this sentence: For certain special arguments, > Power automatically evaluates to exact values. Does this imply that for irrational and real exponents, they are > truncated to rationals before they are evaluated? > Roger Williams > Franklin Laboratory > === Subject: Re: irrational and real exponents One example is Exp[I Pi] -1 Bobby > Hello MathGroup: Originally I was confused also about imaginary exponents also but help > cleared that up. Help for Power also has this sentence: For certain special arguments, > Power automatically evaluates to exact values. Does this imply that for irrational and real exponents, they are > truncated to rationals before they are evaluated? > Roger Williams > Franklin Laboratory > -- DrMajorBob@bigfoot.com === Subject: Re: irrational and real exponents Mathematica will never truncate anything. This mean I^2 is evaluated to -1 and E^(-2 Pi I) is evaluated to 1 Jens > Hello MathGroup: Originally I was confused also about imaginary exponents also but help > cleared that up. Help for Power also has this sentence: For certain special arguments, > Power automatically evaluates to exact values. Does this imply that for irrational and real exponents, they are > truncated to rationals before they are evaluated? > Roger Williams > Franklin Laboratory > === Subject: Image Processing & 3D Graphics Question Hi Group: I have an image that I can Import into Mathematica Ver 7.0.0 as either a *.gif file or a *.bmp file. That is no problem. The image is circular in nature. Now what I want to do is to place this image on one side of a short cylinder that I've created that is a 3D graphics object and be able to rotate both together much like you would do with any 3D graphics object. An illustration of the final result would be to take a coin of some thickness, say a quarter, and be able to tilt the coin so that the tip of Washington's head would be furthest away from the viewpoint and yhe year closest to the viewpoint with the coin's edge showing. So it sounds like the first thing to do is to convert imported image into a 3D Graphics object, but I don't know how to do this (or even if it can be done from within Mathematica). Can the image be digitized and then displayed somehow in 3D? So does anybody have any ideas as to how to proceed? Any and all help is greatly appreciated. TIA .....Terry === Subject: Re: Image Processing & 3D Graphics Question Mathematica can't do texture mapping, but MathGL3d can. Jens > Hi Group: > I have an image that I can Import into Mathematica Ver 7.0.0 as either > a *.gif file or a *.bmp file. That is no problem. The image is > circular in nature. > Now what I want to do is to place this image on one side of a short > cylinder that I've created that is a 3D graphics object and be able to > rotate both together much like you would do with any 3D graphics object. An illustration of the final result would be to take a coin of some > thickness, say a quarter, and be able to tilt the coin so that the tip > of Washington's head would be furthest away from the viewpoint and yhe > year closest to the viewpoint with the coin's edge showing. So it > sounds like the first thing to do is to convert imported image into a 3D > Graphics object, but I don't know how to do this (or even if it can be > done from within Mathematica). Can the image be digitized and then > displayed somehow in 3D? So does anybody have any ideas as to how to > proceed? > Any and all help is greatly appreciated. TIA > .....Terry > === Subject: Default Lighting Colors and Positions Does anyone know how to find out the default lighting colors and positions? Say in the plot: p1=Graphics3D[Sphere[]] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Default Lighting Colors and Positions >Does anyone know how to find out the default lighting colors and positions? There isn't a way to extract this information with a Mathematica command, but I can give you the effective value as of version 6 and later. Lighting->Automatic for Graphics3D is Lighting->{ {Ambient,RGBColor[{0.312,0.188,0.4}]}, {Directional,RGBColor[{0.8,0.,0.}],ImageScaled[{2,0,2}]}, {Directional,RGBColor[{0.,0.8,0.}],ImageScaled[{2,2,2}]}, {Directional,RGBColor[{0.,0.,0.8}],ImageScaled[{0,2,2}]} } Lighting->Neutral for Graphics3D is Lighting->{ {Ambient,RGBColor[{.35,.35,.35}]}, {Directional,RGBColor[{.37,.37,.37}],ImageScaled[{2,0,2}]}, {Directional,RGBColor[{.37,.37,.37}],ImageScaled[{2,2,2}]}, {Directional,RGBColor[{.37,.37,.37}],ImageScaled[{0,2,2}]} } Chris Hill Wolfram Research === Subject: Re: Default Lighting Colors and Positions David, tutorial/LightingAndSurfaceProperties describes the positions and colors of the default lighting. > Does anyone know how to find out the default lighting colors and position= s? > Say in the plot: p1=Graphics3D[Sphere[]] David Park djmp...@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Default Lighting Colors and Positions for MathGL3d I have spend several hours to find out what values the FrontEnd use. With out success. Even the export or POVRay, VRML and other 3d formats what have lights and not only the geometry use different light sources and not the positions that Lighting->Neutral or Lighting->Automatic use. For MathGL3d, I have given up, and MathGL3d use the old < Version 6.0 positions. Jens > Does anyone know how to find out the default lighting colors and positions? > Say in the plot: p1=Graphics3D[Sphere[]] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: extracting points and projecting I would like to extract the points from the following ContourPlot g=ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 100] I can do this with pts = First@Cases[g, x_GraphicsComplex :> First[x]] Then I would like to map this list of points onto the Riemann sphere. The projection is performed through j1[x_, y_] := 2 x/(1 + x^2 + y^2)^2 j2[x_, y_] := 2 y/(1 + x^2 + y^2)^2 j3[x_, y_] := (-1 + x^2 + y^2)/(1 + x^2 + y^2) I need to generate a list of three dimensional points (j1[x,y], j2[x,y], j2[x,y]) from pts and plot them. I am unable to generate the list of three dimensional points. Any help is very much appreciated. Cristina === Subject: Re: extracting points and projecting How about: g = ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 100] pts = First@Cases[g, x_GraphicsComplex :> First[x]]; j1[x_, y_] := 2 x/(1 + x^2 + y^2)^2 j2[x_, y_] := 2 y/(1 + x^2 + y^2)^2 j3[x_, y_] := (-1 + x^2 + y^2)/(1 + x^2 + y^2) Timing[one = pts /. {x_, y_} :> {j1[x, y], j2[x, y], j3[x, y]};] {0.127167, Null} one // Dimensions {8146, 3} Graphics3D[Point@one] or Timing[two = Outer[#2 @@ #1 &, pts, {j1, j2, j3}, 1, 1];] {0.171188, Null} one == two True Bobby > I would like to extract the points from the following ContourPlot g=ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, > PlotPoints -> 100] I can do this with pts = First@Cases[g, x_GraphicsComplex :> First[x]] Then I would like to map this list of points onto the Riemann sphere. > The projection is performed through j1[x_, y_] := 2 x/(1 + x^2 + y^2)^2 > j2[x_, y_] := 2 y/(1 + x^2 + y^2)^2 > j3[x_, y_] := (-1 + x^2 + y^2)/(1 + x^2 + y^2) I need to generate a list of three dimensional points (j1[x,y], j2[x,y], > j2[x,y]) from pts and plot them. I am unable to generate the list of > three dimensional points. Any help is very much appreciated. Cristina > -- DrMajorBob@bigfoot.com === Subject: Re: extracting points and projecting The following code using the Presentations package will create the contours and map them to the Riemann sphere. The Riemann sphere even has a north pole, zero meridian and equator lightly marked (if you want). And tooltips from the 2D graphics are also transferred to the Riemann sphere. Needs[Presentations`Master`] Draw2D[ {arg0contours = ComplexCartesianContour[ Arg[Gamma[z]] == 0, {z, -10 - 10 I, 10 + 10 I}, ContourLabels -> Automatic, PlotPoints -> 20, MaxRecursion -> 4]}, Frame -> True, FrameLabel -> {Re, Im}, PlotLabel -> Row[{Abs@Gamma[z] == 0}], ImageSize -> 300] Draw3DItems[ {ColoredRiemannSphere[], arg0contours // Normal // StereographicMap}, ViewRiemann, ImageSize -> 300] A PDF file and notebook for this should appear at the following site: Peter Lindsay at the Mathematical Institute in the University of St Andrews [ www.mcs.st-and.ac.uk ] has kindly undertaken to maintain an archive that provides downloadable notebooks and PDF files for various Presentations solutions that have appeared on MathGroup. http://blackbook.mcs.st-and.ac.uk/~Peter/djmpark/html/ David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I would like to extract the points from the following ContourPlot g=ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 100] I can do this with pts = First@Cases[g, x_GraphicsComplex :> First[x]] Then I would like to map this list of points onto the Riemann sphere. The projection is performed through j1[x_, y_] := 2 x/(1 + x^2 + y^2)^2 j2[x_, y_] := 2 y/(1 + x^2 + y^2)^2 j3[x_, y_] := (-1 + x^2 + y^2)/(1 + x^2 + y^2) I need to generate a list of three dimensional points (j1[x,y], j2[x,y], j2[x,y]) from pts and plot them. I am unable to generate the list of three dimensional points. Any help is very much appreciated. Cristina === Subject: Re: extracting points and projecting g = ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 100]; j1[x_, y_] := 2 x/(1 + x^2 + y^2)^2 j2[x_, y_] := 2 y/(1 + x^2 + y^2)^2 j3[x_, y_] := (-1 + x^2 + y^2)/(1 + x^2 + y^2) toSphere[{x_, y_}] := {j1[x, y], j2[x, y], j3[x, y]} and Graphics3D[ g[[1]] /. GraphicsComplex[pnts_, more_, ___] :> GraphicsComplex[toSphere /@ pnts, more]] Jens > I would like to extract the points from the following ContourPlot g=ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 100] I can do this with pts = First@Cases[g, x_GraphicsComplex :> First[x]] Then I would like to map this list of points onto the Riemann sphere. The projection is performed through j1[x_, y_] := 2 x/(1 + x^2 + y^2)^2 > j2[x_, y_] := 2 y/(1 + x^2 + y^2)^2 > j3[x_, y_] := (-1 + x^2 + y^2)/(1 + x^2 + y^2) I need to generate a list of three dimensional points (j1[x,y], j2[x,y], j2[x,y]) from pts and plot them. I am unable to generate the list of three dimensional points. Any help is very much appreciated. Cristina > === Subject: Exporting a discrete Manipulate[] sequence? OK, I've got a nice Manipulate[] command set up with one of the variables running through a discrete sequence, and I want to export one complete cycle of the plots produced by running through that sequence into an external file (e.g., a QuickTime movie, or a PDF document) or an external folder (e.g., a sequence of image or PDF files). Possible to get this information back out into the real world, without either (a) manually stepping through the sequence and manually Exporting the graphic at each step, or (b) reprogramming the underlying expr into a separate animation or Export[] loop? === Subject: Re: Exporting a discrete Manipulate[] sequence? > OK, I've got a nice Manipulate[] command set up with one of the > variables running through a discrete sequence, and I want to export one > complete cycle of the plots produced by running through that sequence > into an external file (e.g., a QuickTime movie, or a PDF document) or an > external folder (e.g., a sequence of image or PDF files). Possible to get this information back out into the real world, without > either (a) manually stepping through the sequence and manually Exporting > the graphic at each step, or (b) reprogramming the underlying expr into > a separate animation or Export[] loop? I'm not sure how to export a series of plots directly from Manipulate but if you move your expression into a table command and gernerate a table of plots instead would require minimal work and make exporting them very easy === Subject: Re: Exporting a discrete Manipulate[] sequence? Export[test.avi, Manipulate[Plot[Sin[k x], {x, 0, 2 [Pi]}], {k, 1, 10, 1}]] > OK, I've got a nice Manipulate[] command set up with one of the > variables running through a discrete sequence, and I want to export one > complete cycle of the plots produced by running through that sequence > into an external file (e.g., a QuickTime movie, or a PDF document) or an > external folder (e.g., a sequence of image or PDF files). Possible to get this information back out into the real world, without > either (a) manually stepping through the sequence and manually Exporting > the graphic at each step, or (b) reprogramming the underlying expr into > a separate animation or Export[] loop? === Subject: Re: simpler way to get a particular banded matrix? H = {h0, h1, h2, h3, h4, h5}; rH = Reverse[H]; z = Table[0, {5}]; Take[#, -6] & /@ NestList[RotateRight[#, 2] &, Join[rH, z], 5] Table[Take[Join[z, rH, z], {13, 18} - 2 n], {n, 6}] Bob Hanlon The following command constructs a matrix (typically denoted M0, it arises in filter banks in general, in Burrus, Gopinath, & Guo intro to wavelets and wavelet transforms: a primer in particular). I'm sure there's a way to do this without typing out all 5 bands. Here's what i did: SparseArray[Band[{1,1}]->H,{6,6}]+ SparseArray[Band[{2,3}]->H,{6,6}]+ SparseArray[Band[{3,5}]->H,{6,6}]+ SparseArray[Band[{-2,-3},{1,1},{-1,-1}]->rH,{6,6}]+ SparseArray[Band[{-3,-5},{1,1},{-1,-1}]->rH,{6,6}] where H={h0,h1,h2,h3,h4,h5}; rH=Reverse[H]; I get what I want: h0 0 0 0 0 0 h2 h1 h0 0 0 0 h4 h3 h2 h1 h0 0 0 h5 h4 h3 h2 h1 0 0 0 h5 h4 h3 0 0 0 0 0 h5 Any easier ways to get this? TIA and vale, rip -- NB eddress is r i p 1 AT c o m c a s t DOT n e t === Subject: Re: simpler way to get a particular banded matrix? > H = {h0, h1, h2, h3, h4, h5}; > rH = Reverse[H]; > z = Table[0, {5}]; Take[#, -6] & /@ > NestList[RotateRight[#, 2] &, Join[rH, z], 5] Table[Take[Join[z, rH, z], {13, 18} - 2 n], {n, 6}] > Bob Hanlon This time let me thank you publicly, Bob. Having looked at your solution, I've used some of it [CapitalEth] rotating a larger h vector with zeroes in it. Vale, Rip The following command constructs a matrix (typically denoted M0, it > arises in filter banks in general, in Burrus, Gopinath, & Guo intro to > wavelets and wavelet transforms: a primer in particular). I'm sure there's a way to do this without typing out all 5 bands. Here's > what i did: SparseArray[Band[{1,1}]->H,{6,6}]+ > SparseArray[Band[{2,3}]->H,{6,6}]+ > SparseArray[Band[{3,5}]->H,{6,6}]+ > SparseArray[Band[{-2,-3},{1,1},{-1,-1}]->rH,{6,6}]+ > SparseArray[Band[{-3,-5},{1,1},{-1,-1}]->rH,{6,6}] where H={h0,h1,h2,h3,h4,h5}; > rH=Reverse[H]; I get what I want: h0 0 0 0 0 0 > h2 h1 h0 0 0 0 > h4 h3 h2 h1 h0 0 > 0 h5 h4 h3 h2 h1 > 0 0 0 h5 h4 h3 > 0 0 0 0 0 h5 Any easier ways to get this? TIA and vale, > rip -- NB eddress is r i p 1 AT c o m c a s t DOT n e t === Subject: Re: Histograms and Iterators - Beginner Question Histogram[ FinancialData[IBM, Volume, {{2009, 3, 1}, {2009, 3, 20}}, Value], BarOrigin -> Left] Sjoerd - Actually a histogram is what I am looking for. I have had no > problems generating the various other plots, but, a histogram of the > daily trading volume usually next to a plot of the daily closing > prices is a fairly standard financial chart. You are right that the > online documentation is excellent and I have been putting it to good > use. It does seem that there are a few gaps - but the FinanacialData > function seems to be fairly new so they haven't run through many of > the possible use scenarios yet. Raffy - What you suggested has gotten me one step closer, but it is > not exactly what I am trying to achieve. What you suggested produced a = > chart with a range of volumes on the X-Axis and the number of days in > which those volumes occurred on the y-axis. What I would like is the > volume level on the y-axis and days (time) to run along the x-axis. > Jon Begin forwarded message: > === > Subject: Re: Histograms and Iterators - Beginner Question > Hello everyone: > I am a new Mathematica user and have been teaching myself the program >> using real-world examples and reverse-engineering the code. This >> approach has worked well for the last few months since I began, but I >> have run into a roadblock and was hoping someone will help me out. > I am currently trying to import financial data and generate a >> histogram of the daily volume for a given security. Ultimately I am >> going to make this into a sparkline (very useful in my work). Use of >> the options to create the sparkline is clear. Where I am getting >> stuck = > is the importing and formatting of the data. I think setting up the >> iterators is my problem, but I have tried about every option and have >> not found the answer yet. > I have been using the default examples in the online documentation of > Histogram[Table[FinancialData[IBM,Volume,i],{i,March > Any suggestions, >> Jon To get the volume data: 2009}, Value]; Then just plot it: Histogram[volume] > === Subject: Re: Two versions on the same system >Is it possible to run different versions of Mathematica on the same >machine ? I noticed that there is only one user and one global >folders where all preferences, etc. are stored. Aren't the >preferences files for different versions likely to conflict or get >corrupted ? I've had no difficulty doing this with version 6 and version 7 on my Mac. Previously, I had done that with version 5 and version 6. For the case of version 5 and 6, I modified the init.m file in the Kernel directory to detect which version was being launched and load different things accordingly. For example, I had a function defined to return the path for the working notebook automatically loaded in version 5 which is replaced by NotebookDirectory in version 6 and 7. === Subject: Re: simpler way to get a particular banded matrix? >The following command constructs a matrix (typically denoted M0, it >arises in filter banks in general, in Burrus, Gopinath, & Guo intro >to wavelets and wavelet transforms: a primer in particular). >I'm sure there's a way to do this without typing out all 5 bands. >Here's what i did: >SparseArray[Band[{1,1}]->H,{6,6}]+ >SparseArray[Band[{2,3}]->H,{6,6}]+ >SparseArray[Band[{3,5}]->H,{6,6}]+ >SparseArray[Band[{-2,-3},{1,1},{-1,-1}]->rH,{6,6}]+ >SparseArray[Band[{-3,-5},{1,1},{-1,-1}]->rH,{6,6}] >where >H={h0,h1,h2,h3,h4,h5}; rH=Reverse[H]; >I get what I want: >h0 0 0 0 0 0 >h2 h1 h0 0 0 0 >h4 h3 h2 h1 h0 0 >0 h5 h4 h3 h2 h1 >0 0 0 h5 h4 h3 >0 0 0 0 0 h5 >Any easier ways to get this? You can include a list of bands rather than summing separate arrays with a single band specified. That is: In[17]:= s = SparseArray[Band[{1, 1}] -> H, {6, 6}] + SparseArray[Band[{2, 3}] -> H, {6, 6}] + SparseArray[Band[{3, 5}] -> H, {6, 6}] + SparseArray[Band[{-2, -3}, {1, 1}, {-1, -1}] -> rH, {6, 6}] + SparseArray[Band[{-3, -5}, {1, 1}, {-1, -1}] -> rH, {6, 6}]; In[18]:= s == SparseArray[{Band[{1, 1}] -> H, Band[{2, 3}] -> H[[;; 4]], Band[{3, 5}] -> H[[;; 2]], Band[{2, 1}] -> H[[3 ;;]], Band[{3, 1}] -> H[[5 ;;]]}] Out[18]= True Note, I've also omitted specifying the array dimensions since this is fixed by the main diagonal and I have specified the off main diagonal bands to use just the part of H needed which eliminates the warning messages your code generates. However, I still specified each of the bands. So, this may not satisfy your criteria for easier. === Subject: Re: simpler way to get a particular banded matrix? > >The following command constructs a matrix (typically denoted M0, it >arises in filter banks in general, in Burrus, Gopinath, & Guo intro >to wavelets and wavelet transforms: a primer in particular). > >I'm sure there's a way to do this without typing out all 5 bands. >Here's what i did: > >SparseArray[Band[{1,1}]->H,{6,6}]+ >SparseArray[Band[{2,3}]->H,{6,6}]+ >SparseArray[Band[{3,5}]->H,{6,6}]+ >SparseArray[Band[{-2,-3},{1,1},{-1,-1}]->rH,{6,6}]+ >SparseArray[Band[{-3,-5},{1,1},{-1,-1}]->rH,{6,6}] > >where > >H={h0,h1,h2,h3,h4,h5}; rH=Reverse[H]; > >I get what I want: > >h0 0 0 0 0 0 >h2 h1 h0 0 0 0 >h4 h3 h2 h1 h0 0 >0 h5 h4 h3 h2 h1 >0 0 0 h5 h4 h3 >0 0 0 0 0 h5 > >Any easier ways to get this? You can include a list of bands rather than summing separate > arrays with a single band specified. That is: In[17]:= s = > SparseArray[Band[{1, 1}] -> H, {6, 6}] + > SparseArray[Band[{2, 3}] -> H, {6, 6}] + > SparseArray[Band[{3, 5}] -> H, {6, 6}] + > SparseArray[Band[{-2, -3}, {1, 1}, {-1, -1}] -> rH, {6, 6}] + > SparseArray[Band[{-3, -5}, {1, 1}, {-1, -1}] -> rH, {6, 6}]; In[18]:= s == > SparseArray[{Band[{1, 1}] -> H, Band[{2, 3}] -> H[[;; 4]], > Band[{3, 5}] -> H[[;; 2]], Band[{2, 1}] -> H[[3 ;;]], > Band[{3, 1}] -> H[[5 ;;]]}] Out[18]= True Note, I've also omitted specifying the array dimensions since > this is fixed by the main diagonal and I have specified the off > main diagonal bands to use just the part of H needed which > eliminates the warning messages your code generates. However, I > still specified each of the bands. So, this may not satisfy your > criteria for easier. and you showed me how to do some things I didn't know. I appreciate this. Conceptually, I grok this matrix from its bands, rather than from its rows or columns. Vale, Rip -- NB eddress is r i p 1 AT c o m c a s t DOT n e t === Subject: Re: HoldAll for Integrate > Hi Tammo, what Integrate really does can only somebody from Wolfram explain. But it completely eludes me why the integration variable in Integrate is not localized. Maybe some can give a reason for this. > Hello Daniel, It does not make any sense to localize the integration variable inside Integrate because the result may contain the integration variable (in case of indefinite integrals). However, it might be argued that it is a bad idea to use the same syntax colouring for the integration variable that is used for localized variables (e.g. in Table), as this will make it impossible to tell from the colouring whether the variable has a value. === Subject: Re: HoldAll for Integrate here, the goal is not to compute the integral, but to understand a bit I hadn't tried using Trace, and for the indefinite integral it certainly explains the output 1000. Apparently, something in the code for Integrate has changed since 1996 and now (since it evaluated to 1000/3 then). However, I'm still curious about the output of the definite integral Integrate[ x^2, {x,0,1} ] There is no 'reasonable' way I can think of for this to yield the value 0. Tammo Jan Op 2009-03-27 11:34:56 +0100, zei Jens-Peer Kuska : compare > x = 10; > SetAttributes[Integrate, HoldAll]; Trace[Block[{x}, Integrate[x^2, x]]] with Trace[Integrate[x^2, x]] and you see, that x^2 is evaluated to 100 but > x is preserved, than 100 dx is computed to 100*x > and than x->10 is substituted again to give > 1000 Jens > >> The following commands yield unexpected output: >> >> x=10; >> Integrate[x^2, {x,0,1}] >> >> That is because Integrate does not have attributes HoldAll, so that the >> second command will be interpreted as Integrate[100, {10,0,1}] which is >> not a command that Integrate can work with (so a warning message is >> returned). >> >> However, I can add the attribute HoldAll to Integrate myself: >> >> SetAttributes[Integrate, HoldAll]; >> >> I'm not very sure what to expect when now trying the same experiment >> (the correct answer 1/3 would be nice), but the actual output surprised >> me: >> >> x=10; >> Integrate[x^2, {x,0,1}] >> >> Yields as output: 0 (without any warnings). Could anyone explain why I >> should have expected this result? >> >> On a side note, I found a similar in the Tech Support column of the >> Mathematica Journal Volume 6, Issue 2, by Carl Roy. He tried the >> integral without limits: >> >> x=10; >> SetAttributes[Integrate, HoldAll]; >> Integrate[x^2, x] >> >> In the journal, the output 1000/3 is mentioned, whereas in Mathematica >> 7.0.1 this outputs 1000. >> >> Again, does anyone understand this? === Subject: Re: HoldAll for Integrate AFAIK Integrate[] is C/C++ code of the Mathematica Kernel and only the CVS at Wolfram Reseach will know exacly what have changed since 1996. Jens here, the goal is not to compute the integral, but to understand a bit I hadn't tried using Trace, and for the indefinite integral it > certainly explains the output 1000. Apparently, something in the code > for Integrate has changed since 1996 and now (since it evaluated to > 1000/3 then). However, I'm still curious about the output of the definite integral > Integrate[ x^2, {x,0,1} ] > There is no 'reasonable' way I can think of for this to yield the value 0. Tammo Jan Op 2009-03-27 11:34:56 +0100, zei Jens-Peer Kuska > : > >> compare >> x = 10; >> SetAttributes[Integrate, HoldAll]; >> Trace[Block[{x}, Integrate[x^2, x]]] >> with >> Trace[Integrate[x^2, x]] >> and you see, that x^2 is evaluated to 100 but >> x is preserved, than 100 dx is computed to 100*x >> and than x->10 is substituted again to give >> 1000 >> Jens > The following commands yield unexpected output: x=10; > Integrate[x^2, {x,0,1}] That is because Integrate does not have attributes HoldAll, so that the > second command will be interpreted as Integrate[100, {10,0,1}] which is > not a command that Integrate can work with (so a warning message is > returned). However, I can add the attribute HoldAll to Integrate myself: SetAttributes[Integrate, HoldAll]; I'm not very sure what to expect when now trying the same experiment > (the correct answer 1/3 would be nice), but the actual output surprised > me: x=10; > Integrate[x^2, {x,0,1}] Yields as output: 0 (without any warnings). Could anyone explain why I > should have expected this result? On a side note, I found a similar in the Tech Support column of the > Mathematica Journal Volume 6, Issue 2, by Carl Roy. He tried the > integral without limits: x=10; > SetAttributes[Integrate, HoldAll]; > Integrate[x^2, x] In the journal, the output 1000/3 is mentioned, whereas in Mathematica > 7.0.1 this outputs 1000. Again, does anyone understand this? === Subject: Integrating package documentation with the documentation center Although the documentation center (DC) came with version 6.0, there is (to my knowledge) still no published method for fully integrating package documentation with this system (at least not without using the Wolfram Workbench). As part of work on my new DebugTrace package, I believe I have uncovered the interface mechanism - using commands from the undocumented DocumentationSearch` (!!) context. Using these commands, it is possible to create documentation which pops up when F1 is pressed inside one of your exported symbols, and which appears in searches done within the DC. I am not entirely sure if this information is publicly available elsewhere, but if it is not, I am happy to write it up and make it available to everyone. Please tell me if the knowledge is already available. Needless to say, the information will be at your own risk, and may well not expose all available functionality. Since the relevant functions are not within a private package, I assume WRI meant this to be a public interface! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Integrating package documentation with the documentation center > Although the documentation center (DC) came with version 6.0, there is > (to my knowledge) still no published method for fully integrating > package documentation with this system (at least not without using the > Wolfram Workbench). As part of work on my new DebugTrace package, I believe I have uncovered > the interface mechanism - using commands from the undocumented > DocumentationSearch` (!!) context. Using these commands, it is possible > to create documentation which pops up when F1 is pressed inside one of > your exported symbols, and which appears in searches done within the DC. I am not entirely sure if this information is publicly available > elsewhere, but if it is not, I am happy to write it up and make it > available to everyone. Please tell me if the knowledge is already availab= le. Needless to say, the information will be at your own risk, and may > well not expose all available functionality. Since the relevant > functions are not within a private package, I assume WRI meant this to > be a public interface! David Baileyhttp://www.dbaileyconsultancy.co.uk for the discovery and the work that it took to come up with what Wolfram neglected to. -Bob === Subject: Re: Importing data with comma as decimal separator I don't know [ at the moment ] but wouldn't it be simpler just to Find-Replace comma with stop in a text editor ? Peter 2009/3/30 Dom : > I would like to import two-column numerical data in which comma is > used as decimal separator. The first 12 lines of the file is header, > followed by two tab-separated columns of numbers. > How I can do this in Mathematica 6.0? -- Peter Lindsay === Subject: Re: Importing data with comma as decimal separator Hello Peter, looking for a more elegant way. Dom > I don't know [ at the moment ] but wouldn't it be simpler just to > Find-Replace comma with stop in a text editor ? Peter 2009/3/30 Dom : I would like to import two-column numerical data in which comma is > used as decimal separator. The first 12 lines of the file is header, > followed by two tab-separated columns of numbers. > How I can do this in Mathematica 6.0? -- > Peter Lindsay === Subject: Importing data with comma as decimal separator I would like to import two-column numerical data in which comma is used as decimal separator. The first 12 lines of the file is header, followed by two tab-separated columns of numbers. How I can do this in Mathematica 6.0? === Subject: Re: Importing data with comma as decimal separator Dom, something like Import[filename,TSV,NumberPoint->,] works fine for me most of the time. Yves > I would like to import two-column numerical data in which comma is > used as decimal separator. The first 12 lines of the file is header, > followed by two tab-separated columns of numbers. > How I can do this in Mathematica 6.0? > === Subject: Re: Importing data with comma as decimal separator Hi Dom, > I would like to import two-column numerical data in which comma is > used as decimal separator. The first 12 lines of the file is header, > followed by two tab-separated columns of numbers. > How I can do this in Mathematica 6.0? You can use Import. Something like the following sequence might work for you. idata = Import[Test.txt, Table]; (* import all the data as strings -- the default for *.txt *) sdata = Select[idata, UnsameQ[#[[1]], #] &] (* drop all header lines -- sdata = Drop[idata, {1, 12}] can also work *) ddata = StringReplace[#, {, -> .}] & /@ sdata (* replace our commas with decimal points *) ddata = Map[ToExpression, ddata] (* ... and convert everything to expressions -- reals *) Dave. === Subject: Re: Importing data with comma as decimal separator > I would like to import two-column numerical data in which comma is > used as decimal separator. The first 12 lines of the file is header, > followed by two tab-separated columns of numbers. > How I can do this in Mathematica 6.0? You might try something like this: str = OpenRead[testcomma.txt]; Read[str, {Record, Record, Record, Record, Record, Record, Record, Record, Record, Record, Record, Record}]; datac = ReadList[ str, {Number, Character, Number, Character, Number, Character, Number}]; Close[str]; For[j = 1, j < Length[datac] + 1, j++, { a = Part[datac[[j]], 1]; b = Part[datac[[j]], 3]; c = Part[datac[[j]], 5]; d = Part[datac[[j]], 7]; xx[j] = a + b/(10.^(StringLength[ToString[b]])), yy[j] = c + d/(10.^(StringLength[ToString[d]])); }] This assumes the data file has 12 records/lines to ignore, then an indeterminate amount of data records that have the form (the white space is a TAB character, ASCII 009) xxxx,yyyy xxxxxxx,yyy and you wanted the data to look like xxxx.yyyy xxxxxxx.yyy I am sure there are lots of ways to do this, so take this into consideration, when you get 10 different suggestions. HTH. -Bob === Subject: Function Navigator Notebook, a feature request I am wanting a way to add a search field at the top of Function Nav Notebook. Anyone have done this or can help me do this? I am not wanting to go the main docs but just to keep within the Function Nav === Subject: Grabbing the hierarchy of function names from Function Nav NB Hi all, Is there some way to grab all the function names but keeping the hierarchy of the listing and saving into a cell or text file? All I want is to browse related functions via a popup on notebook cell. === Subject: Interpolation -> segfault? I generated and saved the following interpolating function (and wrapper). Whenever I evaluate it, I immediately get a segfault in V7 and V6. Could someone let me know why this is, why the code that generated it doesn't segfault, and what I should do to avoid segfault issues in the future? fn = If[#1 > 0.1 && #1 < 10^2, (1/(#1 Log[10])) InterpolatingFunction[{{-1., 2.}}, {3, 3, 0, {136}, {4}, 0, 0, 0, 0}, {{-1., -0.75, -0.5, -0.25, -0.125, 0., 0.125, 0.15625, 0.1875, 0.21875, 0.234375, 0.25, 0.265625, 0.273438, 0.28125, 0.289063, 0.296875, 0.304688, 0.3125, 0.320313, 0.328125, 0.335938, 0.34375, 0.351563, 0.359375, 0.367188, 0.375, 0.382813, 0.390625, 0.398438, 0.40625, 0.414063, 0.421875, 0.429688, 0.4375, 0.445313, 0.453125, 0.460938, 0.46875, 0.476563, 0.484375, 0.492188, 0.5, 0.507813, 0.515625, 0.523438, 0.53125, 0.539063, 0.546875, 0.554688, 0.5625, 0.570313, 0.578125, 0.585938, 0.59375, 0.601563, 0.609375, 0.617188, 0.625, 0.632813, 0.640625, 0.648438, 0.65625, 0.664063, 0.671875, 0.679688, 0.6875, 0.695313, 0.703125, 0.710938, 0.71875, 0.726563, 0.734375, 0.742188, 0.75, 0.757813, 0.765625, 0.773438, 0.78125, 0.789063, 0.796875, 0.804688, 0.8125, 0.820313, 0.828125, 0.835938, 0.84375, 0.851563, 0.859375, 0.867188, 0.875, 0.882813, 0.890625, 0.898438, 0.90625, 0.914063, 0.921875, 0.929688, 0.9375, 0.945313, 0.953125, 0.960938, 0.96875, 0.976563, 0.984375, 0.992188, 1., 1.00781, 1.01563, 1.02344, 1.03125, 1.03906, 1.04688, 1.05469, 1.0625, 1.07031, 1.07813, 1.08594, 1.09375, 1.10156, 1.10938, 1.11719, 1.125, 1.13281, 1.14063, 1.14844, 1.15625, 1.17188, 1.1875, 1.20313, 1.21875, 1.23438, 1.25, 1.5, 1.75, 2.}}, {Developer`PackedArrayForm, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136}, {0., 0., 1.839556450000000*10^-316, 1.21549*10^-159, 2.31335*10^-101, 1.67253*10^-56, 4.5936*10^-25, 2.66022*10^-19, 2.23311*10^-14, 2.71726*10^-10, 1.4528*10^-8, 4.79291*10^-7, 9.75747*10^-6, 0.0000367374, 0.000122606, 0.000362738, 0.000951569, 0.00221421, 0.00457332, 0.00839564, 0.0137329, 0.0201077, 0.0265815, 0.0322166, 0.0367286, 0.0408717, 0.0462177, 0.0544092, 0.0663, 0.0813791, 0.0976722, 0.112228, 0.122235, 0.126523, 0.126732, 0.127295, 0.133834, 0.150431, 0.177017, 0.208434, 0.236308, 0.253376, 0.257998, 0.255774, 0.256824, 0.270362, 0.300085, 0.342984, 0.391402, 0.436275, 0.469696, 0.486402, 0.484727, 0.467353, 0.441479, 0.41775, 0.407822, 0.421313, 0.4633, 0.533418, 0.626979, 0.737778, 0.861279, 0.996289, 1.1438, 1.30339, 1.46955, 1.63063, 1.77232, 1.8848, 1.96966, 2.04154, 2.1219, 2.2277, 2.36187, 2.51091, 2.65028, 2.7539, 2.80324, 2.79347, 2.7351, 2.65062, 2.56727, 2.50909, 2.49206, 2.52399, 2.60708, 2.73955, 2.91432, 3.11604, 3.32016, 3.49681, 3.61939, 3.67374, 3.66173, 3.59611, 3.48923, 3.34377, 3.15256, 2.90785, 2.61315, 2.28878, 1.96732, 1.68224, 1.45678, 1.29843, 1.20019, 1.14535, 1.11267, 1.08029, 1.02917, 0.946603, 0.829484, 0.685201, 0.529164, 0.379515, 0.25137, 0.15301, 0.0852144, 0.0432423, 0.0199185, 0.00829953, 0.00311858, 0.00105388, 0.000319547, 0.0000867615, 0.0000210592, 8.81696*10^-7, 2.32524*10^-8, 3.8403*10^-10, 3.95627*10^-12, 2.53536*10^-14, 1.00878*10^-16, 1.67729*10^-83, 7.17379*10^-204, 0.}}, {Automatic}][Log[10, #1]], 0] &; === Subject: Re: Exporting a discrete Manipulate[] sequence? > OK, I've got a nice Manipulate[] command set up with one of the > variables running through a discrete sequence, and I want to export one > complete cycle of the plots produced by running through that sequence > into an external file (e.g., a QuickTime movie, or a PDF document) or an > external folder (ef.g., a sequence of image or PDF files). Possible to get this information back out into the real world, without > either (a) manually stepping through the sequence and manually Exporting > the graphic at each step, or (b) reprogramming the underlying expr into > a separate animation or Export[] loop? There's no super-convenient way to export a sequence of image files (aside from one of the methods you already mentioned), but you can export an animation in AVI or SWF (Flash) pretty easily. If the Manipulate only has the one variable and it's already in the discrete sequence you want, then you can just use Export as so... Export[/tmp/test.swf, ControllerManipulate[Plot[Sin[n x], {x, 0, 10}], {n, 1, 5, 1}]] The reason I use ControllerManipulate here is that it will produce an image which has no controls or panel of any sort, which I presume is what you want. But you can also Export as a Manipulate if you so choose. If the default Export doesn't do what you want, then you can make an explicit list of bookmarks to export through. By default, Mathematica will interpolate between the bookmarks, so we'll have to kill that, too... Export[c:temptest.swf, ControllerManipulate[Plot[Sin[n x], {x, 0, 10}], {n, 1, 5, 1}, InterpolationOrder -> 0, Bookmarks -> Map[# :> (n = #) &, Range[5] (* <- list of discrete values *)]]] This also makes for a more compact swf file, so you might prefer this method. If you have other variables you want to fix, you could assign them a fixed value on the right-hand side of the RuleDelayed. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Using manipulate in two cells in one note book crashes my computer. Hello Group. I'm having an awful time with this. I have 2 essentially same codes using manipulate. Only differences are the ODEs. When I have both of the cells open, the Mathematica goes crazy, with the cell brackets flashing as if it's evaluating both cells at the same time. Eventually it will crash or I have to stop it using Alt +. Is anyone else having the same problem? Here're the cells causing problems. cell 1 Manipulate[dsol=DSolve[{b''[t]==-k1 k2 b[t]-k1 b'[t], b[0]==b0, b'[0] ==bp0}, b[t], t]; Plot[Evaluate[b[t]/.dsol],{t, 0, 10},PlotRange-> All], {k1, 0.1, 10}, {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}] cell 2 Manipulate[dsol=DSolve[{k1 k2 b[t]==k1 b'[t]+b''[t], b[0]==b0, b'[0] ==bp0}, b[t], t]; Plot[Evaluate[b[t]/.dsol],{t, 0, 10},PlotRange-> All], {k1, 0.1, 10}, {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}] In two separate notebooks, these two cells cause no problems. In the same notebook, if one of the cells are closed (by double clicking on the cell bracket), they don't cause problems. It's only when the cells are both open, the mathematica goes crazy and crashes. Sean === Subject: Using manipulate in two cells in one note book crashes my computer. Hello Group. I'm having an awful time with this. I have 2 essentially same codes using manipulate. Only differences are the ODEs. When I have both of the cells open, the Mathematica goes crazy, with the cell brackets flashing as if it's evaluating both cells at the same time. Eventually it will crash or I have to stop it using Alt +. Is anyone else having the same problem? Here're the cells causing problems. cell 1 Manipulate[dsol=DSolve[{b''[t]==-k1 k2 b[t]-k1 b'[t], b[0]==b0, b'[0] ==bp0}, b[t], t]; Plot[Evaluate[b[t]/.dsol],{t, 0, 10},PlotRange-> All], {k1, 0.1, 10}, {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}] cell 2 Manipulate[dsol=DSolve[{k1 k2 b[t]==k1 b'[t]+b''[t], b[0]==b0, b'[0] ==bp0}, b[t], t]; Plot[Evaluate[b[t]/.dsol],{t, 0, 10},PlotRange-> All], {k1, 0.1, 10}, {k2, 0.1, 10}, {b0, 0.1, 10}, {bp0, 0.1, 10}] In two separate notebooks, these two cells cause no problems. In the same notebook, if one of the cells are closed (by double clicking on the cell bracket), they don't cause problems. It's only when the cells are both open, the mathematica goes crazy and crashes. Sean === Subject: Re: Two versions on the same system > Good morning, Is it possible to run different versions of Mathematica on the same > machine > ? I noticed that there is only one user and one global folders where all > preferences, etc. are stored. Aren't the preferences files for different > versions likely to conflict or get corrupted ? > A. Berkani Actually, they do a very good job of not getting corrupted or causing conflicts. This was considered in the design. And it means that you don't have to reinstall all of your applications at every new version release. In the matter of preferences, though, you can choose to fork the preferences on a per-version basis by using the Option Inspector to set the VersionedPreferences option to True at the global scope. This will force separate preferences files for every major version (but not the minor ones, like 7.0.0 vs. 7.0.1). John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: Importing data with comma as decimal separator >I would like to import two-column numerical data in which comma is >used as decimal separator. The first 12 lines of the file is header, >followed by two tab-separated columns of numbers. How I can do this This can be done in Mathematica as follows: data = ReadList[filename, String][[13;;]]; data = StringSplit[StringReplace[#, ,->.], t]&/@data; data = Map[ToExpression, data, {2}]; But, I think it is easier to replace the comma's with periods using a text editor than using Import to read the file into Mathematica. === Subject: Re: What's going on here (Table-generated lists)? >But >Plot[0.5{x,x^2}, {x,0,1}] >will not plot two curves in two different colors -- right? -- >despite the fact that evaluating 0.5{x,x^2} by itself >displays as {0.5 x, 0.5 x^2} ); Right, 0.5{x,x^2} is not a list until it is evaluated. Entering this by itself causes it to be evaluated to a list. But Plot has the attribute HoldAll which means it is not evaluated immediately. Consequently, only one color is used. >Plot[{0.5x, 0.5x^2}, {x, 0, 1}] >does plot two curves in two different colors Right. This is an explicit list for which Plot will use different colors for each member of the list. >>What answer are you looking for here? >In my case (I'm not the OP), not an explanation of why this happens >(I've come to sort of understand this); but as purely curiosity >questions (since this behavior of Plot comes up time after time): >1) Is having this weird and confusing behavior in the Plot[] >command somehow necessary, unavoidable, for reasons deep in the >fundamental structure of Mathematica? -- or is this merely a bad >design choice made long ago, that one would wish could now be >extirpated (but probably can't be)? It is a question of efficiency. For a simple expression such as 0.5{x,x^2} the time to evaluate this symbolically then substitute numbers is trivial. But it is not difficult to find examples where the time needed to evaluate the expression symbolically then substitute numbers is far greater than the time needed to substitute numbers and evaluate. It is also not difficult to find examples where just the opposite is true. There is no single process guaranteed to be the best in all cases. And note, there is no simple way to determine whether multiple values returned by an expression are the result of a multi-valued function to be plotted in one color of the results from a list of separate expressions to be plotted in more than one color without first evaluating the expression. And that requires execution time. Including this functionality into Plot would mean more time to create a given Plot. >2) Does Wolfram have any understanding of how much the string of >endless gotchas like this damage the usability of Mathematica for >ordinary users (as contrasted to full time professional >programmers)? You seem to think there is a solution that would avoid such issues. I definitely do not believe this to be the case. Nor do I accept your implication that a full time professional programmer is needed to avoid such issues. Many (if not all) of these gotchas are reasonably easy to understand with a bit of thought. In this particular case, how would you decide whether a set of values returned by an expression where from a multi-valued function to be plotted in a single color or values from members of a list to be plotted in different colors? In the case of Plot, the answer is simple. If the expression has Head == List, then it is to be plotted in multiple colors. Otherwise a single color is to be used. === Subject: DeleteCases Given this example list: {{0, 0, 1, 1}, {0, 0, 2, 2}, {0, 0, 3, 3}, {1, 1, 0, 0}, {1, 1, 2, 2}, {1, 1, 3, 3}, {2, 2, 0, 0}, {2, 2, 1, 1}, {2, 2, 3, 3}, {3, 3, 0, 0}, {3, 3, 1, 1}, {3, 3, 2, 2}} I need the elements {a,a,b,b} and {b,b,a,a} to be the same, i.e. i want to delete one of the two occurrences from the list. (or all but one if the condition is more complicated, say {a,b,c,d} and {b,a,c,d} or {a,b,c,d} and {a,b,d,c}) How can i do that? Can i use DeleteCases? if so, what conditional should I use to compare different elements in the list? Filippo === Subject: Graphics and DisplayFunction Does anyone know why the following code fails to return the second Graphics object? ListPlot[{1, 2, 3}, DisplayFunction -> Print]; Graphics[{Circle[]}, DisplayFunction -> Print]; Even the coloring of the syntax differs for the two: after ListPlot [...], the semicolon is red indicating its unnecessary presence, while the one after Graphics[...] is left black. I would think that with the generalized input of Mathematica 6, the two would behave the same way, but apparently they do not. I know how to solve this with Show. I just simply don't understand why these two behave differently, if both produce (without specifying DisplayFunction) Graphics objects: In[104]:= Print[InputForm[ListPlot[{1, 2, 3}]]]; Print[InputForm[Graphics[{Circle[]}]]]; During evaluation of In[104]:= Graphics[{Hue[0.67, 0.6, 0.6], Point [{{1., 1.}, {2., 2.}, {3., 3.}}]}, {AspectRatio -> GoldenRatio^(-1), Axes -> True, AxesOrigin -> {0, Automatic}, PlotRange -> Automatic, PlotRangeClipping -> True}] During evaluation of In[104]:= Graphics[{Circle[{0, 0}]}] In[106]:= Head[ListPlot[{1, 2, 3}]] Head[Graphics[{Circle[]}]] Out[106]= Graphics Out[107]= Graphics Any idea? === Subject: Re: pdf export problem > A couple of things: > [1] For obvious reasons, transparency doesn't work well, but if you > save using the bitmap that will solve that problem. Perhaps these reasons are less obvious than you think. Transparent graphics export to PDF fine for me. Could you explain what you mean by this? > Wolfram, you have a bug - IMHO. Because the problem does not occur in > both types of Cells (Input and Text), I sure would guess the problem > is Mathematica's and not a PDF/Adobe problem. Please make sure to report any issues you believe to be bugs to Wolfram Research . As has been stated repeatedly on this forum, a mention here is not sufficient to ensure the issue is tracked and fixed. -Rob === Subject: Re: pdf export problem HI David the secret is as follows [ mac ]: File Print PDF Save as PDF Peter === Subject: Re: pdf export problem > Hello All- I have been having problems exporting notebooks to pdf and was hoping > someone might have some insight. I submitted a support request to > Wolfram, but have not heard back. Quick background: Mathematica 7.0.0; Macintosh Front End (OS X Leopard= 10.5.6). Quick summary: I am writing handouts for distribution in a math/ > stats class. Some characters disappear when converting to pdf. > Example that has been vexing me lately is the less-than-or-equal-to > sign (unicode character 2264, I think). I just get blank spaces in > its place. My theories (obviously wrong or I wouldn't be here asking!): I > thought it was a problem with font installations, but I have tried > different fonts without success. I also have noted that the problem = > occurs when the cells are text style, but goes away if I make the > cell equation style. I can't decide if there is a problem in the > style definitions, a bug that improperly defines fonts (and/or misses > embedding) into pdf, or something to do with high unicode characters. Apologies if my perusal of the archives has missed another discussion > help. I thought such font problems were well in my past, but no such = > luck. > David David Elbert > Department of Earth and Planetary Sciences & > Environmental Science and Policy Program > Johns Hopkins University > 3400 N. Charles St > Baltimore, MD 21218 elb...@jhu.edu David, Well I can see your problem now. The difference from what I did and what you did (and this is a guess), is that I created my test cells with the less than as an Input cell and then changed the style to Text. So I created another test case with the cell being created as a Text cell initially, and sure enough it shows the problem. So two workarounds are available: 1. Create your cells as Input and convert them to Text with the Format/ Style/Text command 2. Use another type of less than, e.g. LessSlantEqual which does not seem to have the same problem. Wolfram, you have a bug - IMHO. Because the problem does not occur in both types of Cells (Input and Text), I sure would guess the problem is Mathematica's and not a PDF/Adobe problem. -Bob === Subject: Re: pdf export problem Hi David: Not much in the way of help here, but moral support. I, too, have had problems exporting notebooks to PDFs with Mathematica (both 6 and 7). A couple of things: [1] For obvious reasons, transparency doesn't work well, but if you save using the bitmap that will solve that problem. [2] I've contacted Mathematica about the font mappings. Even The Mathematica Journal doesn't print/export correctly for me. For some reason it always wants to use Courier, for everything but Times, despite having verified that all other fonts installed correctly. Some workarounds, File -> Printing Options -> Working might help. Weird thing is, if I use working, as opposed to printout, the fonts map properly, but figures wind up being cut off and the text wrap doesn't work so well. You also may want to go into the Options Inspector and hardcode the PageMargins for the Printout option (compared to Working). When I get home from work this evening I will post the actual numbers and option names you can try as provided by Wolfram. Hope that helps. If I find anything else that works, I will be sure to post. t. PS - I use a Linux computer (Kubuntu 8.04), and you? > Hello All- I have been having problems exporting notebooks to pdf and was hoping > someone might have some insight. I submitted a support request to > Wolfram, but have not heard back. Quick background: Mathematica 7.0.0; Macintosh Front End (OS X Leopard= 10.5.6). Quick summary: I am writing handouts for distribution in a math/ > stats class. Some characters disappear when converting to pdf. > Example that has been vexing me lately is the less-than-or-equal-to > sign (unicode character 2264, I think). I just get blank spaces in > its place. My theories (obviously wrong or I wouldn't be here asking!): I > thought it was a problem with font installations, but I have tried > different fonts without success. I also have noted that the problem = > occurs when the cells are text style, but goes away if I make the > cell equation style. I can't decide if there is a problem in the > style definitions, a bug that improperly defines fonts (and/or misses > embedding) into pdf, or something to do with high unicode characters. Apologies if my perusal of the archives has missed another discussion > help. I thought such font problems were well in my past, but no such = > luck. > David David Elbert > Department of Earth and Planetary Sciences & > Environmental Science and Policy Program > Johns Hopkins University > 3400 N. Charles St > Baltimore, MD 21218 elb...@jhu.edu === Subject: Re: pdf export problem Here is some more advice. A snippet from Wolfram.... For example, in the TMJ stylesheet, you can edit the Working style to understand printing margins by adding the following options to the section Style Environment Names -> Working: (use Ctrl-Shift-e to open the section) PageWidth->PaperWidth, PrintingOptions->{PageSize->{490, 720}, PrintingMargins->{{0, 0}, {82, 56}}}, If you are working on a custom stylesheet, you can copy the Style Enviornment Names section out of Core.nb, paste it into your stylesheet, and make the changes there. Adding these options and setting the Printing Environment to Working will allow you to make PDFs that more closely match what you see on the screen. t. === Subject: Re: pdf export problem > Hi David: Not much in the way of help here, but moral support. I, too, have had > problems exporting notebooks to PDFs with Mathematica (both 6 and 7). Used to be a gotcha in exporting graphics with added Labels to PDF. The labels created by the Label command showed up fine in the notebook output cell viewed on screen, but appeared in the exported PDF file enclosed in unwanted double quotes (My Label). There was some arcane option you had to set to present this; don't know what the present situation may be. Also, in certain graphics plots exported as PDFs and then opened with some (but not all) Adobe apps, certain lines would appear enormously thickened. Selecting the lines in Illustrator and resetting their thickness would cure the situation. Never resolved, at least so far as I know, whether this was a Wolfram or Adobe problem. === Subject: Re: pdf export problem can you send me an example a notebook you are having problems with. We use macs so may be able to help. Peter 2009/3/27 David Elbert someone might have some insight. I submitted a support request to > Wolfram, but have not heard back. Quick background: Mathematica 7.0.0; Macintosh Front End (OS X Leopard > 10.5.6). Quick summary: I am writing handouts for distribution in a math/ > stats class. Some characters disappear when converting to pdf. > Example that has been vexing me lately is the less-than-or-equal-to > sign (unicode character 2264, I think). I just get blank spaces in > its place. My theories (obviously wrong or I wouldn't be here asking!): I > thought it was a problem with font installations, but I have tried > different fonts without success. I also have noted that the problem > occurs when the cells are text style, but goes away if I make the > cell equation style. I can't decide if there is a problem in the > style definitions, a bug that improperly defines fonts (and/or misses > embedding) into pdf, or something to do with high unicode characters. Apologies if my perusal of the archives has missed another discussion > help. I thought such font problems were well in my past, but no such > luck. > David > David Elbert > Department of Earth and Planetary Sciences & > Environmental Science and Policy Program > Johns Hopkins University > 3400 N. Charles St > Baltimore, MD 21218 elbert@jhu.edu -- Peter Lindsay === Subject: Palette Tutorial/training help Hi all, I am a disabled person who has trouble with typing. So I really use/ need the palette tools a lot. Although the classroom assistant palette provides a great deal helping me, it needs to be redesigned some for my needs. I had tried tearing it apart but its way too complex to do so. All I am wanting to do is rearrange buttons and panels, and adding a few new buttons. I would be glad to create a picture mock up of the changes for anyone wanting to help me. I live on very limited income so I can't really pay for hire (M7 Home Edition is a belated 50th birthday gift from family/friends). However, if someone created an in depth tutorial how to create/edit palettes than I would gladly roll my own to meet my needs. Yes, I have studied the docs on palettes in M7, and about to work through docs in M6 as suggested to me. But often the docs do not provide enough info to help me. Or, any links to sites that have that level of tutorial. Maybe someone from the User-Interface group at WRI would like to contact me? === Subject: listing related functions via autocompletion, feature request I find very helpful the function name completion button on the Classroom Assistant palette. However, I would to add some how via the hierarchy of the function Nav notebook a popup listing of related functions/options. This would aid in learning better Mathematica and deeper math too. Has anyone done this? Care to share code to do this? === Subject: Re: extracting points and projecting g = ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 100] pts = First@Cases[g, x_GraphicsComplex :> First[x]]; j1[x_, y_] := 2 x/(1 + x^2 + y^2)^2; j2[x_, y_] := 2 y/(1 + x^2 + y^2)^2; j3[x_, y_] := (-1 + x^2 + y^2)/(1 + x^2 + y^2); {j1[##], j2[##], j3[##]} & @@@ {{x1, y1}, {x2, y2}, {x3, y3}} {{(2*x1)/(x1^2 + y1^2 + 1)^2, (2*y1)/(x1^2 + y1^2 + 1)^2, (x1^2 + y1^2 - 1)/ (x1^2 + y1^2 + 1)}, {(2*x2)/(x2^2 + y2^2 + 1)^2, (2*y2)/(x2^2 + y2^2 + 1)^2, (x2^2 + y2^2 - 1)/ (x2^2 + y2^2 + 1)}, {(2*x3)/(x3^2 + y3^2 + 1)^2, (2*y3)/(x3^2 + y3^2 + 1)^2, (x3^2 + y3^2 - 1)/ (x3^2 + y3^2 + 1)}} pts3D = {j1[##], j2[##], j3[##]} & @@@ pts; ListPointPlot3D[pts3D, PlotRange -> Full, ImageSize -> 600] Bob Hanlon I would like to extract the points from the following ContourPlot g=ContourPlot[Arg[Gamma[x + I*y]] == 0, {x, -10, 10}, {y, -10, 10}, PlotPoints -> 100] I can do this with pts = First@Cases[g, x_GraphicsComplex :> First[x]] Then I would like to map this list of points onto the Riemann sphere. The projection is performed through j1[x_, y_] := 2 x/(1 + x^2 + y^2)^2 j2[x_, y_] := 2 y/(1 + x^2 + y^2)^2 j3[x_, y_] := (-1 + x^2 + y^2)/(1 + x^2 + y^2) I need to generate a list of three dimensional points (j1[x,y], j2[x,y], j2[x,y]) from pts and plot them. I am unable to generate the list of three dimensional points. Any help is very much appreciated. Cristina === Subject: Re: Using manipulate in two cells in one note book crashes my computer. By the way, I'm using Mathematica 7.0.0. Windows vista home edition. 32 bit. I also recently updated to Java runtime 6.0 and I had some problems with Mathematica help crashing. So I uninstalled and reinstalled the Mathematica. Also have Mathematica 6.0 installed. (This problem persists in Mathematica 6 also ) I also have another CAS system and other stuff installed on here, but not sure if any of that is an issue.