A129 === Subject: Re: Flipping axes on Graphics I am looking for a way to flip the direction of an axis that is used > to render a Graphics object. For example, I would like to be able to do Plot[Sin[x], {x, 0, 2*Pi}] > but the top-left corner of the rendered Graphics object would > correspond to coordinate (0,-1) while the bottom-left corner would > correspond to (0, +1); effectively, the graph would need to be > mirrored in the x-axis. I've skimmed all Graphics options and it seems the convention that > increasing x is rendered left-to-right and increasing y is rendered > bottom-to-top is hard-wired into Graphics. Would there be a clever way > to get around this? > Just flip the function, then relabel the axes. Here's an example: f[x_] := Sin[x] + x^2/10 Plot[f[x], {x, -5, 5}] gr = Plot[f[-x], {x, -5, 5}] invertXTicks[gr_Graphics] := Module[{xticks, yticks}, {xticks, yticks} = FullOptions[gr, Ticks]; {Replace[ xticks, {position_, label_Real, rest__} :> {position, -label, rest}, {1}], yticks} ] Show[gr, Ticks -> invertXTicks[gr]] === Subject: Re: Flipping axes on Graphics Again, I use the Presentations package so I can use the CustomTicks routine to easily obtain major and minor ticks. We use the Mathematica Rescale function to do the actual flipping. Needs[Presentations`Master`] yticks = CustomTicks[Rescale[#, {-1, 1}, {1, -1}] &, {-1., 1., .5, 5}]; Draw2D[ {Draw[Rescale[Sin[x], {-1, 1}, {1, -1}], {x, 0, 2 [Pi]}]}, AspectRatio -> 1/GoldenRatio, Axes -> True, Ticks -> {Automatic, yticks}] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I am looking for a way to flip the direction of an axis that is used to render a Graphics object. For example, I would like to be able to do Plot[Sin[x], {x, 0, 2*Pi}] but the top-left corner of the rendered Graphics object would correspond to coordinate (0,-1) while the bottom-left corner would correspond to (0, +1); effectively, the graph would need to be mirrored in the x-axis. I've skimmed all Graphics options and it seems the convention that increasing x is rendered left-to-right and increasing y is rendered bottom-to-top is hard-wired into Graphics. Would there be a clever way to get around this? === Subject: Re: Slicing a surface James === Subject: max. value in a plot? Hallo, i have 2 small questions. how can i find the max. Value of the following Plot? Plot3D[ (6*15*(10^-6))/((x - 0)^2 + (y - 0)^2 + (0 - 0.005)^2), {x, -0.05, 0.05}, {y, -0.05, 0.05}] and how can i plot the range ONLY from the min to the max value? === Subject: Re: max. value in a plot? MaxValue[( 6*15*(10^-6))/((x - 0)^2 + (y - 0)^2 + (0 - 0.005)^2), {x, y}] You can use the PlotRange option to restrict plotting to a certain range. > Hallo, > i have 2 small questions. how can i find the max. Value of the following lot? Plot3D[ > (6*15*(10^-6))/((x - 0)^2 + (y - 0)^2 + (0 - 0.005)^2), {x, -0.05, 0.05}, {y, -0.05, 0.05}] and how can i plot the range ONLY from the min to the max value? === Subject: Re: max. value in a plot? Maximize the value of what? x, y, or z? In what currency? Bobby > Hallo, > i have 2 small questions. how can i find the max. Value of the following > Plot? Plot3D[ > (6*15*(10^-6))/((x - 0)^2 + (y - 0)^2 + (0 - 0.005)^2), > {x, -0.05, 0.05}, {y, -0.05, 0.05}] and how can i plot the range ONLY from the min to the max value? > -- DrMajorBob@bigfoot.com === Subject: Re: max. value in a plot? {gr, vals} = Reap[Plot3D[ With[{v = (6*15*(10^-6))/((x - 0)^2 + (y - 0)^2 + (0 - 0.005)^2)}, Sow[v]; v], {x, -0.05, 0.05}, {y, -0.05, 0.05}]]; Show[gr, PlotLabel -> Max[vals]] Jens > Hallo, > i have 2 small questions. how can i find the max. Value of the following Plot? Plot3D[ > (6*15*(10^-6))/((x - 0)^2 + (y - 0)^2 + (0 - 0.005)^2), > > {x, -0.05, 0.05}, {y, -0.05, 0.05}] and how can i plot the range ONLY from the min to the max value? > === Subject: Re: max. value in a plot? f[x_, y_] = (6 15)/(10^6 ((x + 0)^2 + (y + 0)^2 + (0 - 0.005)^2)) Maximize[{f[x, y], -0.05 <= x <= 0.05, -0.05 <= y <= 0.05}, {x, y}] // Chop {3.6, {x -> 0, y -> 0}} Minimize[{f[x, y], -0.05 <= x <= 0.05, -0.05 <= y <= 0.05}, {x, y}] // Chop {0.0179104, {x -> 0.05, y -> 0.05}} Plot3D[f[x, y], {x, -0.05, 0.05}, {y, -0.05, {0.05}}, PlotRange -> {0.0179104, 3.6}] David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hallo, i have 2 small questions. how can i find the max. Value of the following Plot? Plot3D[ (6*15*(10^-6))/((x - 0)^2 + (y - 0)^2 + (0 - 0.005)^2), {x, -0.05, 0.05}, {y, -0.05, 0.05}] and how can i plot the range ONLY from the min to the max value? === Subject: Re: max. value in a plot? > Hallo, > i have 2 small questions. how can i find the max. Value of the following Plot? Plot3D[ > (6*15*(10^-6))/((x - 0)^2 + (y - 0)^2 + (0 - 0.005)^2), > > {x, -0.05, 0.05}, {y, -0.05, 0.05}] and how can i plot the range ONLY from the min to the max value? > If you only need the min/max values for plotting, simply use the PlotRange -> All option. If you do need to use the numerical values of the minimum/maximum, use the MaxValue and MinValue functions (NMaxValue if necessary). If you have an older version than 7, use Experimental`Supremum or Experimental`Infimum I hope this helps, Szabolcs === Subject: Re: General form of a summation as a function of 2 Sum[k/n, {k, 0, n}] (n + 1)/2 However, a more complicated argument may not have a closed-form. Bob Hanlon My goal is to have a general form of a summation that is a function of two variables, and would like to see if Mathematica can be used to determine the general form. For example, with a single variable, is there a way to get Mathematica to take sum_{k=0}^n (k/n) and determine the general formula for the sum (as a function of 'n') is (n+1)/2? The problem I am looking at is a bit more complicated (incorporates a five factorials) and is a function of two variables, m and n. I have never programmed in Mathematica (but do have programming experience in a few languages), and any direction on what resources or functions are appropriate for this sort of problem would be greatly appreciated. If this sort of thing can only be done in one variable, that would also be very useful since I'll just look at a particular case (when the two variables are equal: m=n). David === Subject: Re: opening notebooks in mathematica player instead of In OS X, you can select a notebook and get Info... from the Finder (cmd-I). You can then select which app opens the notebook. You can select Player. There is an option to change all files of the same type (.nb files) to show the same behaviour. This should work most of the time. If you want to open a doc with Mathematica proper, you can open it from within Mathematica. You can also right-click -- cmd-Click and select Mathematica from the list of choices to open with... This provides you with a way to override the default behaviour. You can even open files in BBEdit or TextEdit this way. You may have a problem with .m files, though. Xcode uses this extension for objective c files, and in my experience it is a crap shoot which app opens them, regardless of the default behaviour. If you do not have Xcode installed, there will be no problem. So a combination of default assignment using get Info... and the specific override using the contextual menus should provide you with what you want. george > When I double click on a notebook I want just want to view it. Is > there a way to default the assigned application to open the > mathematica notebooks with the mathematica viewer instead of having > mathematica boot up? If I want mathematica to boot up I'll click on > the icon. That's on my doc. I'm running Mac OS X 10.5.6 (9G55) on a PowerBook G4 if that helps > any. > === Subject: Re: opening notebooks in mathematica player instead of When I double click on a notebook I want just want to view it. Is > there a way to default the assigned application to open the > mathematica notebooks with the mathematica viewer instead of having > mathematica boot up? If I want mathematica to boot up I'll click on > the icon. That's on my doc. I'm running Mac OS X 10.5.6 (9G55) on a PowerBook G4 if that helps And George Woodrow III replied: > In OS X, you can select a notebook and get Info... from the Finder (cmd-I). You can then select which app opens the notebook. You can select > Player. There is an option to change all files of the same type (.nb > files) to show the same behaviour. This should work most of the time. I believe more or less exactly the same inherent and fundamental dilemma arises with respect to whether PDF files open in Adobe Acrobat or Adobe Reader when clicked (if you have both apps on your system), and the same workaround for Macs can be invoked here also. === Subject: Re: Polygon with holes > not work so easily for arbitrary polygons. The connection between inner > and outer contours is made by a straight line. A general algorithm would > have to select the points to be connected and make sure that the > connection itself does not intersect the contours. There should also be > a check on the orientations. Making two or more holes would complicate > things further. It shouldn't matter whether the lines cross the contours or not, so long as the exact same line is followed in reverse order at the end (which my earlier example does). It's possible the implementation of this algorithm in Mathematica code I provided earlier has a bug (I didn't test it thoroughly, if you have an example where it fails I'd be interested in seeing it), but the algorithm works and is completely general. Mathematica's built-in PDF import support appears to use the same algorithm for converting arbitrary multi-contour PDF paths into Mathematica Polygon primitives. Take a look at: Import[ExampleData/mathematica.pdf] Notice the output for the e, a, and i characters. The only caveat (of which I'm aware) of using this algorithm is that if you try to print a graphic containing one of these polygons to a PostScript printer, some PostScript printers will interpret the 0-width segment to be 1 device pixel wide (so lines do appear even though they cover zero area). > As I expected there seems to be no simple facility available. This could > be a feature request for wolfram. How do I submit one? Try this: http://support.wolfram.com/submitabug.cgi -Rob === Subject: Request for help - Minimize Please see the codes below (note the codes are used to show the problem, they may not executable). I use array CE to store the results of the function Minimize. Minimize may return error (becuase constraints[i] can not be satisfied). So I want to neglect the result in this case, I don't want the program stops in this case. How can I manage it? Array[CE,100] For[i =1,i<=100,i++, CE[i] = Minimize [objfun[i],constraints[i]] ] === Subject: Re: Request for help - Minimize > Please see the codes below (note the codes are used to show the problem, they may not executable). I use array CE to store the results of the function Minimize. Minimize may return error (becuase constraints[i] can not be satisfied). So I want to neglect the result in this case, I don't want the program stops in this case. How can I manage it? Array[CE,100] > For[i =1,i<=100,i++, CE[i] = Minimize [objfun[i],constraints[i]] ] Do[Check[CE[i] = Minimize[objfun[i], constraints[i]], $Failed], {i, 100}] === Subject: Re: Request for help - Minimize You can use the function Check for handling error conditions. > Please see the codes below (note the codes are used to show the problem, they may not executable). I use array CE to store the results of the function Minimize. Minimize may return error (becuase constraints[i] can not be satisfied). So I want to neglect the result in this case, I don't want the program stops in this case. How can I manage it? Array[CE,100] > For[i =1,i<=100,i++, CE[i] = Minimize [objfun[i],constraints[i]] ] === Subject: Re: Request for help - Minimize a) you must assign CE[[i]] b) CE /. _Minimize:> Sequence[] will remove the unevaluated minimization that fail. Jens > Please see the codes below (note the codes are used to show the problem, they may not executable). I use array CE to store the results of the function Minimize. Minimize may return error (becuase constraints[i] can not be satisfied). So I want to neglect the result in this case, I don't want the program stops in this case. How can I manage it? Array[CE,100] > For[i =1,i<=100,i++, CE[i] = Minimize [objfun[i],constraints[i]] ] > === Subject: Re: Request for help - Minimize > Please see the codes below (note the codes are used to show the problem, they may not executable). I use array CE to store the results of the function Minimize. Minimize may return error (becuase constraints[i] can not be satisfied). So I want to neglect the result in this case, I don't want the program stops in this case. How can I manage it? Array[CE,100] > For[i =1,i<=100,i++, CE[i] = Minimize [objfun[i],constraints[i]] ] > First, this is better written as Table[Minimize[{objfun[i], constraints[i]}, variables], {i, 1, 100}] but this does not filter out the cases that throw errors. You can use check for this: Table[ Check[ Minimize[{objfun[i], constraints[i]}, variables], error ], {i, 1, 100}] If you're new to Mathematica, it is a good idea to try to avoid For[]. In most cases there are easier/faster alternatives. === Subject: Re: FullGraphics of Graphics3D No idea, anyone? Istvan === Subject: Re: FullGraphics of Graphics3D This function does not exist ? You must write your own ... Jens > No idea, anyone? Istvan > === Subject: Re: General form of a summation as a function of 2 variables > My goal is to have a general form of a summation that is a function of two variables, and would like to see if Mathematica can be used to determine the general form. For example, with a single variable, is there a way to get Mathematica to take sum_{k=0}^n (k/n) and determine the general formula for the sum (as a function of 'n') is (n+1)/2? The problem I am looking at is a bit more complicated (incorporates a five factorials) and is a function of two variables, m and n. I have never programmed in Mathematica (but do have programming experience in a few languages), and any direction on what resources or functions are appropriate for this sort of problem would be greatly appreciated. If this sort of thing can only be done in one variable, that would also be very useful since I'll just look at a particular case (when the two variables are equal: m=n). > The first step is to open the documentation centre and type sum ... It certainly gives the solution much more quickly than writing to a moderated mailing list and waiting two days for the reply. Sum[k/n, {k, 0, n}] === Subject: Re: General form of a summation as a function of 2 variables In Mathematica, if you evaluate the following statement you obtain the general answer for all n. Sum[k/n, {k, 0, n}] (1 + n)/2 David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ My goal is to have a general form of a summation that is a function of two variables, and would like to see if Mathematica can be used to determine the general form. For example, with a single variable, is there a way to get Mathematica to take sum_{k=0}^n (k/n) and determine the general formula for the sum (as a function of 'n') is (n+1)/2? The problem I am looking at is a bit more complicated (incorporates a five factorials) and is a function of two variables, m and n. I have never programmed in Mathematica (but do have programming experience in a few languages), and any direction on what resources or functions are appropriate for this sort of problem would be greatly appreciated. If this sort of thing can only be done in one variable, that would also be very useful since I'll just look at a particular case (when the two variables are equal: m=n). David === Subject: Re: opening notebooks in mathematica player instead of mathematica > When I double click on a notebook I want just want to view it. Is ther= e a way to default the assigned application to open the mathematica noteboo= ks with the mathematica viewer instead of having mathematica boot up? If= I want mathematica to boot up I'll click on the icon. That's on my doc. I'm running Mac OS X 10.5.6 (9G55) on a PowerBook G4 if that helps any. Select one of the .nb files, get info on it, change the open with popup to the player app, then click Change All.... === Subject: Re: opening notebooks in mathematica player instead of mathematica > When I double click on a notebook I want just want to view it. Is ther= e a way to default the assigned application to open the mathematica noteboo= ks with the mathematica viewer instead of having mathematica boot up? If= I want mathematica to boot up I'll click on the icon. That's on my doc. I'm running Mac OS X 10.5.6 (9G55) on a PowerBook G4 if that helps any. I'd be very surprised if Mathematica Player starts up faster than Mathematica. That aside, it should be possible to change the default application to open notebook files using the Finder's Get Info window. Additionally, Mathematica 7 includes a QuickLook plugin for Mac OS X 10.5. So you can select the file in the Finder and press the QuickLook button (or the space bar) to get an idea what's in the file. -Rob === Subject: ListPointPlot3D not composable? Hello MathGroup: I want to annotate my 3D point plot, so I start with some Epilog statements (e.g. Point[]). An example is: ListPointPlot3D[ReplacePart[Partition[Range[100], 10] , {{3, 3} -> None, {5, 7} -> I, {8, 4} -> Missing[NotAvailable]}] , PlotStyle -> PointSize[Large] , Epilog -> Point[{6, 6, 50}] ] I kept getting a message like: Array {6, 6, 50} has the wrong dimensions for a graphics coordinate list. This does not make sense since this works fine: Graphics3D@Point[{6, 6, 50}] Now since the help for ListPointPlot3D[] says: returns Graphics3D[] I decided to try a list of Graphics3D[{e1,e2}] and then I get stuck on: (* no Epilog statement now! *) q1 = ListPointPlot3D[ReplacePart[Partition[Range[100], 10], {{3, 3} -> None, {5, 7} -> I, {8, 4} -> Missing[NotAvailable]}], PlotStyle -> PointSize[Large]]; Head@q1 >> Graphics3D Graphics3D[q1] >> Graphics is not a Graphics3D primitive or directive. Show@Graphics3D[q1] >> Graphics is not a Graphics3D primitive or directive. q1 (* output displays fine *) So should this work? What I am doing seems simple. I am trying to think of another workaround for this. Is there some other way to make this work? TIA. Roger Williams Franklin Laboratory === Subject: Re: ListPointPlot3D not composable? 1. Epilog is a 2D graphics space. 2. When in doubt, FullForm: Use: Show[q1] 3D Epilog: Show[q1, Graphics3D[{Red, PointSize[0.5], Point[{6, 6, 50}]}]] === Subject: Re: ListPointPlot3D not composable? > Hello MathGroup: I want to annotate my 3D point plot, so I start with some Epilog > statements (e.g. Point[]). An example is: ListPointPlot3D[ReplacePart[Partition[Range[100], 10] > , {{3, 3} -> None, {5, 7} -> I, {8, 4} -> Missing[NotAvailable]}] > , PlotStyle -> PointSize[Large] > , Epilog -> Point[{6, 6, 50}] > ] I kept getting a message like: Array {6, 6, 50} has the wrong dimensions for a graphics coordinate > list. This does not make sense since this works fine: Graphics3D@Point[{6, 6, 50}] > This is because Epilog takes 2D graphics primitives, even when used with Graphics3D. Quote from the doc page: In three-dimensional graphics, two-dimensional graphics primitives can be specified by the Epilog option. The graphics primitives are rendered in a 0,1 coordinate system. I know, this can be confusing ;) If you need to annotate your plot, use Show[]: Show[ PointPlot3D[..., Epilog -> {(* your 2D annotations here *)}], Graphics3D[ (* your 3D annotations here *) ] ] I hope this helps, Szabolcs === Subject: Re: ListPointPlot3D not composable? Hi Roger, Actually this is documented in the Epilog help page: In three-dimensional graphics, two-dimensional graphics primitives can be specified by the Epilog option. The graphics primitives are rendered in a 0,1 coordinate system. Translation: Epilog needs 2D Graphics primitives and not the 3D you are providing it with. If you want to inclued an additional 3D point you could simply use Show to combine the plot and a separate Graphics: Show[ ListPointPlot3D[ ReplacePart[ Partition[Range[100], 10], {{3, 3} -> None, {5, 7} -> I, {8, 4} -> Missing[NotAvailable]}], PlotStyle -> PointSize[Large]], Graphics3D[Point[{6, 6, 50}]]] wrt to q1: you can't do a Graphics3D of a Graphics3D... > Hello MathGroup: I want to annotate my 3D point plot, so I start with some Epilog > statements (e.g. Point[]). An example is: ListPointPlot3D[ReplacePart[Partition[Range[100], 10] > , {{3, 3} -> None, {5, 7} -> I, {8, 4} -> Missing[NotAvailable]}= ] > , PlotStyle -> PointSize[Large] > , Epilog -> Point[{6, 6, 50}] > ] I kept getting a message like: Array {6, 6, 50} has the wrong dimensions for a graphics coordinate > list. This does not make sense since this works fine: Graphics3D@Point[{6, 6, 50}] Now since the help for ListPointPlot3D[] says: returns Graphics3D[] > I decided to try a list of Graphics3D[{e1,e2}] and then I get stuck > on: (* no Epilog statement now! *) > q1 = ListPointPlot3D[ReplacePart[Partition[Range[100], > 10], {{3, 3} -> None, {5, 7} -> I, {8, 4} - Missing[NotAvailable]}], PlotStyle -> PointSize[Large]]; > Head@q1>> Graphics3D > Graphics3D[q1] >> Graphics is not a Graphics3D primitive or directive. > Show@Graphics3D[q1] >> Graphics is not a Graphics3D primitive or directive. q1 > (* output displays fine *) So should this work? What I am doing seems simple. I am trying to > think of another workaround for this. Is there some other way to make > this work? TIA. Roger Williams > Franklin Laboratory === Subject: Re: ListPointPlot3D not composable? Epilog can only contain 2d graphics objects, not 3d ones. Jens > Hello MathGroup: I want to annotate my 3D point plot, so I start with some Epilog > statements (e.g. Point[]). An example is: ListPointPlot3D[ReplacePart[Partition[Range[100], 10] > , {{3, 3} -> None, {5, 7} -> I, {8, 4} -> Missing[NotAvailable]}] > , PlotStyle -> PointSize[Large] > , Epilog -> Point[{6, 6, 50}] > ] I kept getting a message like: Array {6, 6, 50} has the wrong dimensions for a graphics coordinate > list. This does not make sense since this works fine: Graphics3D@Point[{6, 6, 50}] Now since the help for ListPointPlot3D[] says: returns Graphics3D[] > I decided to try a list of Graphics3D[{e1,e2}] and then I get stuck > on: (* no Epilog statement now! *) > q1 = ListPointPlot3D[ReplacePart[Partition[Range[100], > 10], {{3, 3} -> None, {5, 7} -> I, {8, 4} - Missing[NotAvailable]}], PlotStyle -> PointSize[Large]]; > Head@q1 > Graphics3D > Graphics3D[q1] > Graphics is not a Graphics3D primitive or directive. > Show@Graphics3D[q1] > Graphics is not a Graphics3D primitive or directive. > q1 > (* output displays fine *) So should this work? What I am doing seems simple. I am trying to > think of another workaround for this. Is there some other way to make > this work? TIA. Roger Williams > Franklin Laboratory > === Subject: Re: How to rotate a Histogram (Mathamatica 6) The format of Rotate you are using is only possible since version 7. In 6 it does only 3D graphics rotations. You could try the following: Graphics[ GeometricTransformation[ Rasterize[Plot[x, {x, -1, 1}], RasterSize -> 600][[1]], RotationTransform[-45 Degree] ], Frame -> True ] This rotates a rasterized version of the plot. On Mar 12, 9:20 am, prageeth saraka wimalaweera Im using Mathamatica 6.Could you please tell me a way to rotate a > Histogram? i tried it using Rotate[Histogram[xx[[3]], 45 Degree]but = it is 668130 > -- > prageeth === Subject: Re: How to rotate a Histogram (Mathamatica 6) On Mar 12, 3:20 am, prageeth saraka wimalaweera > Im using Mathamatica 6.Could you please tell me a way to rotate a > Histogram? i tried it using Rotate[Histogram[xx[[3]], 45 Degree]but = it is 668130 You want to use the Inset[] directive, which not only allows you to treat complex graphics objects like plots and histograms as elements in other, more complex graphics, but also takes an argument that allows you to specify the orientation of the inset graphics object so that its x-axis points along a specified vector. Between that and RotationTransform[], you really have all you need. Try, Graphics[Inset[hist, Center, Center, 1, RotationTransform[45*Degree][{1, 0}]]] and go ahead and enter ?Inset for more information about the other options. Pillsy === Subject: Re: Compile for different parameter types > Say I want to have a compiled function that works for tensors of rank > 2 or 3. Let's call this function f. Then f = Compile[{{A,_Real,2},{B,_Real,2}}, expr] would make function f for tensor of rank 2. Is it possible to expand > this function to work for both tensors of rank 2 and 3? Eventually I > would like to obtain a compiled function that works for a wide (but > limited) range of combinations of tensor ranks. All tensor ranks are > less than 15 so we are talking about at most 15^2=225 combinations. > You could use a proxy function that checks the type of the argument, and dispatches the task to the appropriate compiled function. f[x_Integer] := fInteger[x] (* fInteger is optimized for working with Integers *) f[x_Real] := fReal[x] Something like that. Use Depth to obtain the tensor rank. f[t_?TensorQ] /; Depth[t] == 4 := ... etc. === Subject: Re: Compile for different parameter types > This idea is kinda silly but: I just wanted to show that the idea of Raffy can just as well be done without writing the actual body (expr in the code below) of the compiled function as a string, which makes it look somewhat less silly :-) (to me at least) > funcString[a_Integer,b_Integer]:=Compile[{{A,_Real,<>ToString[a]<>}, > {B,_Real,<>ToString[b]<>}}, expr]; funcExpr[a_Integer, b_Integer] = Hold[{{A, _Real, a}, {B, _Real, b}}, expr]; > cache[a_Integer,b_Integer]:=cache[a,b]=ToExpression[funcString[a,b]]; cache[a_Integer, b_Integer] := cache[a, b] = Compile @@ funcExpr[a, b]; > func[a_?ArrayQ,b_?ArrayQ]:=cache[ArrayDepth[a],ArrayDepth[b]][a,b]; this last one needs no modification. For the reasons Jens has explained, I think automatically creating the compiled functions when needed as Raffy suggested is probably the best you can do. Just don't forget to ClearAll[cache] after changing expr... For some reasons I think it is good practice to try to avoid ToExpression and work with Mathematica expressions instead of strings wherever possible. Usually this can be done conveniently with placing some Holds in the right places. Some advantages are that syntax highlighting and 2D-Input for formulas will work as usual within the body of your compiled function, but it will also avoid parsing expr each and every time funcString is called. I also found that code using ToExpression is more error prone than code without it, especially when working with Packages/Contexts. Other problems with ToExpression can arise when using your code with Player, PlayerPro or WebMathematica, where ToExpression is limited to work with a subset of Mathematica only. There might be many more and probably even better reasons to try to avoid ToExpression, but I can't think of any more right now... hth, albert === Subject: font size Can someone tell me how to make the input output text, formulas, etc bigger in font? I used to use the magnification but doing it every time I use mathematica is tiring now. === Subject: Re: font size > Can someone tell me how to make the input output text, formulas, etc > bigger > in font? > I used to use the magnification but doing it every time I use mathematica > is > tiring now. > === Subject: Re: font size In the option inspector (format menu) go to Formatting Options/Font Options/Font Properties/Screen Resolution and change it to some higher value. Alternatively, you could change the style sheets, but that would take quite some effort. > Can someone tell me how to make the input output text, formulas, etc bigger > in font? > I used to use the magnification but doing it every time I use mathematica is > tiring now. === Subject: Re: font size The easiest thing to do is to use the magnification icon -- by default 100% in the status bar of a notebook's window (the location of this varies with the platform). Click there and then select 125%, 150%, etc. But you'll need to do that each time you open a notebook. Another way is to use the Options Inspector: 2. In the first field at the top of the pop-up Options window, from the drop-down list select Global Preferences. 3. In the left pane, click Notebook Options to open up a list of subcategories of options. Select Display Options in that list. 4. Now in the right-hand pane you will see a line with the option Magnification, which has setting 1 by default. To change it, click the little icon at the right end of that line and select the magnification factor you want, e.g., 1.25. (You'll notice an X is now displayed next to Magnification. 5. Click the Apply button in the Options Inspector window. Close the Options Inspector. A third way is to modify the default style sheet. I don't recommend that for a beginner. > Can someone tell me how to make the input output text, formulas, etc bigger > in font? > I used to use the magnification but doing it every time I use mathematica is > tiring now. > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: font size > Can someone tell me how to make the input output text, formulas, etc bigg= er > in font? > I used to use the magnification but doing it every time I use mathematica= is > tiring now. You could try a couple of things. One involves setting the Global Preference value of Magnification and the other involves changing the font sizes of styles. I will explain the first, and you can read on your wown about how to do the second if this is not what you are looking for. To set the magnification -- use the Option Inspector to set the default Magnification parameter to something larger than the default value of 1. (or 100%). To use the Option Inspector, click on the Format/Option Inspector menu, then click on the Global Preferences for scope and alphabetical for viewing mode then type in magnification (magn is enough to find this parameter) in the input cell and then change it's value (on my Mac there were 2 of these, one is for printing and one is for the screen - change the one that doesn't have to do with printing). I did this on a Mac version of Mathematica 7.0.1 - I think the Windows (and others?) works slightly different, but can't recall for sure. Keep in mind that this Magnification can be reset in a notebook, so this is not an absolute solution. Also, when the default magnification is changed like this, the magnification values that are at the bottom of a notebook window need to be multiplied by the new global magnification value you just set. For example if the global magnification number were set to 1.5 (150%) then the real magnification is the product of these two numbers or 1.5 (100% x 1.5 = 150%). If you wanted to go back to the former size of 100% temporarily, you would need to set the notebook percentage to 66% (66% x 1.5 = 100%). Another by-product of setting this magnification to 150% is that some palettes may grow in size (but I think this is a bug) and the Documentation window will not open with a window wide enough to display everything so a bit of clipping on the left and right takes place - but you can change the width of the window to be able to display everything (and the height also). Hope that helps ... Also be careful of what you do in the Option Inspector, as certain mistakenly set parameters can be difficult to recover from. -Bob === Subject: Re: font size > Another by-product of setting this > magnification to 150% is that some palettes may grow in size (but I > think this is a bug) and the Documentation window will not open with a > window wide enough to display everything so a bit of clipping on the > left and right takes place - but you can change the width of the > window to be able to display everything (and the height also). Well, turns out this is a feature according to Wolfram tech support. The palettes that are affected are ones that have their own percentage magnification button in the bottom right corner of the palette. So that means the Classroom Assistant, Writing Assistant, and Basic Math Assistant all do grow in size as you change the magnification parameter, but not the Special Characters, Chart Element Schemes, Color Schemes, Basic Typesetting, Basic Math Input and Algebraic Manipulation. The Documentation Center window if it is currently displayed modifies itself to compensate for the new magnification value, in that as the magnification global parameter goes up, the current DC window goes down, so the net effect is nill. If you open a DC after changing the global magnification parameter, this does not happen, but instead the content is magnified just as all other notebook windows contents are changed. I still think, that the fact that a new DC window opened after the global magnification parameter changes, and clips the content, is a bug and not a feature, as all other notebooks adjust their content and don't clip what they display, but again Wolfram says this is a feature. So the fact that there are several inconsistent behaviors, and all of them are features, rather escapes my sense of what Wolfram should consider a bug, but I suppose that is one of those my bug is your feature kind of issues. If other Mathematica users think these are bugs also, please contact Wolfram and let them know what you think. Perhaps we can start a thread in this newsgroup and create a list of these bugs vs features items? -Bob === Subject: Looking for automated search engine for conjectures in algebraic There are search engines that look for symbolic generators for sequences. There are engines that look for symbolic forms that match real valued constants. There is a very successful engine that looks for conjectures in graph theory, unfortunately I cannot remember the name of that one at the moment. I think I remember, but I now cannot find, an engine that searches for conjectures in simple algebra or perhaps algebraic geometry. This does not need to produce a proof, just searching through the composition of an assortment of functions applied to a handful of test cases until it stumbles onto one or more likely conjectures that satisfies a conjunction of equalities will be enough. searches and asking a few people has turned up nothing. It might have been a Mathematica package, but I've searched Wolfram's site and not found anything. A tangible, but over-simplified example, might help. Imagine the cosine law for triangles was not known, but you suspect there is a relationship between the edges of any triangle. The engine would be handed an equality, with unknown functions on both sides, and a set of example triangles. The task is to search through a bounded set of functions applied to each triangle until it finds something that likely satisfies the equality as far as N[] is concerned. Can anyone recall where they saw something like this described? Or, as a last resort, how something like this might be coded up in Mathematica? === Subject: Re: opening notebooks in mathematica player instead of mathematica >When I double click on a notebook I want just want to view it. Is >there a way to default the assigned application to open the >mathematica notebooks with the mathematica viewer instead of having >mathematica boot up? If I want mathematica to boot up I'll click on >the icon. That's on my doc. >I'm running Mac OS X 10.5.6 (9G55) on a PowerBook G4 if that helps >any. This isn't something that can be done from Mathematica since it is the OS that determines what app to launch when a document icon is clicked. However, it can be done. I can think of two ways to do this on a Mac. First, using =46inder, select a notebook, do cmd-i to bring up the meta information for that notebook, click on the arrow beside open with. Once this is done, set the mathematica viewer as the default application to use and finish by clicking on change all button. The other approach would be to get a RCDefaultApp. This is a freeware preference pane that allows you to set system wide preferences for which applications launch when document icons are clicked. It was created by Rubicode and can be obtained from the usual sources for Mac software. === Subject: Re: Notebook that auto-executes when opened? >>Mathematica is far more than the typical application that contains >>similar warning messages. Mathematica can be viewed as being a >>general purpose programming language. In this regard it is no more >>appropriate to put Are you sure? warnings in Mathematica than say >>a C/C++ compiler. As is the case with a C/C++ compiler, the >>assumption is the user knows what he is doing with commands such as >>DeleteFile. >Opening a C++ source file in an editor doesn't automatically run the >compiled program. True. But this doesn't change the fact Mathematica implements a programming language which while being heavily orientated to mathematics is general purpose. As such, the user is expected to know what they are doing and Are you sure? warnings are not appropriate. Additionally, unless you do something to change things, Mathematica does not automatically run notebooks when they are opened. === Subject: Re: Notebook that auto-executes when opened? >>Mathematica is far more than the typical application that contains >>similar warning messages. Mathematica can be viewed as being a >>general purpose programming language. In this regard it is no more >>appropriate to put Are you sure? warnings in Mathematica than say >>a C/C++ compiler. As is the case with a C/C++ compiler, the >>assumption is the user knows what he is doing with commands such as >>DeleteFile. > But this doesn't change the fact Mathematica implements a > programming language which while being heavily orientated to > mathematics is general purpose. As such, the user is expected to > know what they are doing and Are you sure? warnings are not appropriate. Many other users seem to find that warnings like this have saved their bacon on more than one occasion, and many, many other high-quality software products seem to contain such warnings. Would you really say that the InitializationCellWarning dialog (and the option to turn it on or off), and any other warnings like it, should never have been put into Mathematica to start with? (Not even into the $295 Mathematica Home Edition?) === Subject: Shooting Method Help Hi Im sure if anyone has done the shooting method on two variables instead of one would find this problem easy to tackle. I have two coupled differential equations one in the variable named vphi[Rr] and the other wz[Rr] both are a function of Rr. My notebook file can be accessed at http://web.mit.edu/~shahriar/Public/shootingmethodhelp.nb I only have two boundary conditions to satisfy. They are vphi[1]==0 and vphi[0]==0. Since eqn1 has vphi''[Rr] as second order. It needs two initial conditions, one is vphi[1]=0 and the other I decided to implement the shooting method on to get vphi[0]==0. So the initial condition vphi'[1]=A but since I have eqn2 with wz'[Rr] in it I need an initial condition on wz as well. I decided to use the shooting method on it as well so I kept wz[1]==B. I essentially am doing the shooting method with two variables, A and B but since I dont have any other boundary condition to satisfy on wz, when it comes time to solve for the roots in the shooting method I need two equations to solve for A and B One equation I use to set vphi[0]==0 but I dont know what to set the second one to for it to find a root for both A and B. So my findroot expression looks like this rooteqn = FindRoot[{fpA[A, B] == 0, fpA[A, B] == 0}, {{A, {Al, Au}}, {B, {Bl, Bu}}}] where I repeat the function twice over fpend[A_, B_] := vphi[0] /. NDSolve[{Eqnstosolve, vphi[1] == 0, !(*SuperscriptBox[vphi, [Prime], MultilineFunction->None])[1] == A, [Omega]z[1] == B}, {vphi, [Omega]z}, {Rr, 0, xend}, MaxSteps -> Infinity] This results in a result for vphi'[0]==A but it doesnt actually solve for values of B. It gives me the same result for whatever bounds I select for B. How do I solve for both A and B? Is there another way to implement this so I can solve for vphi[Rr] and wz[Rr] Any help on this matter is greatly appreciated. === Subject: Re: Shooting Method Help in order to obtain a meaningful result, you have to specify the right number of boundary conditions. As you explained in your posting, you need 3 boundary conditions. This doesn't only apply to solving the system by the shooting method, but applies to every possible method, also to solving it analytically. If you don't have the right number of BCs, you haven't specified your system correctly, so you should definitively ask your advisor. Good luck Alois === Subject: Re: Unexpected zoom when rotating Plot3D Hi David, and thank you for your help. My thinking also was that this was a bug. But I did not find a way to report it directly to Wolfram and so, , am glad you did. Michael > Go to the Mathematica Preference Dialog. In that Dialog select the Interface tab. In that tab, check the box that says Automatically re-fit 3-D > graphics after rotation. I am not sure why the graphic zooms so much if that box is unchecked: > it seems as though it is much too much of a zoom, and perhaps this is > a bug. That checkbox covers the global setting of the option RotationAction. Hope that this helps, David > http://scientificarts.com/worklife > Extending Mathematica's Reach.... > On Mar 10, 6:37 am, Michael Young I am running Mathematica 7.0.1 under OSX 10.5.6 using an ATI Radeon >> HD >> 2600 graphics card. >> In looking at the Plot3D documentation, I evaluated the notebook to >> rotate its figures. Following this there was no apparent change, but >> immediately upon mouse-rotation, images 2 and 4 of the Basic Examples >> appeared to zoom in very close to center so that the entire plot >> could >> not be fully viewed. Apart from that nothing else seemed wrong. >> Why might this be? > === Subject: Re: Maintaining a Mathematica bug list > The following would be a good start: http://getsatisfaction.com/wolfram It's not exactly a bug database, but it needs no setup, and it's > accessible to anyone. The company may choose to participate if they > wish so. I tried the link and it shows a blank page. Does it work for others? === Subject: Re: Maintaining a Mathematica bug list >> The following would be a good start: >> http://getsatisfaction.com/wolfram >> It's not exactly a bug database, but it needs no setup, and it's >> accessible to anyone. The company may choose to participate if they >> wish so. I tried the link and it shows a blank page. > Does it work for others? > You may try going directly to http://getsatisfaction.com/ and searching for the product Mathematica or the company Wolfram Research. Many companies have chosen to provide support for their products through this site (as well as by other means), but the page for WRI/Mathematica is empty at the moment. === Subject: Re: Maintaining a Mathematica bug list Murray's observation that one person's bug is another person's feature made me think that insisting on the word bug is probably misleading. To explain what I think, I will resort to an example. A few days ago, I used Minimize on a numeric function and, after some testing, I discovered that NMinimize with method Simulated Annealing found a better solution, so that Minimize's result was wrong. is documented: Minimize on a numeric function calls NMinimize. (What is not stated is that it call NMinimize with Method->Automatic). So I replied: ok, but than it should be possible to specify a Method also in Minimize, in case this happens (this is not possible now). So Daniel told me: use SetOptions[NMinimize]={Method->Simulated Annealing} and you get what you want. The moral of this is manifold: 1) Now I know how to handle the situation 2) Daniel is right: this is not a bug and there is a way out in Mathematica as it is 3) In general terms, I am not very happy, because if I did not make some tests I would never realized that Minimize returned a wrong value 4) I tend to consider symbolic functions as a way to provide the best possible result: when this does not happen I start trembling... 4) Like me, other users may have fallen in the same trap. Now, calling this a bug is misleading. It should more probably called a Caveat when using Minimize on numerical function. What is difficult now is to find a place where caveats (and genuine bugs) are collected and can be quickly searched before starting complex or serious activities. This place should also collect the discussions which ended with the words You should report this as a bug to Wolfram. I think that we really need is this: a searchable wiki collecting caveats and genuine bugs. How to create this in practice I do not know. Perhaps getsatisfaction.com is the solution or there is a better one. In any case, I believe it is useful and, if required, I will contribute to this achievement. ADL === Subject: Re: Maintaining a Mathematica bug list What is difficult now is to find a place where caveats (and genuine > bugs) are collected and can be quickly searched before starting > complex or serious activities. This is exactly what I would find useful about this. Presently the only way to learn about bugs is to follow MathGroup closely, but even when I remember that I've seen a bug (that might be relevant to me at the moment) mentioned a couple of months ago, I cannot always find the posts that described it. With tricky cases that are not bugs the situation is better, but the best place to learn about them is still the (quite busy) MathGroup. getsatisfaction.com is a nice site, but since it's completely open and uncontrollable, I'm afraid that it wouldn't be any more useful than MathGroup for this purpose: the useful bug descriptions would still be difficult to find in the flood of messages. === Subject: Re: Using Select here is a problem I have solved but I am not happy with the method I have a data matrix DATA, a list of m ordered n-tuples. I run a > function on the data matrix which returns a list DATAEVAL with m > elements. The i-th element of this list corresponds to the i-th tuple > of the data matrix. I think of this DATAEVAL list as an additional > column of the data matrix. Now I am only interested in those tuples of the data matrix, where the > corresponding DATAEVAL list has a value greater than zero. My current approach is the following: I add the DATAEVAL list to the > data matrix and call Select afterwards: data = Import[...]; > dataEval = f[data, ...]; > filteredData = Select[Transpose[Join[Transpose[data], {dataEval}] ], > Last[#] > 0 &]; This works. However, calling Transpose two times seems not to be the > most efficient way to solve the problem. As a newbie to Mathematica (and functional programming), I wonder if > you can point me to a simpler solution? > Hello Karsten, Use Pick[]. Pick[DATA, DATAEVAL, n_ /; n > 0] === Subject: Re: Using Select Positive -- n_/; n>0 -- /@) Karsten. here is a problem I have solved but I am not happy with the method I have a data matrix DATA, a list of m ordered n-tuples. I run a > function on the data matrix which returns a list DATAEVAL with m > elements. The i-th element of this list corresponds to the i-th tuple > of the data matrix. I think of this DATAEVAL list as an additional > column of the data matrix. Now I am only interested in those tuples of the data matrix, where the > corresponding DATAEVAL list has a value greater than zero. My current approach is the following: I add the DATAEVAL list to the > data matrix and call Select afterwards: data = Import[...]; > dataEval = f[data, ...]; > filteredData = Select[Transpose[Join[Transpose[data], {dataEval}] ], > Last[#] > 0 &]; This works. However, calling Transpose two times seems not to be the > most efficient way to solve the problem. As a newbie to Mathematica (and functional programming), I wonder if > you can point me to a simpler solution? Hello Karsten, Use Pick[]. Pick[DATA, DATAEVAL, n_ /; n > 0] === Subject: Re: Wolfram/Alpha (Wikipedia page restored) >> To be honest, Wolfram|Alpha is not THAT big at Google. I got 473000 hits for >> wolfram alpha, but if I look at hits 451-469, none of them refer to the >> Wolfram|Alpha project. If I put Wolfram Alpha (with citation marks) I get >> exactly 337 hits today. But that is at least more than 42 (base ten). >> Ingolf Dahl >> Sweden This is odd. I checked it yesterday with the term in quotation marks and > got 2.1 million. You get 337 today, but I get: Results 1 - 10 of about 63,100 English pages for wolfram alpha. (0.17 > seconds) > So it changes from 337, to 63,100 to 2.1 million. I've no idea why that > is. I'm using the double-quote opperators -i.e which I think is the > correct thing to do. Alpha. Apparently you set Google search to only return results in English, which severely decreased the number of results you got. That's why it gave you only 63,000. === Subject: Re: Wolfram/Alpha (Wikipedia page restored) > This is odd. I checked it yesterday with the term in quotation marks and > got 2.1 million. You get 337 today, but I get: Results 1 - 10 of about 63,100 English pages for wolfram alpha. (0.17 > seconds) So it changes from 337, to 63,100 to 2.1 million. I've no idea why that > is. I'm using the double-quote opperators -i.e which I think is the > correct thing to do. Typing Wolfram Alpha (with quotes) gives me 243.000 hits, different form all the other numbers. Most of the hits in the first page are in the local language of the searcher. So it is very possible that Ingolf from Sweden sees different hits than David from country X. yet. Have you noticed that Wolfram/Alpha was not announced in MathGroup by Wolfram? I believe my thread was the first on this topic. WRI is smartly building expectations and interest around Wolfram Alpha. It is funny to think that Wolfram Alpha might do for WRI what the ipod did for Apple: bring the brand into every household. We shall see. === Subject: Re: Share symbols among packages I do not understand why I should import the first package from the second. I consider them as independent. But use a third package which contains just the globals and import it to both packages sounds as good idea. >You have not been totally clear as to whether these are your packages - which you can alter. Sorry, I cannot rename the global vars. >2) Don't include myVar in either package, but write the definitions of myFun1 and myFun2 so they include data as a parameter. I cannot do it. -Andrey === Subject: How to map a list on function Could anyone explain me how to do the following: I have a long list of integer numbers in groups of four: list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } or its Flatten version. How to write a fast function g[list] which does this: g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... It should be done many times (say, 10^4-6) on lists with length > 1000, so taking parts is not a good idea. How to use Map or similar ? === Subject: Re: How to map a list on function Could anyone explain me how to do the following: > I have a long list of integer numbers in groups of four: list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } or its Flatten version. How to write a fast function g[list] which does this: g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... It should be done many times (say, 10^4-6) on lists with > length > 1000, so taking parts is not a good idea. > How to use Map or similar ? Here are five ways to do it. For lists of 1000 and 2000 4-tuples, g4 and g5 are best and about equally fast, but for longer lists g5 is fastest. list = {{10,3,5,7},{4,6,8,9},{0,8,3,6}}; g1[list_] := Tr[Times@@({x,y,z,u}^#)& /@ list]; g2[list_] := Tr[Inner[Power,{x,y,z,u},#,Times]& /@ list]; g3[list_] := Tr@Inner[#2^#1&,list,{x,y,z,u},Times]; g4[list_] := Tr[Times@@({x,y,z,u}^Transpose@list)]; g5[list_] := Tr@Inner[Power,{x,y,z,u},Transpose@list,Times]; SameQ @@ (#@list& /@ {g1,g2,g3,g4,g5}) g5[list]//InputForm True u^6*y^8*z^3 + u^7*x^10*y^3*z^5 + u^9*x^4*y^6*z^8 try[length_,reps_] := Block[{list = Table[Random[Integer,9], {length},{4}]}, {length, First/@{Timing@Do[g1[list],{reps}], Timing@Do[g2[list],{reps}], Timing@Do[g3[list],{reps}], Timing@Do[g4[list],{reps}], Timing@Do[g5[list],{reps}]}/.Second->1}] try[1000#,64/#]&/@{1,2,4,8} {{1000, {1.93, 1.56, 1.50, 1.21, 1.23}}, {2000, {2.10, 1.75, 1.73, 1.46, 1.47}}, {4000, {2.45, 2.13, 2.16, 1.95, 1.88}}, {8000, {2.72, 2.44, 2.42, 2.36, 2.17}}} === Subject: Re: How to map a list on function Could anyone explain me how to do the following: > I have a long list of integer numbers in groups of four: list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } or its Flatten version. How to write a fast function g[list] which does this: g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... It should be done many times (say, 10^4-6) on lists with length > 1000, s= o taking parts is not a good idea. > How to use Map or similar ? mPowers = RandomInteger[{0, 1}, {100, 4}]; vSymbols = {x, y, z, u}; Do[r1 = Plus @@ Times @@@ Transpose[vSymbols^Transpose[mPowers]], {10000}] // Timing Do[r2 = Total[ Times @@@ Transpose[vSymbols^Transpose[mPowers]]], {10000}] // Timing Do[r3 = Plus @@ Times @@@ (Power[vSymbols, #] & /@ mPowers), {10000}] // Timing Do[r4 = Plus @@ MapThread[Times, vSymbols^Transpose[mPowers]], {10000}] // Timing If you can prebuild a function before hand: f = Evaluate[Times @@ (vSymbols^Array[Slot, Length[vSymbols]])] &; Do[r5 = Plus @@ f @@ Transpose[mPowers], {10000}] // Timing Do[r6 = Plus @@ (f @@@ mPowers), {10000}] // Timing The winner depends on the length of mPower. (Might wanna call ClearSystemCache[] for better time tests) Additionally, if the mPower vector can be Transposed before hand, you gain more speed. === Subject: Re: How to map a list on function More like 'map a function onto a list'. list = {{10, 3, 5, 7}, {4, 6, 8, 9}, {0, 8, 3, 6}}; g[{xexp_, yexp_, zexp_, uexp_}] := x^xexp y^yexp z^zexp u^uexp Total[g /@ list] u^6 y^8 z^3 + u^7 x^10 y^3 z^5 + u^9 x^4 y^6 z^8 David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Could anyone explain me how to do the following: I have a long list of integer numbers in groups of four: list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } or its Flatten version. How to write a fast function g[list] which does this: g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... It should be done many times (say, 10^4-6) on lists with length > 1000, so taking parts is not a good idea. How to use Map or similar ? === Subject: Re: How to map a list on function list = {{10, 3, 5, 7}, {4, 6, 8, 9}, {0, 8, 3, 6}} {{10, 3, 5, 7}, {4, 6, 8, 9}, {0, 8, 3, 6}} g[list_List] := Plus @@ (Times @@ ({x, y, z, u}^#) & /@ list) g[list] u^6 y^8 z^3 + u^7 x^10 y^3 z^5 + u^9 x^4 y^6 z^8 Bobby Could anyone explain me how to do the following: > I have a long list of integer numbers in groups of four: list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } or its Flatten version. How to write a fast function g[list] which does this: g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... It should be done many times (say, 10^4-6) on lists with length > 1000, > so taking parts is not a good idea. > How to use Map or similar ? > -- DrMajorBob@bigfoot.com === Subject: Re: How to map a list on function Could anyone explain me how to do the following: > I have a long list of integer numbers in groups of four: list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } or its Flatten version. How to write a fast function g[list] which does this: g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... It should be done many times (say, 10^4-6) on lists with length > 1000, so taking parts is not a good idea. > How to use Map or similar ? Here's one straightforward way to do it. First, define a function gg[t] that acts on a 4-tuple t. gg[t_List] := x^t[[1]] y^t[[2]] z^t[[3]] u^t[[4]] Try this out on a single 4-tuple: t1={5,4,6,2} gg[t1] Now, define a function to Map gg over the list of 4-tuples and Total the results. g[list_List] := Total[Map[gg, list]] Try it on a list of 1000 4-tuples: list1 = RandomInteger[{0, 15}, {1000, 4}] g[list1] -- Helen Read University of Vermont === Subject: Re: How to map a list on function Your example is unclear - is your list format {x1,y1,z1,u1},{x2,y2,z2,u2}...{xn,yn,zn,un}}? If so, try Total[Map[#[[1]]*#[[2]]*#[[3]]*#[[4]]&,list]] Michael Could anyone explain me how to do the following: > I have a long list of integer numbers in groups of four: list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } or its Flatten version. How to write a fast function g[list] which does this: g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... It should be done many times (say, 10^4-6) on lists with length > 1000, so taking parts is not a good idea. > How to use Map or similar ? === Subject: Re: How to map a list on function lst = {{10, 3, 5, 7}, {4, 6, 8, 9}, {0, 8, 3, 6}} Plus @@ Times @@@ ( MapThread[Power, {{x, y, z, u}, #}] & /@ lst) ?? Jens Could anyone explain me how to do the following: > I have a long list of integer numbers in groups of four: list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } or its Flatten version. How to write a fast function g[list] which does this: g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... It should be done many times (say, 10^4-6) on lists with length > 1000, so taking parts is not a good idea. > How to use Map or similar ? > === Subject: Re: How to map a list on function Could anyone explain me how to do the following: > I have a long list of integer numbers in groups of four: list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } or its Flatten version. How to write a fast function g[list] which does this: g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... It should be done many times (say, 10^4-6) on lists with length > 1000, so taking parts is not a good idea. > How to use Map or similar ? > I don't know if this is really fast, but it seems to work: list = {{10, 3, 5, 7}, {4, 6, 8, 9}, {0, 8, 3, 6}, {4, 3, 5, 9}} Plus @@ ((x^#1 + y^#2 + z^#3 + u^#4) & @@@ list) Out= 1 + u^6 + u^7 + 2 u^9 + 2 x^4 + x^10 + 2 y^3 + y^6 + y^8 + z^3 + 2 z^5 + z^8 -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: How to map a list on function Could anyone explain me how to do the following: > I have a long list of integer numbers in groups of four: list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } or its Flatten version. How to write a fast function g[list] which does this: g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... It should be done many times (say, 10^4-6) on lists with length > 1000, so taking parts is not a good idea. > How to use Map or similar ? Try this: Times @@ ({x, y, z, u}^#) & /@ {{10, 3, 5, 7}, {4, 6, 8, 9}, {0, 8, 3, 6}} === Subject: Re: General form of a summation as a function of 2 variables Best, David === Subject: Re: Shooting Method Help > Hi Im sure if anyone has done the shooting method on two > variables > instead of one would find this problem easy to > tackle. > I have two coupled differential equations one in the > variable named > vphi[Rr] and the other wz[Rr] both are a function of > Rr. My notebook > file can be accessed at http://web.mit.edu/~shahriar/Public/shootingmethodhelp > .nb I only have two boundary conditions to satisfy. They > are vphi[1]==0 > and vphi[0]==0. Since eqn1 has vphi''[Rr] as second order. It needs > two initial > conditions, one is vphi[1]=0 and the other I decided > to implement the > shooting method on to get vphi[0]==0. So the initial condition vphi'[1]=A but since I have > eqn2 with wz'[Rr] > in it I need an initial condition on wz as well. I > decided to use the > shooting method on it as well so I kept wz[1]==B. > Why ? If you have only two boundary conditions to be satisfied, fix wz[1] to an arbitrary value. Then you only need to solve for A. > I essentially am doing the shooting method with two > variables, A and B > but since I dont have any other boundary condition to > satisfy on wz, > when it comes time to solve for the roots in the > shooting method I > need two equations to solve for A and B One equation I use to set vphi[0]==0 but I dont know > what to set the > second one to for it to find a root for both A and B. > So my findroot > expression looks like this rooteqn = > FindRoot[{fpA[A, B] == 0, > fpA[A, B] == 0}, {{A, {Al, Au}}, {B, {Bl, Bu}}}] where I repeat the function twice over fpend[A_, B_] := vphi[0] /. NDSolve[{Eqnstosolve, > vphi[1] == 0, > !(*SuperscriptBox[vphi, [Prime], > MultilineFunction->None])[1] == A, [Omega]z[1] == > B}, {vphi, [Omega]z}, {Rr, 0, xend}, MaxSteps > Steps -> Infinity] This results in a result for vphi'[0]==A but it > doesnt actually solve > for values of B. It gives me the same result for > whatever bounds I > select for B. How do I solve for both A and B? Is there another way > to implement > this so I can solve for vphi[Rr] and wz[Rr] > Any help on this matter is greatly appreciated. > Best wishes Torsten. === Subject: Re: ListPointPlot3D not composable? Show[ListPointPlot3D[ ReplacePart[ Partition[Range[100], 10], {{3, 3} -> None, {5, 7} -> I, {8, 4} -> Missing[NotAvailable]}], PlotStyle -> PointSize[Large]], Graphics3D[{Red, AbsolutePointSize[8], Point[{6, 6, 50}]}]] Bob Hanlon Hello MathGroup: I want to annotate my 3D point plot, so I start with some Epilog statements (e.g. Point[]). An example is: ListPointPlot3D[ReplacePart[Partition[Range[100], 10] , {{3, 3} -> None, {5, 7} -> I, {8, 4} -> Missing[NotAvailable]}] , PlotStyle -> PointSize[Large] , Epilog -> Point[{6, 6, 50}] ] I kept getting a message like: Array {6, 6, 50} has the wrong dimensions for a graphics coordinate list. This does not make sense since this works fine: Graphics3D@Point[{6, 6, 50}] Now since the help for ListPointPlot3D[] says: returns Graphics3D[] I decided to try a list of Graphics3D[{e1,e2}] and then I get stuck on: (* no Epilog statement now! *) q1 = ListPointPlot3D[ReplacePart[Partition[Range[100], 10], {{3, 3} -> None, {5, 7} -> I, {8, 4} -> Missing[NotAvailable]}], PlotStyle -> PointSize[Large]]; Head@q1 >> Graphics3D Graphics3D[q1] >> Graphics is not a Graphics3D primitive or directive. Show@Graphics3D[q1] >> Graphics is not a Graphics3D primitive or directive. q1 (* output displays fine *) So should this work? What I am doing seems simple. I am trying to think of another workaround for this. Is there some other way to make this work? TIA. Roger Williams Franklin Laboratory === Subject: Mathematica Question - Using DSolve with Boundary Conditions I am trying to reproduce the analytic solution to a pair of partial differential equations subject to boundary conditions. The analytic reproduce/ verify/ understand the solution. I believe I have set up DSolve correctly. However, when the line is executed DSolve simply returns the equations and boundary conditions rather than solving the system. Notes: * There are two partial differential equations, two unknown variables, and three boundary conditions. * The second and third boundary conditions are supposed to hold when: WN, WA and the partial derivatives of WN , WA with respect to t are evaluated at the value t == ts, where ts is an arbitrary constant. * Arbitrary constants include: a, b, d, e, k, r, s I would like to solve for WN and WA which are both functions of [t, m]. Here is the code I tried: DSolve[{-t m + (b e - d m) D[WN[t, m], m] + a t D[WN[t, m], t] + 1/2 s^2 t^2 D[WN[t, m], t, t] == r WN[t, m], -t m - d m D[WA[t, m], m] + a t D[WA[t, m], t] + 1/2 s^2 t^2 D[WA[t, m], t, t] == r WA[t, m], WN[0, m] == 0, WN[ts, m] == WA[ts, m] - k, D[WN[ts,m],t] == D[WA[ts,m],t]}, {WN[t, m], WA[t, m]}, {t, m}] OR... DSolve[{-t m + (b e - d m) D[WN[t, m], m] + a t D[WN[t, m], t] + 1/2 s^2 t^2 D[WN[t, m], t, t] == r WN[t, m], -t m - d m D[WA[t, m], m] + a t D[WA[t, m], t] + 1/2 s^2 t^2 D[WA[t, m], t, t] == r WA[t, m], WN[0, m] == 0, WN[ts, m] == WA[ts, m] - k, (D[WN[t,m],t]/.t->ts) == (D[WA[t,m],t]/.t->ts)}, {WN[t, m], WA[t, m]}, {t, m}] The published solution is of the form (where A and y are positive constants to be determined): WN[t, m] = A t^y - t m / (r + d - a) - b e t / ((r - a) (r + d - a)) WA[t, m] = - t m / (r + d - a) Can anyone advise how to use DSolve to yield solutions for WN and WA? James Huth jh288507@ohio.edu === Subject: Re: Mathematica Question - Using DSolve with Boundary Conditions write a function, that solve your problem and rename it to DSolve[], because DSolve[] build in Mathematica can't solve this kind of problems. Jens I am trying to reproduce the analytic solution to a pair of partial > differential equations subject to boundary conditions. The analytic > reproduce/ verify/ understand the solution. I believe I have set up DSolve correctly. However, when the line is > executed DSolve simply returns the equations and boundary conditions rather > than solving the system. Notes: > * There are two partial differential equations, two unknown variables, and > three boundary conditions. > * The second and third boundary conditions are supposed to hold when: WN, > WA and the partial derivatives of WN , WA with respect to t are evaluated > at the value t == ts, where ts is an arbitrary constant. > * Arbitrary constants include: a, b, d, e, k, r, s I would like to solve for WN and WA which are both functions of [t, m]. Here is the code I tried: DSolve[{-t m + (b e - d m) D[WN[t, m], m] + a t D[WN[t, m], t] + 1/2 s^2 > t^2 D[WN[t, m], t, t] == r WN[t, m], > -t m - d m D[WA[t, m], m] + a t D[WA[t, m], t] + 1/2 s^2 t^2 D[WA[t, m], t, > t] == r WA[t, m], > WN[0, m] == 0, WN[ts, m] == WA[ts, m] - k, D[WN[ts,m],t] == D[WA[ts,m],t]}, > {WN[t, m], WA[t, m]}, {t, m}] OR... DSolve[{-t m + (b e - d m) D[WN[t, m], m] + a t D[WN[t, m], t] + 1/2 s^2 > t^2 D[WN[t, m], t, t] == r WN[t, m], > -t m - d m D[WA[t, m], m] + a t D[WA[t, m], t] + 1/2 s^2 t^2 D[WA[t, m], t, > t] == r WA[t, m], > WN[0, m] == 0, WN[ts, m] == WA[ts, m] - k, (D[WN[t,m],t]/.t->ts) == > (D[WA[t,m],t]/.t->ts)}, {WN[t, m], WA[t, m]}, {t, m}] > The published solution is of the form (where A and y are positive constants > to be determined): WN[t, m] = A t^y - t m / (r + d - a) - b e t / ((r - a) (r + d - a)) WA[t, m] = - t m / (r + d - a) Can anyone advise how to use DSolve to yield solutions for WN and WA? > James Huth > jh288507@ohio.edu === Subject: Re: The Go Back Button doesn't work I'm just curious -- can you tell me where this go back button is on my WinXP box? I looked in the documentation for go back and found nothing. I do know about the undo menu item. === Subject: Re: The Go Back Button doesn't work First put up the toolbar if you haven't already: menu Window->Show Toolbar. Then note the really tiny arrow button Kevin > I'm just curious -- can you tell me where this go back button is on my WinXP box? I looked in the documentation for go back and found nothing. I do know about the undo menu item. > === Subject: Re: The Go Back Button doesn't work > I'm just curious -- can you tell me where this go back button is on my WinXP box? I looked in the documentation for go back and found nothing. I do know about the undo menu item. I am not sure of this either, but I am guessing that this is the Back button when you Control-click or right-click in the title bar of a Notebook window (not in the main Mathematica menu along the very top of the screen). Would someone post an example notebook that shows what this really is used for, or where in the Documentation Center to look for more information? -Bob === Subject: Re: How to get data from Histogram > h = Histogram[RandomReal[NormalDistribution[0, 1], 200]] Just look at the FullForm and extract whatever you want. The bin > interval and count are > The method used in the documentation, as pointed out by DrMajorBob is better. It gets the information from a documented behavior of Histogram (namely, what the third argument can be.) The internal form of the graphic returned by Histogram is not documented and is subject to change from version to version. For example, V7.0.1 has a change from V7.0.0 in how the styles are applied to Histogram's bars so that the size (in bytes) of the graphic is smaller (by about 20% for a simple example I just tried.) Brett Champion Wolfram Research > bd = Cases[h, RectangleBox[{bl_, _}, {br_, c_}] :> {{bl, br}, c}, > Infinity] {{{-(5/2), -2}, 5}, {{-2, -(3/2)}, 8}, {{-(3/2), -1}, 13}, > {{-1, -(1/2)}, 36}, {{-(1/2), 0}, 37}, {{0, 1/2}, 43}, > {{1/2, 1}, 23}, {{1, 3/2}, 21}, {{3/2, 2}, 7}, {{2, 5/2}, 5}, > {{5/2, 3}, 2}} bins = bd[[All, 1]] // Flatten // Union {-(5/2), -2, -(3/2), -1, -(1/2), 0, 1/2, 1, 3/2, 2, 5/2, 3} counts = bd[[All, 2]] {5,8,13,36,37,43,23,21,7,5,2} counts == Cases[h, Tooltip[_, Style[label_, __]] :> label, Infinity] True > Bob Hanlon SOLUTION: > h = Histogram[RandomReal[NormalDistribution[0, 1], 200]] > counts = Cases[h, Tooltip[_, Style[label_, __]] :> label, Infinity] However I only get number of counts in a bin.. is it possible to > somehow extract also the bin positions? > === Subject: Re: How to get data from Histogram h = Histogram[RandomReal[NormalDistribution[0, 1], 200]] Just look at the FullForm and extract whatever you want. The bin interval and count are bd = Cases[h, RectangleBox[{bl_, _}, {br_, c_}] :> {{bl, br}, c}, Infinity] {{{-(5/2), -2}, 5}, {{-2, -(3/2)}, 8}, {{-(3/2), -1}, 13}, {{-1, -(1/2)}, 36}, {{-(1/2), 0}, 37}, {{0, 1/2}, 43}, {{1/2, 1}, 23}, {{1, 3/2}, 21}, {{3/2, 2}, 7}, {{2, 5/2}, 5}, {{5/2, 3}, 2}} bins = bd[[All, 1]] // Flatten // Union {-(5/2), -2, -(3/2), -1, -(1/2), 0, 1/2, 1, 3/2, 2, 5/2, 3} counts = bd[[All, 2]] {5,8,13,36,37,43,23,21,7,5,2} counts == Cases[h, Tooltip[_, Style[label_, __]] :> label, Infinity] True Bob Hanlon SOLUTION: h = Histogram[RandomReal[NormalDistribution[0, 1], 200]] counts = Cases[h, Tooltip[_, Style[label_, __]] :> label, Infinity] However I only get number of counts in a bin.. is it possible to somehow extract also the bin positions? === Subject: Re: How to get data from Histogram I was trying to get data like it is described in these example... But this only works if I chose interval and step for histogram. I > was not > able to get data out of histogram when letting Mathematica > automatically > chose step and interval for building the histogram. > This will use the automatic bin selection, and return the bins and their counts: {g, {binCounts}} = Reap[Histogram[ RandomReal[NormalDistribution[0, 1], 100], Automatic, Function[{bins, counts}, Sow[{bins, counts}];counts]]]; Brett Champion Wolfram Research > Jozef -----Original Message----- === > Subject: How to get data from > Histogram Help has the following example: {g, {binCounts}} = > Reap[Histogram[ > RandomReal[NormalDistribution[0, 1], 100], {-2, 2, 0.25}, > Function[{bins, counts}, Sow[counts]]]]; binCounts {{3, 4, 5, 6, 11, 3, 12, 6, 5, 13, 7, 4, 10, 2, 3, 2}} Bobby >> HI to all, >> i am using Mathematica 7.0.0. >> what I would like to do is to somehow get data out of histogram >> generated by >> Histogram[]. >> For an example: >> I tried to do find the frequency of my data with BinCounts[]... but I >> need >> to manually chose binsize an binwindow. >> By using Histogram[] the binsize and binwindow are chosen >> automatically >> with >> smart algorithms, but only plotted. is there any way to get data >> out of >> plotted histogram? >> Thnx, >> Jozef > > -- > DrMajorBob@bigfoot.com > === Subject: Re: How to get data from Histogram SOLUTION: h = Histogram[RandomReal[NormalDistribution[0, 1], 200]] counts = Cases[h, Tooltip[_, Style[label_, __]] :> label, Infinity] However I only get number of counts in a bin.. is it possible to somehow = extract also the bin positions? === Subject: Re: How to get data from Histogram I was trying to get data like it is described in these example... But this only works if I chose interval and step for histogram. I was not able to get data out of histogram when letting Mathematica automatically chose step and interval for building the histogram. Jozef -----Original Message----- === Subject: How to get data from Histogram Help has the following example: {g, {binCounts}} = Reap[Histogram[ RandomReal[NormalDistribution[0, 1], 100], {-2, 2, 0.25}, Function[{bins, counts}, Sow[counts]]]]; binCounts {{3, 4, 5, 6, 11, 3, 12, 6, 5, 13, 7, 4, 10, 2, 3, 2}} Bobby > HI to all, i am using Mathematica 7.0.0. what I would like to do is to somehow get data out of histogram > generated by > Histogram[]. For an example: I tried to do find the frequency of my data with BinCounts[]... but I > need > to manually chose binsize an binwindow. By using Histogram[] the binsize and binwindow are chosen automatically > with > smart algorithms, but only plotted. is there any way to get data out of > plotted histogram? Thnx, Jozef -- DrMajorBob@bigfoot.com === Subject: Function as return value, how to document it (::usage) my function is a function builder, when it is called, it returns a function. Everything works fine, except for the help text. Here is a minimal example: funcBuilder[start_, factor_] := Module[ {localfunc}, localfunc[0] = start; localfunc[x_Integer] := localfunc[x - 1] + factor*x; localfunc[] := empty; localfunc::usage = my help text here.; localfunc ]; myf = funcBuilder[1, 1]; myf[] Table[myf[i], {i, 1, 5}] ?myf It displays localfunc$7151 instead of my help text here. Do you have a hint on how to improve this? To put this problem into a larger perspective, here is what I really want to do with this function builder. I need to read several Excel sheets and want a nice interface. I have some assumptions on the Excel sheets: data is rectangular, first row is column names, there is one column that has unique values (something like a primary key). Now I have defined a wrapper for the Import function as follows: ReadExcelSheet[file_, sheet_, pk_] := Module[{firstRow, colNameRules, data, datafunc}, data = Import[file, {Sheets, sheet}]; firstRow = First[data]; data = Rest[data]; colNameRules = MapThread[#1 -> #2 &, {firstRow, Table[i, {i, 1, Length[firstRow]}]}]; datafunc[id_] := First[Select[data, Part[#, pk /. colNameRules] == id &]]; datafunc[id_, colName_String] := Part[datafunc[id], colName /. colNameRules]; datafunc[id_, colNames_List] := Part[datafunc[id], colNames /. colNameRules]; datafunc[] := colNameRules; datafunc[Null] := data; datafunc[Null, colName_String] := Map[ Part[#, colName /. colNameRules] &, data]; datafunc[Null, colNames_List] := Map[ Part[#, colNames /. colNameRules] &, data]; datafunc (* return value *) ]; The function returns a function which allows data access like this (assuming we have a sheet with columns id and each month): ProductionData = ReadExcelSheet[myfile.xls, mysheet, id] ProductionData[id1, Jan] (* returns one number *) ProductionData[id1, {Jan, Feb}] (* returns two values *) ProductionData[Null, {id, Jan}] (* returns id and january values for all plants *) ProductionData[Null] (*returns all values, but not the headers*) ProductionData[] (* returns transformation rules column names -> list index *) I hope that this approach does not have negative side effects ?!? Also, I would be interested in different approaches to this data access problem. And, I would like to add some information of the excel sheet (file and sheet name, timestamp, some usage information). Karsten. === Subject: Re: Function as return value, how to document it (::usage) and what does Information[Evaluate[myf]] ?? Jens my function is a function builder, when it is called, it returns a > function. Everything works fine, except for the help text. > Here is a minimal example: funcBuilder[start_, factor_] := Module[ > {localfunc}, > localfunc[0] = start; > localfunc[x_Integer] := localfunc[x - 1] + factor*x; > localfunc[] := empty; > localfunc::usage = my help text here.; > localfunc > ]; > myf = funcBuilder[1, 1]; > myf[] > Table[myf[i], {i, 1, 5}] > ?myf It displays localfunc$7151 instead of my help text here. Do you > have a hint on how to improve this? To put this problem into a larger perspective, here is what I really > want to do with this function builder. I need to read several Excel > sheets and want a nice interface. I have some assumptions on the Excel > sheets: data is rectangular, first row is column names, > there is one column that has unique values (something like a primary > key). Now I have defined a wrapper for the Import function as follows: ReadExcelSheet[file_, sheet_, pk_] := > Module[{firstRow, colNameRules, data, datafunc}, > data = Import[file, {Sheets, sheet}]; > firstRow = First[data]; > data = Rest[data]; > colNameRules = MapThread[#1 -> #2 &, {firstRow, Table[i, {i, 1, > Length[firstRow]}]}]; > datafunc[id_] := First[Select[data, Part[#, pk /. colNameRules] == > id &]]; > datafunc[id_, colName_String] := Part[datafunc[id], colName /. > colNameRules]; > datafunc[id_, colNames_List] := Part[datafunc[id], colNames /. > colNameRules]; > datafunc[] := colNameRules; > datafunc[Null] := data; > datafunc[Null, colName_String] := Map[ Part[#, colName /. > colNameRules] &, data]; > datafunc[Null, colNames_List] := Map[ Part[#, colNames /. > colNameRules] &, data]; > datafunc (* return value *) > ]; The function returns a function which allows data access like this > (assuming we have a sheet with columns id and each month): ProductionData = ReadExcelSheet[myfile.xls, mysheet, id] > ProductionData[id1, Jan] (* returns one number *) > ProductionData[id1, {Jan, Feb}] (* returns two values *) > ProductionData[Null, {id, Jan}] (* returns id and january values > for all plants *) > ProductionData[Null] (*returns all values, but not the headers*) > ProductionData[] (* returns transformation rules column names -> list > index *) I hope that this approach does not have negative side effects ?!? > Also, I would be interested in different approaches to this data > access problem. And, I would like to add some information of the excel > sheet (file and sheet name, timestamp, some usage information). > Karsten. === Subject: ToNumberField isn't perfect I'm seeing a problem with ToNumberField sometimes claiming that a number isn't in a number field, when it actually is. In particular, try d=Root[-5+17 #1^2-8 #1^4+#1^6&,6]; z=Sqrt[2-d^2]; f=Root[-5+413 #1-2156 #1^2+#1^3&,2,0]; now ToNumberField[f, z] fails, but ToNumberField[d^2 f,z]/ToNumberField [d^2,z] (which gives the same answer) succeeds. A mathematica session follows. Scott Morrison In[295]:= [Delta]=Root[-5+17 #1^2-8 #1^4+#1^6&,6] Out[295]= Root[-5+17 #1^2-8 #1^4+#1^6&,6] In[296]:= z=RootReduce[Sqrt[2-[Delta]^2]] Out[296]= Root[-5-3 #1^2+2 #1^4+#1^6&,4] In[297]:= f=((1-7 Root[-5+17 #1^2-8 #1^4+#1^6&,6]^2+2 Root[-5+17 #1^2-8 #1^4+#1^6&,6]^4) [Sqrt](3-11 Root[-5+17 #1^2-8 #1^4+#1^6&,6] ^2+3 Root[-5+17 #1^2-8 #1^4+#1^6&,6]^4) (4-11 Root[-5+17 #1^2-8 #1^4+#1^6&,6]^2+3 Root[-5+17 #1^2-8 #1^4+#1^6&,6]^4) Root[-5+13179 #1^2+28316 #1^4+#1^6&,2])/((-2+Root[-5+17 #1^2-8 #1^4+#1^6&,6]^2) ((-1- Root[-5+17 #1^2-8 #1^4+#1^6&,6]+Root[-5+17 #1^2-8 #1^4+#1^6&,6]^2) (-1+Root[-5+17 #1^2-8 #1^4+#1^6&,6]+Root[-5+17 #1^2-8 #1^4+#1^6&,6]^2)) ^(3/2)); In[298]:= ToNumberField[f,z] During evaluation of In[298]:= ToNumberField::nnfel: ((1-7 Root[-5+17 Power[<<2>>]-8 Power[<<2>>]+Slot[<<1>>]^6&,6,0]^2+2 Root[-5+17 Power [<<2>>]-8 Power[<<2>>]+Slot[<<1>>]^6&,6,0]^4) Sqrt[3-11 Root[-5+Times [<<2>>]+Times[<<1>>]+Power[<<2>>]&,6,0]^2+3 Root[-5+Times[<<2>>]+Times [<<2>>]+Power[<<2>>]&,6,0]^4] (4-11 Root[<<1>>&,6,0]^2+3 <<1>>^4) Root [-5+13179 #1^2+28316 #1^4+#1^6&,2,0])/((-2+Root[-5+17 Power[<<2>>]-8 Power[<<2>>]+Slot[<<1>>]^6&,6,0]^2) ((-1-Root[-5+Times[<<2>>]+Times [<<2>>]+Power[<<2>>]&,6,0]+Root[-5+Times[<<2>>]+Times[<<2>>]+Power [<<2>>]&,6,0]^2) (-1+Root[<<1>>]+<<1>>^2))^(3/2)) does not belong to the algebraic number field generated by Root[-5-3 #1^2+2 #1^4+#1^6&, 4,0]. >> Out[298]= ToNumberField[((1-7 Root[-5+17 #1^2-8 #1^4+#1^6&,6]^2+2 Root [-5+17 #1^2-8 #1^4+#1^6&,6]^4) Sqrt[3-11 Root[-5+17 #1^2-8 #1^4+#1^6&, 6]^2+3 Root[-5+17 #1^2-8 #1^4+#1^6&,6]^4] (4-11 Root[-5+17 #1^2-8 #1^4+#1^6&,6]^2+3 Root[-5+17 #1^2-8 #1^4+#1^6&,6]^4) Root[-5+13179 #1^2+28316 #1^4+#1^6&,2])/((-2+Root[-5+17 #1^2-8 #1^4+#1^6&,6]^2) ((-1- Root[-5+17 #1^2-8 #1^4+#1^6&,6]+Root[-5+17 #1^2-8 #1^4+#1^6&,6]^2) (-1+Root[-5+17 #1^2-8 #1^4+#1^6&,6]+Root[-5+17 #1^2-8 #1^4+#1^6&,6]^2)) ^(3/2)),Root[-5-3 #1^2+2 #1^4+#1^6&,4]] In[299]:= ToNumberField[RootReduce[f],z] During evaluation of In[299]:= ToNumberField::nnfel: Root[-5+413 #1-2156 #1^2+#1^3&,2,0] does not belong to the algebraic number field generated by Root[-5-3 #1^2+2 #1^4+#1^6&,4,0]. >> Out[299]= ToNumberField[Root[-5+413 #1-2156 #1^2+#1^3&,2],Root[-5-3 #1^2+2 #1^4+#1^6&,4]] In[300]:= ToNumberField[f [Delta]^2,z]/ToNumberField[[Delta]^2,z] Out[300]= AlgebraicNumber[Root[-5-3 #1^2+2 #1^4+#1^6&,4], {554,0,668,0,183,0}] In[301]:= N[ToNumberField[f [Delta]^2,z]/ToNumberField[[Delta]^2,z]- f] Out[301]= 1.68199*10^-14 === Subject: Comparing Corresponding Columns of Two Matrices Hello everyone, I'm trying to develop a modest skill in mapping functions and I've been working on this problem. Suppose I have two 100 x 4 matrices, X and Y, and I want to see whether each value in a column of X is bigger than each value in the corresponding column of Y. In other words, compare column 1 of X with column 1 of Y, column 2 of X with column 2 of Y, and so on. It's easy to generate a 100 x 4 table of Booleans using Table as Table[Boole[X[[i , j]] > Y[[i, j]]], {i, 100}, {j, 4}] But what about without Table? I am able to do it for the comparison of any one column as Boole[#[[1]] > #[[2]]] & /@ Transpose[{X[[All, ]], Y[[All, 1]]}] but I'm not sure how to extend this to other columns. Any tip would be much appreciated. Gregory === Subject: Re: Comparing Corresponding Columns of Two Matrices > Hello everyone, I'm trying to develop a modest skill in mapping functions and I've > been working on this problem. Suppose I have two 100 x 4 matrices, X and Y, and I want to see > whether each value in a column of X is bigger than each value in the > corresponding column of Y. In other words, compare column 1 of X with = > column 1 of Y, column 2 of X with column 2 of Y, and so on. It's easy to generate a 100 x 4 table of Booleans using Table as Table[Boole[X[[i , j]] > Y[[i, j]]], {i, 100}, {j, 4}] But what about without Table? I am able to do it for the comparison = > of any one column as Boole[#[[1]] > #[[2]]] & /@ Transpose[{X[[All, ]], Y[[All= , 1]]}] but I'm not sure how to extend this to other columns. Any tip would = > be much appreciated. > Gregory X = RandomReal[{0, 1}, {100, 4}]; Y = RandomReal[{0, 1}, {100, 4}]; r1 = Boole@MapThread[Greater, {X, Y}, ArrayDepth[X]]; Or, even better: r2 = Clip[X - Y, {0, 0}, {0, 1}]; === Subject: Re: Comparing Corresponding Columns of Two Matrices [ScriptCapitalX] = Table[RandomInteger[{0, 255}], {10}, {4}]; [ScriptCapitalY] = Table[RandomInteger[{0, 255}], {10}, {4}]; MapThread[#1 > #2 &, {[ScriptCapitalX], [ScriptCapitalY]}, 2] ?? Jens > Hello everyone, I'm trying to develop a modest skill in mapping functions and I've > been working on this problem. Suppose I have two 100 x 4 matrices, X and Y, and I want to see > whether each value in a column of X is bigger than each value in the > corresponding column of Y. In other words, compare column 1 of X with > column 1 of Y, column 2 of X with column 2 of Y, and so on. It's easy to generate a 100 x 4 table of Booleans using Table as Table[Boole[X[[i , j]] > Y[[i, j]]], {i, 100}, {j, 4}] But what about without Table? I am able to do it for the comparison > of any one column as Boole[#[[1]] > #[[2]]] & /@ Transpose[{X[[All, ]], Y[[All, 1]]}] but I'm not sure how to extend this to other columns. Any tip would > be much appreciated. > Gregory > === Subject: relaxation method for boundary value problem in systems of nonlinear ODEs In the help for Mathematica 6 I could only find the use of the shooting methods for solving 2 point boundary value problems in systems of nonlinear ODEs. And the chasing method is not applicable to nonlinear ODEs. So I was wondering if there is an implementation of the relaxation method and where to find the way to use it if there is. I apologize for referencing outside sources but what I have in mind is described in Numerical recipes in C ch.17.3. Alexander Borisov. === Subject: Hash function I bet I'm wrong in a childish way but I'm incapable to overcome the bug. Why does the following code return discrepant values when processing two identical file ( CRTL + C , CRTL + V ) placed in two different folders ? Of course, I'm looking on only the Hash part of the out, being obviously the folder related part. Ignacio fileIdentifier[myFile_]:=Module[{ tmp , folderPos }, folderPos = StringPosition[myFile,]//Flatten//Max; tmp={ FileByteCount[myFile], Hash[myFile,SHA512], StringJoin[ ], StringTake[myFile,folderPos-1], StringDrop[myFile,folderPos] }; Return[tmp]; ] === Subject: Re: Hash function On Mar 14, 3:41 am, Ignacio Plazeta I bet I'm wrong in a childish way but I'm > incapable to overcome the bug. Why does the following code return discrepant values > when processing two identical file ( CRTL + C , CRTL + V ) > placed in two different folders ? Of course, I'm looking on only > the Hash part of the out, being obviously the folder related part. Ignacio fileIdentifier[myFile_]:=Module[{ tmp , folderPos }, > folderPos = StringPosition[myFile,]//Flatten//Max; > tmp={ > FileByteCount[myFile], > Hash[myFile,SHA512], > StringJoin[ > ], > StringTake[myFile,folderPos-1], > StringDrop[myFile,folderPos] > }; > Return[tmp]; > ] FileHash? === Subject: Re: Hash function Hash does a hash on the expression that is its argument, in this case the file name (which is different for both locations if you include the path). You need FileHash, which does a hash on the file itself. On Mar 14, 12:41 pm, Ignacio Plazeta I bet I'm wrong in a childish way but I'm > incapable to overcome the bug. Why does the following code return discrepant values > when processing two identical file ( CRTL + C , CRTL + V ) > placed in two different folders ? Of course, I'm looking on only > the Hash part of the out, being obviously the folder related part. Ignacio fileIdentifier[myFile_]:=Module[{ tmp , folderPos }, > folderPos = StringPosition[myFile,]//Flatten//Max; > tmp={ > FileByteCount[myFile], > Hash[myFile,SHA512], > StringJoin[ > ], > StringTake[myFile,folderPos-1], > StringDrop[myFile,folderPos] > }; > Return[tmp]; > ] === Subject: Re: read real*8 binary This binary file I could read without problems using > Import[....Real32]; But when I changed real to real*8 in the > fortran program I could not read the file anymore (I used Real64 > instead of Real32), meaning I get numbers like 10^275. I used the > same fortran compiler (ifort 10) and the same computer (Mac Pro) in > both computations. > Anyone has an idea why this does not work??? > Jan > This sounds rather puzzling to me.I would write a mini Fortran program to output a number of REAL*8 numbers with known bit patterns - possibly equivalencing them to integers so that you can print out the exact bit pattern. Then you can check with a hex editor that the resultant file actually contains the bit patterns you expect. My guess is that there is a typo in your program somewhere. Have you checked that your Fortran program is actually producing the numbers you expect. For example, when you changed to REAL*8, did you end up calling a function that required a REAL*4 with an argument that was now REAL*8 perhaps. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Request for help - Minimize >Please see the codes below (note the codes are used to show the >problem, they may not executable). I use array CE to store the >results of the function Minimize. Minimize may return error (because >constraints[i] can not be satisfied). So I want to neglect the >result in this case, I don't want the program stops in this case. >How can I manage it? Look at the function Check. It has the form Check[expr, errorExpr] and returns the result of expr if there is no error and the result of errorExpr is there is an error. === Subject: Re: Mathematica 7.0.1.0 and some General Comments >But: the difference between traditional computation (I do not have >a better term...) and computation done using closed applications is >that in the first, at least in principle, there is complete openness >as to what was done, while in the second there is a party *actively* >withholding possibly relevant information. (The motivation for that >withholding is probably not confounding mathematicians all over the >globe; it is not difficult, e.g., to come up with a few possible >reasons which make WRI not keep an openly accessible list of bugs, >all more trite than world domination) The idea that an open source version of Mathematica (if it existed) would somehow give more assurance than the existing version really isn't valid. The lack of source code for Mathematica in no way prevents you from verifying any computation done with Mathematica. Mathematica's rich tool set gives you the tools to solve any computational problem without using any particular built-in function. That is you can replace any built-in function with Mathematic code using other functions. The only issue is your time and ability. The ability to replace any function with independent code gives you a method to validate any computation without having the source code. Further, most users have neither the time nor the knowledge needed to review the source code to find bugs. In fact, the time needed to review the source code adequately probably exceeds the time needed to validate a computation using a different approach/algorithm in many cases. And since bugs are simply instances of a computation giving incorrect results, an openly accessible bug list isn't needed any more than the source code. The only advantage I can see to an openly accessible bug list is that it might save time/effort spent verifying a given computation done in Mathematica is correct. === Subject: how to plot a tree assigning nodes with your own labels When I use the Funtion TreePlot[] with option VertexLabeling -> True, surely there would be labels displayed. However, if I want to designate different nodes with same label, the tree looks not so nice. How could I do? === Subject: Re: how to plot a tree assigning nodes with your own labels > When I use the Funtion TreePlot[] with option VertexLabeling -> True, > surely there would be labels displayed. However, if I want to > designate different nodes with same label, the tree looks not so nice. > How could I do? I'm not sure what you're asking for. You can use VertexRenderingFunction to design how the vertexes are displayed. vertex[pt : {x_, y_}, tag_, index_] := Text[ToString[tag] <> ( <> ToString@Head[tag] <> ), pt]; TreePlot[ {1 -> a, 1 -> 2, 2 -> apple, a -> 7, 2 -> log, a -> six, 1 -> A, A -> four, A -> Log}, VertexLabeling -> True, VertexRenderingFunction -> vertex ] === Subject: Re: max. value in a plot? expr = (6*15*(10^-6))/((x - 0)^2 + (y - 0)^2 + (0 - 0.005)^2); Plot3D[expr, {x, -0.05, 0.05}, {y, -0.05, 0.05}] The image is clipped by the default PlotRange so you cannot see the maximum Plot3D[expr, {x, -0.05, 0.05}, {y, -0.05, 0.05}, PlotRange -> All] Maximize[expr, {x, y}] NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded. >> {3.6, {x -> -2.22108555912549*^-16, y -> -1.4320914417659524*^-16}} expr2 = Rationalize[expr]; Maximize[expr2, {x, y}] {18/5,{x->0,y->0}} The min value is out at plus or minus infinity for x and/or y Minimize[expr2, {x, y}] Minimize::natt: The minimum is not attained at any point satisfying the given constraints. >> {0,{x->Indeterminate,y->Indeterminate}} Bob Hanlon Hallo, i have 2 small questions. how can i find the max. Value of the following Plot? Plot3D[ (6*15*(10^-6))/((x - 0)^2 + (y - 0)^2 + (0 - 0.005)^2), {x, -0.05, 0.05}, {y, -0.05, 0.05}] and how can i plot the range ONLY from the min to the max value? === Subject: Reading in an ASCII file written by a FORTRAN program Hello All: I didn't want to hijack another's thread about reading in fixed format files into Mathematica and I was wondering if there is a way to read FORTRAN written data. For my thesis used FORTRAN code for my number crunching, and used function calls to DISLIN to visualize that data. Now I have Mathematica, whose graphics capabilities are well beyond anything I could previously do, I would like to recreate and improve those graphs. The way I created the files of data (which I always used a .d extension, but it doesn't matter what that would be called) is demonstrated below. Please note, this is NOT binary data, but text output with no FORMAT. For example: open(unit=30,name=fnout,status='old') write(30,'(a20)') fnmod write(30,'(a20)') fnstr write(30,*) nfault,hpl,vplx,vply,taua,tauf,amuu, & tminn,tstepp,itime,TBIS,bulkms,ntm,ncycle,pdcy write(30,*) ptrad write(30,'(a1)') respfb write(30,*) (timi(n), n=1,nfault) write(30,*) (taub(n), n=1,nfault) write(30,*) (delts(n), n=1,nf) write(30,*) (cfr(n), n=1,nfault) write(30,*) (dfr(n), n=1,nfault) write(30,*) (slpdf(n), n=1,nf2) write(30,*) (slpv(n), n=1,nfault) write(30,*) (rhofcc(n), n=1,nfault) write(30,*) (islip(n), n=1,nfault) (NOTE: not all variables are the same length, some are strings, some doubles, etc.) I subsequently read back the data into FORTRAN as: open(unit=30,name=fnin,status='old') read(30,'(a20)') fnmod read(30,'(a20)') fnstr read(30,*) nfault,hpl,vplx,vply,taua,tauf,amuu, & tminn,tstepp,ntime,TBIS,bulkms,ntm,ncycle,pdcy read(30,*) ptrad read(30,'(a1)') respfb read(30,*) (timi(n), n=1,nfault) read(30,*) (taub(n), n=1,nfault) read(30,*) (delts(n), n=1,nf) read(30,*) (cfr(n), n=1,nfault) read(30,*) (dfr(n), n=1,nfault) read(30,*) (slpdf(n), n=1,nf2) read(30,*) (slpv(n), n=1,nfault) read(30,*) (rhofcc(n), n=1,nfault) read(30,*) (islip(n), n=1,nfault) So, the big question then is: How would I go about reading in the above unformatted Fortran file within Mathematica? t. === Subject: Re: about mathlink connection On 13 mar, 10:54, Jens-Peer Kuska since I have not your source code, I can't tell you what's wrong. > But my own MathLink programs do that typical when > I have given a false path or some dll can't be found. Jens On 11 mar, 10:22, Jens-Peer Kuska > typical this dialog box pops up when MathLink alone can't start the >> binary, i.e., a missing command line argumente like -mathlink >> in your string .. > Jens Hi mathematica community, > I have a c++ program in which I established a comunication with > mathematica via mathlink. > But when my program is executed, a Choose a MathLink Program to > Launch dialog box appears and ask me to choose between some > executables. This is how I established the connection: > link = MLOpenString(env,-linkname C:Wolfram ResearchMathemat= ic= > a > 6.0MathKernel.exe,&error); > Note that I have chosen to launch mathkernel.exe so why the dialog bo= x > appears and How can I get rid of this dialog box? >> - Afficher le texte des messages pr=E9c=E9dents - still appearing! : > ml = MLOpenString(env,-linkname C:Wolfram ResearchMathematica > 6.0MathKernel.exe -mathlink,&error);- Masquer le texte des messag= es pr=E9c=E9dents - - Afficher le texte des messages pr=E9c=E9dents - hi Mr Jens here is my source code: void main(){ MLENV env; int error; MLINK ml; env = MLInitialize(0); if(env == (MLENV)0) { printf(unable to initialize environment); } ml = MLOpenString(env,-linkname C:Program FilesWolfram ResearchMathematica6.0MathKernel.exe -mathlink,&error); if(ml == (MLINK)0 || error != MLEOK) { printf(unable to create link to the Kernel); } MLActivate(ml); if(!MLActivate(ml)) { printf(unable to establish communication);} return ml; } } === Subject: Re: about mathlink connection since I have not your source code, I can't tell you what's wrong. But my own MathLink programs do that typical when I have given a false path or some dll can't be found. Jens > On 11 mar, 10:22, Jens-Peer Kuska typical this dialog box pops up when MathLink alone can't start the >> binary, i.e., a missing command line argumente like -mathlink >> in your string .. >> Jens > Hi mathematica community, > I have a c++ program in which I established a comunication with > mathematica via mathlink. > But when my program is executed, a Choose a MathLink Program to > Launch dialog box appears and ask me to choose between some > executables. This is how I established the connection: > link = MLOpenString(env,-linkname C:Wolfram ResearchMathematic= > a > 6.0MathKernel.exe,&error); > Note that I have chosen to launch mathkernel.exe so why the dialog box > appears and How can I get rid of this dialog box? >> - Afficher le texte des messages pr=E9c=E9dents - still appearing! : > ml = MLOpenString(env,-linkname C:Wolfram ResearchMathematica > 6.0MathKernel.exe -mathlink,&error); > === Subject: Re: Function as return value, how to document it SetAttributes[funcBuilder, HoldFirst] funcBuilder[func_Symbol, start_, factor_] := Module[{}, Clear[func]; func[0] = start; func[x_Integer] := func[x - 1] + factor*x; func[] = empty; func::usage = ToString[func] <> [x] my help text here.] funcBuilder[myf, 1, 1]; myf[] Table[myf[i], {i, 1, 5}] ?myf empty {2,4,7,11,16} myf[x] my help text here. Bob Hanlon my function is a function builder, when it is called, it returns a function. Everything works fine, except for the help text. Here is a minimal example: funcBuilder[start_, factor_] := Module[ {localfunc}, localfunc[0] = start; localfunc[x_Integer] := localfunc[x - 1] + factor*x; localfunc[] := empty; localfunc::usage = my help text here.; localfunc ]; myf = funcBuilder[1, 1]; myf[] Table[myf[i], {i, 1, 5}] ?myf It displays localfunc$7151 instead of my help text here. Do you have a hint on how to improve this? To put this problem into a larger perspective, here is what I really want to do with this function builder. I need to read several Excel sheets and want a nice interface. I have some assumptions on the Excel sheets: data is rectangular, first row is column names, there is one column that has unique values (something like a primary key). Now I have defined a wrapper for the Import function as follows: ReadExcelSheet[file_, sheet_, pk_] := Module[{firstRow, colNameRules, data, datafunc}, data = Import[file, {Sheets, sheet}]; firstRow = First[data]; data = Rest[data]; colNameRules = MapThread[#1 -> #2 &, {firstRow, Table[i, {i, 1, Length[firstRow]}]}]; datafunc[id_] := First[Select[data, Part[#, pk /. colNameRules] == id &]]; datafunc[id_, colName_String] := Part[datafunc[id], colName /. colNameRules]; datafunc[id_, colNames_List] := Part[datafunc[id], colNames /. colNameRules]; datafunc[] := colNameRules; datafunc[Null] := data; datafunc[Null, colName_String] := Map[ Part[#, colName /. colNameRules] &, data]; datafunc[Null, colNames_List] := Map[ Part[#, colNames /. colNameRules] &, data]; datafunc (* return value *) ]; The function returns a function which allows data access like this (assuming we have a sheet with columns id and each month): ProductionData = ReadExcelSheet[myfile.xls, mysheet, id] ProductionData[id1, Jan] (* returns one number *) ProductionData[id1, {Jan, Feb}] (* returns two values *) ProductionData[Null, {id, Jan}] (* returns id and january values for all plants *) ProductionData[Null] (*returns all values, but not the headers*) ProductionData[] (* returns transformation rules column names -> list index *) I hope that this approach does not have negative side effects ?!? Also, I would be interested in different approaches to this data access problem. And, I would like to add some information of the excel sheet (file and sheet name, timestamp, some usage information). Karsten. === Subject: Re: A newbee to Mathematica >> showing the weights of each edge as is provided in Hi. I may be wrong, but I believe you have a Directed graph. Meaning that from 1-7 the weight is 2, but from 7-1 the weight is 1. I'm am not sure how you want to label this when you have different weights in different directions. Again, I may be wrong. am // MatrixForm {1,0,1,2,0,1,2} {0,0,0,0,1,1,1} {1,0,0,1,1,1,1} {0,3,1,4,1,0,1} {0,1,1,1,0,1,0} {1,1,1,0,1,0,0} {1,1,5,1,0,0,0} When you do.. GraphPlot3D[g, VertexLabeling -> True]; The graph does not show a link between 2 & 4. Although there is a '0 between 2 & 4, there is a '3 between 4 & 2. This shows the link between 2 & 4. (no double call to GraphPlot3D[am, VertexLabeling -> True] Just throwing out some additional options: g = SetEdgeLabels[g, GetEdgeWeights[g]]; ops = {VertexColor -> Red, VertexLabelColor -> Blue, VertexLabel -> True, EdgeLabel -> True, ImageSize -> 600}; ShowGraph[g, Sequence @@ ops] Note that because this is undirected, the label from 3-7 is 1, but the label from 7-3 of 5 was discarded. I'm not sure how you want to really label these edges. If you want, remove self-loops... ShowGraph[MakeSimple[g], Sequence @@ ops] One can see the one-way relationships between 1&4, and 2&4 with something like this... Type -> Directed]; ShowGraph[g, VertexLabel -> True] Again, just some additional ideas. = = = = = HTH :>) Dana DeLouis > Hi I have just started using mathematica,and therefore have a very silly question that needs an answer. > I am trying to run this: > Needs[GraphUtilities`] > Needs[Combinatorica`] > am = {{1, 0, 1, 2, 0, 1, 2}, {0, 0, 0, 0, 1, 1, 1}, {1, 0, 0, 1, 1, 1, > 1}, {0, 3, 1, 4, 1, 0, 1}, {0, 1, 1, 1, 0, 1, 0}, {1, 1, 1, 0, 1, > 0, 0}, {1, 1, 5, 1, 0, 0, 0}}; > > MatrixForm[am] > EdgeLabeling -> True] > GraphPlot3D[g] > I am getting this error message: > GraphPlot3D::grph:Graph:<11,7,Undirected> is not a valid graph. > > BASICALLY what I want to do is to generate a 3d graph from a given adjacency matrix,with the elements of the matrix showing the weights > === Subject: Re: How to map a list on function >I have a long list of integer numbers in groups of four: >list= {{10,3,5,7},{4,6,8,9},{0,8,3,6}, ...... } >or its Flatten version. >How to write a fast function g[list] which does this: >g[list] =x^10*y^3*z^5*u^7 + x^4*y^6*z^8*u^9 + y^8*z^3*u^6+ ... In[3]:= list = {{10, 3, 5, 7}, {4, 6, 8, 9}, {0, 8, 3, 6}}; Total@Inner[Power[#2, #1] &, list, {x, y, z, u}, Times] Out[4]= u^9*x^4*y^6*z^8 + u^7*x^10*y^3*z^5 + u^6*y^8*z^3 === Subject: inverse of calculation hello everyone, i need assistance in inverting a calculation. currently, i do the following: the process that produces the data. there is a model function, d(a,b,c,x), where a,b,c are parameters i twiddle to get the best fit (or ultimately let mathematica's nonlinearmodelfit do it for me). there are also other physical inputs, call them e(x), that describe parts of the system i'm studying. in the end, i plot a curve F( e(x), d(a,b,c,x) ), and by varying the model parameters i try to find the d() that makes F look the most like D. i'd like to flip this process around. that is, i'd like to invert the calculation such that i input D(x) (or a smooth interpolation of it) into Finv ( e(x), D(x) ) and get back a curve d(x). with a single function, i might just invert it. however, F() here is actually a set of nested functions F(G(H(e(x),d(x))))=96 there's a number of effects i'm modeling=96, and so i'm unsure how to proceed. heck, i'm not sure it can be done in principle. thank you very much for any help. best, erik === Subject: Re: Hash function >I bet I'm wrong in a childish way but I'm incapable to overcome the >bug. >Why does the following code return discrepant values when processing >two identical file ( CRTL + C , CRTL + V ) placed in two different >folders ? Of course, I'm looking on only the Hash part of the out, >being obviously the folder related part. >fileIdentifier[myFile_]:=Module[{ tmp , folderPos }, >folderPos = StringPosition[myFile,]//Flatten//Max; >tmp={ >FileByteCount[myFile], >Hash[myFile,SHA512], >StringJoin[ >], >StringTake[myFile,folderPos-1], >StringDrop[myFile,folderPos] >}; >Return[tmp]; >] The key issue here is you want to use FileHash not Hash for working with files. Additionally, your code can be made platform independent and more robust by making more use of built in functions. That is: fileID[filename_] := Module[{dirName = DirectoryName@filename}, {FileByteCount[filename], FileHash[filename, SHA512], Second}], StringDrop[dirName, -1], StringDrop[filename, StringLength@dirName]}] accomplishes the same thing as your code without the bug and without need to know what character is used as a path name separator. === Subject: Re: Notebook that auto-executes when opened? >>But this doesn't change the fact Mathematica implements a >>programming language which while being heavily orientated to >>mathematics is general purpose. As such, the user is expected to >>know what they are doing and Are you sure? warnings are not >>appropriate. >Many other users seem to find that warnings like this have saved >their bacon on more than one occasion, and many, many other >high-quality software products seem to contain such warnings. You are missing the point. There is a fundamental difference in say Illustrator and a programming language. With a program like Illustrator, the expectation is you are editing or creating a document interactively. Here, dialogs that warn before doing something that cannot be recovered from are reasonable. The same would be true for Mathematica *if* the only usage mode of Mathematica was a similar interactive mode. But Mathematica implements a general programming language. Such warnings add overhead any program created and halt the program for user interaction. Neither of these outcomes are desired in a programming language. So, similar warnings in a programming language are not at all reasonable. The particular function that started this sub-thread was DeleteFile. Surely, there can be no doubt as to the intent of this function. I see no need to ask a user Are you sure? with such a clearly descriptive name. Frankly, there is no viable way to protect a user who would carelessly use DeleteFile. For a careless/inattentive user, a dialog asking Are you sure? gets a click on the OK/Yes button with no real thought. And the end result is precisely the same. === Subject: BarChart - Extendng the Y-axis and labeling the endpoints Here is a BarChart (almost directly from the Mathematica Documentation): Needs[BarCharts`] thisBarChart = BarChart[{1, 2, -1.3, 2.4}] I am trying to extend the labeling of the Y-axis so that the endpoints of the Y-axs extend a little beyond the extremes of the data in the Y direction (the extremes of the data being -1.3 and 2.4) and these endpoints are labeled with multiples of the chosen increment. I believe this makes the BarChart easier to read and is aesthetically more pleasing. For example, with the above evaluation of BarChart, the labeling of the Y-axis goes from 2.0 to -1.0 in increments of 0.5 as chosen by Mathematica but the Y-axis itself extends beyond these labels. I would like to extend the labeling in both directions (positive and negative sides along the Y-axis) to the nearest integral multiple of the increment that Mathematica has chosen so the Y-axis would be extended slightly beyond the extremes of the data and the endpoints of the Y-axis would have labels. In this example, the Y-axis would be extended from 2.5 to -1.5 and the labeling would go from { -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0} to {-1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5} with the labeling being integral multiples of the chosen increment. To do this, I need to know that the automatic labeling is in increments of 0.5 (as chosen by Mathematica) and then I need to extend the endpoint labels from {-1.0, 2.0} to {-1.5, 2.5}. I can get the PlotRange that is chosen by Mathematica automatically by using AbsoluteOptions on the graphical object called thisBarChart: AbsoluteOptions[thisBarChart, PlotRange] which produces {PlotRange -> {{0.4, 4.6}, {-1.3, 2.4}}} But, I still don't know the increment that Mathematica used so that I can force the labeling to a high of 2.5 and a minimum of -1.5. There's another complication: Assuming I did know (by magic) that the chosen increment was 0.5 for the labeling I thought I could then use BarChart[{1, 2, -1.3, 2.4}, PlotRange -> {Automatic, { 2.5, -1.5}}] to extend the Y-axis endpoints with labels of -1.5, and 2.5 but this doesn't work because the endpoints of the Y-azis are not labeled. I find, through experimentation only, that what I need is: BarChart[{1, 2, -1.3, 2.4}, PlotRange -> {Automatic, {3.0, -2.0}}] and the increment for the labeling has automatically changed to 1 (the fact that the increment has changed from 0.5 to 1.0 in this case is not a problem.) How can I get Mathematica to do this in a programmatic way so that I don't need to experiment each time to (1) get the Y-axis extended a little beyond the extremes of the data and (2) the endpoints labeled with integral multiples of the chosen increment? === Subject: 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 === Subject: Re: Mathematica 7.0.1.0 and some General David could you give notebook examples of what you mean with commentary ? I'm not sure I understand and think I am missing the point [ again ]. Peter 2009/3/14 David Park Of course, in my work as a mathematician I have seen (too!) > many papers in which I could not tell why something > followed from something, or why something was equal to > something else. > ______ Ah yes! If it is a book, then for me this usually first occurs on page 3. This all brings us back to the intent of my original posting. Instead of > just thinking of Mathematica as an ancillary tool to provide material for > some other purpose, we should think of it as a primary medium for technical > development and communication. I would urge that all development and communication be done via active > dynamic Mathematica notebooks. Everything should be developed, derived, > proved or calculated ACTIVELY with no interludes of hand waving or 'word > processing'. (But there should be plenty of textual discussion.) This means > that all starting points should be gathered as definitions and rules, and > further definitions or rules will be developed and accumulated as the > exposition proceeds. This may seem to many as too much work, and some may > doubt that it can be done. It can almost always be done! It IS work, but > the > payoffs from the work are enormous. One of the payoffs is that you will be > accumulating active rules and definitions that you can use in creating > graphics and other types of presentations, and for doing further > exploration > of the subject matter. (The graphics, presentations, or further > explorations > may be the first indication of errors.) You may even find it worthwhile to > turn these routines into a package. This is one of the main fruits of your > labor. Don't let it slip through your fingers. A second enormous payoff is > that Mathematica notebooks in the active style are largely self-proofing. > Yes, it is still possible to make errors or have a clumsy approach but, > nevertheless, such notebooks are of a far higher quality and integrity than > traditional media. Many technical writers don't use active Mathematica notebooks because they > are just plain lazy. There is no other word to describe it. That is why > their work is often so difficult to follow, or sometimes wrong. (Sometimes > they rationalize this with: If the reader can't follow it, he shouldn't be > working in the field anyway. Come on! Let's invite more people in.) It is far easier for people to understand actions than to understand > 'static' diagrams or equations. We evolved to detect actions and respond to > them with our own actions. That is why a derivation that is done actively > is > easier to understand. We get from one expression to another expression by > actively applying some axiom or theorem. Gee, that might even cause a > student to actually think about the axiom and how it is used. These axioms > and theorems, in turn, are encapsulated as rules or routines. The reader of > an active notebook could see what rule or routine is used to get from point > to point in the derivation. He could use it himself. He could try it on > other cases. The reader is far less likely to get stuck at some point she > has no explanation for. Fully active Mathematica notebooks: they are the path. If we could only convince WRI to take it a little more seriously. > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ > Of course, in my work as a mathematician I have seen (too!) > many papers in which I could not tell why something > followed from something, or why something was equal to > something else. -- Peter Lindsay === Subject: Re: Mathematica 7.0.1.0 and some General Comments Of course, in my work as a mathematician I have seen (too!) many papers in which I could not tell why something followed from something, or why something was equal to something else. ______ Ah yes! If it is a book, then for me this usually first occurs on page 3. This all brings us back to the intent of my original posting. Instead of just thinking of Mathematica as an ancillary tool to provide material for some other purpose, we should think of it as a primary medium for technical development and communication. I would urge that all development and communication be done via active dynamic Mathematica notebooks. Everything should be developed, derived, proved or calculated ACTIVELY with no interludes of hand waving or 'word processing'. (But there should be plenty of textual discussion.) This means that all starting points should be gathered as definitions and rules, and further definitions or rules will be developed and accumulated as the exposition proceeds. This may seem to many as too much work, and some may doubt that it can be done. It can almost always be done! It IS work, but the payoffs from the work are enormous. One of the payoffs is that you will be accumulating active rules and definitions that you can use in creating graphics and other types of presentations, and for doing further exploration of the subject matter. (The graphics, presentations, or further explorations may be the first indication of errors.) You may even find it worthwhile to turn these routines into a package. This is one of the main fruits of your labor. Don't let it slip through your fingers. A second enormous payoff is that Mathematica notebooks in the active style are largely self-proofing. Yes, it is still possible to make errors or have a clumsy approach but, nevertheless, such notebooks are of a far higher quality and integrity than traditional media. Many technical writers don't use active Mathematica notebooks because they are just plain lazy. There is no other word to describe it. That is why their work is often so difficult to follow, or sometimes wrong. (Sometimes they rationalize this with: If the reader can't follow it, he shouldn't be working in the field anyway. Come on! Let's invite more people in.) It is far easier for people to understand actions than to understand 'static' diagrams or equations. We evolved to detect actions and respond to them with our own actions. That is why a derivation that is done actively is easier to understand. We get from one expression to another expression by actively applying some axiom or theorem. Gee, that might even cause a student to actually think about the axiom and how it is used. These axioms and theorems, in turn, are encapsulated as rules or routines. The reader of an active notebook could see what rule or routine is used to get from point to point in the derivation. He could use it himself. He could try it on other cases. The reader is far less likely to get stuck at some point she has no explanation for. Fully active Mathematica notebooks: they are the path. If we could only convince WRI to take it a little more seriously. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Of course, in my work as a mathematician I have seen (too!) many papers in which I could not tell why something followed from something, or why something was equal to something else. === Subject: Re: Mathematica 7.0.1.0 and some General Comments Absolutely true. I would say that the way to start believing a proof that is justified by software is to replicate the results, which is what physicists and other scientists do. A different team in a different laboratory using different equipment tries the same experiment. Or, preferably, a different experiment. In the case of mathematical proofs, additional confidence could be gained by using a different program. And by different program I mean not only the CAS, but also the code written on top of the CAS that performs the calculation. In any event I would think that the code that led to the proof should be made available to anyone who wishes to check the results. (Note that the Climate Audit blog is full of discussion and controversy over the fact that a lot of results used in making policy decisions in the global warming debate are based on computer models where the actual computer code is not made available to people attempting to replicate the results, so that even if the data sets are made available, the reported results can't be duplicated.) I'm not saying this will lead to computer-aided proofs being believed in general, nor am I saying that it will lead to a level of confidence that current non-computer-aided proofs have, just that in the case of any particular computer-aided proof a result replicated using different software will gain credibility. > This is a very misleading argument---a nasty sophism, I should say. And > it's quoted way too much. A piece of software is not any less buggy by > virtue of being open source. The sane approach is to accept that software are buggy, and check the > results with different methods rather than e.g. learning the theory of > indefinite integration, and start reading open source system X's source > code. (Unless your field of research happens to be indefinite > integration, of course.) Blindly trusting open source programs leads to just as bad mistakes as > blindly trusting commercial software (expect that with the current state > of scientific software, it is likely to take longer and be more painful > to obtain those bad results with open source programs than with the > popular commercial choices). === Subject: Re: Mathematica 7.0.1.0 and some General Comments On Mar 13, 4:48 am, Mariano Su=E1rez-Alvarez I don't think Mathematica should replace mathematics. It is an > important tool, but very importantly, a commercial closed-source > tool. > It costs a great deal of money and you do not know what it is doing > (although most of the time it gives correct results). Only systems > that can be considered to generally replace Mathematics have got > to be > open source (although I admit I do not use any). If at least the > basis > of Mathematica was made open-source with paid-for support from > Wolfram > that would make things a lot better. As it stands, we should not > chain > people to commercial software. > Other than people who use pencils and paper, or blackboards and >> chalk*, everyone is chained to commercial products in their >> workplaces. We need to free our minds a bit from the idea that >> software should somehow be an exception to everything else that >> occurs >> in our workplaces. Or alternatively perhaps someone can explain to m= e >> why software should be any different to scientific equipment, cars, >> dishwashers... I cannot use an open source mass spectrometer, drive = = > = >> an >> open source car [although GM and Ford are verging on open source :), >> or at least maybe publicly owned soon] etc. Well, if you come up with a proof of a theorem > which depends on non-trivial Mathematica code > to do non-trivial computations, in what way can > you possibly say that you know how the proof works, > if *you* yourself, the author of the proof, do not > know what Mathematica is really doing? Using > closed-source code simply goes against the very > spirit of open review which is essential to > the scientific endeavor. There was a recent discussion in this subject > . -- m The truth is that, on the one hand, a great many mathematicians > (perhaps the majority) rely on results of other mathematicians whose > proofs they have not fully (and sometimes not at all) understood, or > even tried to understand. Moreover, many of such proofs have only been = = > = published in a sketchy form with various parts left to the reader > and or accompanied by comments like it can be shown etc. Anyone who > does not know that must have had no contact with real world research > in mathematics. On the other hand, all algorithms use by Mathematica are standard and > can be found in books and papers. So the issue is only whether they > are correctly implemented. While we cannot check this for sure, they > are ways to check this with a very high degree of confidence, which is > at least as high as that of the correctness of proofs checked by human > mathematicians, many of which have only been read carefully by a > handful of persons. Whether you choose to believe in a purely human proof or a computer > assisted one you are always relying on trust and can never have 100% > assurance. There are cases of mathematical proofs that have been > accepted as correct for many years before it was discovered that they > contained gaps or mistakes. There are also many theorems that have > been fully proved by humans and yet if you talk to the experts you > will find out that they would not be very surprised if some day they > turn out to be incorrect or incomplete. Indeed. History is full of such events. Mathematics > is a human activity, so to expect anything else would > simply be against all evidence, and only people who > have no real understanding of the way mathematics > is done are surprised by that. But that is really unrelated to the fact that > black boxes that produce results essentially out of > the blue are quite not exactly desirable tools > for the scientific endeavor. An example: a while ago in this list there was an interesting > sys.math.mathematica/browse_frm/thread/6529a588a3fb12c4/ > bed4bcf7c952334e?lnk=gst&q=#bed4bcf7c952334e> on what Simplify really= does. > What it does is, of course, amazingly complex, but > Daniel Lichblau observed that FullSimplify can make > mistakes on measure zero sets. We do not generally regard this > phenomenon as a bug, though we reconsider on case by case basis. > The documentation certainly does not include enough information > for me to tell what generally means in this context, > and which cases were special-cased, and so on---I conjecture > that such information is not available to normal users. > Of course, in my work as a mathematician I have seen (too!) > many papers in which I could not tell why something > followed from something, or why something was equal to > something else. But: the difference between traditional computation (I do not > have a better term...) and computation done using > closed applications is that in the first, at least in principle, > there is complete openness as to what was done, while > in the second there is a party *actively* withholding > possibly relevant information. (The motivation for that > withholding is probably not confounding mathematicians > all over the globe; it is not difficult, e.g., to come up > with a few possible reasons which make WRI not > keep an openly accessible list of bugs, all more > trite than world domination) -- m Have you ever examined your compiler and understood it what it does to your code on your hard drive magnetic region/character by magnetic region/character? Isn't the compiler you use a black box to you ...and if not to you then to most people? Isn't it the case that on some level what you are doing, even with open source software or code you've written, is opaque? Whatever you use you must check and not use blindly. That is surely the point, not whether something is commercial or open source. Mike === Subject: Re: Mathematica 7.0.1.0 and some General Comments On Mar 13, 4:47 am, Dr. David Kirkby chalk*, everyone is chained to commercial products in their > workplaces. We need to free our minds a bit from the idea that > software should somehow be an exception to everything else that occurs > in our workplaces. Or alternatively perhaps someone can explain to me > why software should be any different to scientific equipment, cars, If a car gets you from A to B, in reasonable comfort, you probably don't > care too much exactly how the car works and so you are unlikely to need > the source code to prove it got you to B. You *know* it got you there - > there is no uncertainty of that fact. dishwashers... If the plates are clean, the power consumption is not too high, and it > does not make too much noise, I doubt anyone cares. There is little > point in having the source code for a dishwasher. I cannot use an open source mass spectrometer, You have a point with the mass spectrometer. People should be more > critical with a mass-spectrometer. Unlike the case of the car and > dishwasher, it is not so obvious if the results are wrong. and for mass spectrometer substitute any number of specialized scientific and engineering equipment However, I > suspect is is easier to detect problems with a mass spectrometer than > with a result from Mathematica. Read the archives of sci.math.symbolic > and you will find many examples where commercial computer algebra > systems give incorrect results. To me that means the system is working. i.e. people are not blindly accepting output from software they are checking it ...and in any case, in the context of where this thread has headed, are there no bugs reported from open source software? One obvious problem, even if the source to Mathematica was available, is > that few people would be able to make use of it. However, I suspect it > would improve the quality of the software, as some people will be able > to check it. it is one million lines of code or something isn't it? Of course people wouldn't make use of it. Solaris has improved since Sun took it from a closed source system to an > open-source one. They have stopped selling Solaris, but of course charge > for support on it. Is it any wonder that the most trusted encryption techniques are open > source? Connect to your bank to make transactions, and you will be using > SSL, the source to which is open for all to see. It would never surprise me if more and more companies or governments > insist on the source of software being available. Far too many people > are concerned about the issues of closed source software, and this > awareness is growing steadily (not just with mathematical software). > However, I can't see too many companies or governments wanting the > source for the dishwashers or cars they or their sub-contractors use. The other thing that has been ignored is scale. A model in which a company releases software as open source and charges for support/ consulting may be viable for mass market stuff like office suites or database software. There is not the scale in computer algebra. === Subject: Re: Mathematica 7.0.1.0 and some General Comments > when the student graduates he can obtain a home edition for under $300 > -- which seems affordable for someone professionally employed. If I am not mistaken, this is true when the student/individual is American or Canadian (and that is a very generous move Wolfram did). Not so in Central and South America, Europe, Asia, Australia and Africa. This is another quirk of commercial software: it usually is not equalitarian from a social POV. Science is, or at least it should be. cheers, Peltio === Subject: Re: Mathematica 7.0.1.0 and some General Comments Well, if you come up with a proof of a theorem > which depends on non-trivial Mathematica code > to do non-trivial computations, in what way can > you possibly say that you know how the proof works, > if *you* yourself, the author of the proof, do not > know what Mathematica is really doing? Using > closed-source code simply goes against the very > spirit of open review which is essential to > the scientific endeavor. There was a recent discussion in this subject > . > This is a very misleading argument---a nasty sophism, I should say. And it's quoted way too much. A piece of software is not any less buggy by virtue of being open source. People usually don't know how the software they use works *exactly*, open source or not. And they usually don't have the time or the knowledge to check it either. The sane approach is to accept that software are buggy, and check the results with different methods rather than e.g. learning the theory of indefinite integration, and start reading open source system X's source code. (Unless your field of research happens to be indefinite integration, of course.) Blindly trusting open source programs leads to just as bad mistakes as blindly trusting commercial software (expect that with the current state of scientific software, it is likely to take longer and be more painful to obtain those bad results with open source programs than with the popular commercial choices). === Subject: Re: Mathematica 7.0.1.0 and some General I think you are assuming bottomless grit and determination on the part of the hapless punter. He is prepared to invest endless effort in learning whatever language is thrown at him, whatever the syntactic idiosyncrasy, and however incomplete the documentation. The reality is that I [ is it only me ? ] rapidly lose the will to live when diverted from my main goal of problem solving by syntax issues. I guess what we need is a Babel Fish for Mathematics software. Where is Douglas Adams when you need him ? Peter 2009/3/12 George Woodrow III close, or change the direction of their products. (In my opinion, MS would > be in much better shape and useful to me if Word had stuck with version 5.2 > other than compatibility updates. ;-) However, the important thing in mathematics are the ideas. The Mathematica, > c++, or other codes are 'just' implementations. The hard part of any task is solving the problem. One the problem is > solved, the implementation can, in some sense, be termed trivial. Over the > years, I have had to implement the solution to the same problem several > different times, as the tools available changed -- from PDP-5s to my MacBook > Pro. Mathematica is an efficient means. I have to write far less code than I > would implementing a solution in c. Despite minor problems with > documentation, using Mathematica has far less hassle than dealing with a set > of open source tools. One is 'locked in' to Mathematica only if one is using the system as a > crutch: not learning how to integrate because Mathematica does it for you or > not learning how to deal with matrices. Granted, it takes time to master any > system, and 'experts' may be locked in because their job depends on knowing > the specific magic incantations for Mathematica, but this is true for almost > any job. All of us are dependent on the kindness of strangers, even those who just > possible to solve problems without re-inventing the wheel. In principle, > software tools are essentially the same. Unlike my work in the 1970s and > 1980s, I don't have to roll my own routines or design my own graphics. I see no insurmountable problem with 'changing brands'. If Mathematica > disappeared tomorrow, it would take time to learn the specifics of another > system, but my knowledge of the problem and the solutions to problems would > not change. I am reminded of the lines from a temp secretary in the movie Dave : I > learned on the Wang, and they put me on the IBM. I can't do the IBM. (This > was a 1993 movie when Wang sold intelligent typewriters.) Some people are interested in Mathematica for its own sake, just as there > are people who are interested in c++ for its own sake. For my part, I am interested in finding out things using mathematics. > Mathematica is a wonderful tool that I use on this journey, but it is only a > tool. I can use other tools, but I cannot replace my knowledge of > mathematics, logic, chemistry, philsophy, .... Mathematica, at its best, > lets me solve problems efficiently so that I have time for my real work. george woodrow > Its the danger of being locked-in to a product that people are concerned >> about. Changing chalk brand isn't going to ruin your Maths day, unless the >> chalk is rubbish of course. One can imagine there is some risk to getting >> locked-in to Mathematica or any other proprietary brand competitor. Even >> with C++, Fortran etc you can get so dependent on proprietary libraries, >> which may be black-boxes, that you'd be struggling to cope if you had to >> change brand ? >> 2009/3/11 > I don't think Mathematica should replace mathematics. It is an >> important tool, but very importantly, a commercial closed-source tool. >> It costs a great deal of money and you do not know what it is doing >> (although most of the time it gives correct results). Only systems >> that can be considered to generally replace Mathematics have got to be >> open source (although I admit I do not use any). If at least the basis >> of Mathematica was made open-source with paid-for support from Wolfram >> that would make things a lot better. As it stands, we should not chain >> people to commercial software. > > Other than people who use pencils and paper, or blackboards and > chalk*, everyone is chained to commercial products in their > workplaces. We need to free our minds a bit from the idea that > software should somehow be an exception to everything else that occurs > in our workplaces. Or alternatively perhaps someone can explain to me > why software should be any different to scientific equipment, cars, > dishwashers... I cannot use an open source mass spectrometer, drive an > open source car [although GM and Ford are verging on open source :), > or at least maybe publicly owned soon] etc. Mike *these are also commercial products of course > -- >> Peter Lindsay > -- Peter Lindsay === Subject: Re: Mathematica 7.0.1.0 and some General Comments > [...] > Well, if you come up with a proof of a theorem > which depends on non-trivial Mathematica code > to do non-trivial computations, in what way can > you possibly say that you know how the proof works, > if *you* yourself, the author of the proof, do not > know what Mathematica is really doing? Using > closed-source code simply goes against the very > spirit of open review which is essential to > the scientific endeavor. There was a recent discussion in this subject > . -- m of an effort to encourage public (and perhaps also private) funding for development of certain open source mathematical software. You will be hard pressed to find vestiges of that effort, as all relevant web pages seem to have been yanked. As to the larger issue of proof believability...that's something of a moving target. Computer verification of proofs (whether human or computer generated) is something of a hot topic, among other reasons because it is related to computer chip verification. One comment I really like comes from a practitioner in the field, John Harrison of Intel: Nothing is ever 100% certain, and a foundational death spiral adds little value. I do not claim to be entirely certain of the intended meaning, but I was present once when he said this (plenary talk at ICMS 2006). I had the strong impression he meant that one should trust those computations which are obviously not going to mess up your proof (and yes, obviously is context dependent and requires judgement). A reason this is a moving target is that an ever increasing set of difficult proofs involve hard core computer computations. Which ones do we trust, and under what circumstances? Here is an example. It is from a paper I have cited: are chosen at random in the interior of a cube. Monatshefte fur Mathematik 139:341-348. In it the author states Nonetheless the calculations require a great effort and necessarily entailed the use of a computer algebra package. We used the package Mathematica 4.0. This was to find several definite integrals. Do we trust the proof? I know enough about symbolic definite integration to not trust all such integrals as reliable. These, however, are all numeric and thus can be checked to close approximation by quadrature. Does this suffice for us to trust the proof? I believe this is a matter of opinion, and one that is gradually changing over time. Let me describe a common type of example. Many algebraic proofs can be accomplished via computation of a cylindric algebraic decomposition or a Groebner basis. In some cases there are relatively straightforward means of verifying the computations, but this is not always the case. When should we trust these computations? If they can be repeated by different programs? One thing I can say is that, despite the relative simplicity of, say, the Buchberger algorithm for Groebner bases, code to compute them can still contain bugs. Why? Because speed is important, and the effort to get good speed often adds complexity to the code. (This is true of far more basic computations such as, say integer greatest common divisors.) Neither open source nor proprietary software are immune to algorithm complexity-induced bugs. I do not defend the lack of documentation of some of the more sophisticated algorithms in Mathematica (or elsewhere for that matter, but I bear no responsibility for other software). Having such documentation would serve many useful purposes. Giving the user (or journal referee) some indication of what are the underlying methods of computation is certainly one such. The issue of open source is a different matter entirely. There are very good reasons for having open source software. In the case of mathematical software, making proofs transparent is not one of those reasons. Claims to the contrary are, well, considerably more politics than science (I'm being polite here). That complicated under-the-hood software might be available for perusal adds quite little to the process of actual verification, and moves not one iota the bar for what are those computations that obviously should be trusted. This is not an appropriate forum for a debate on proprietary vs. open source math software. I will only remark that I think the world can use substantial amounts of both, and there are places in which they can and should intersect (code libraries being an important example). Daniel Lichtblau Wolfram Research (This being largely an opinion piece, I will emphasize that I am not speaking for my employer). === Subject: Re: Mathematica 7.0.1.0 and some General Sure, there are problems with proprietary software of any kind. Companies close, or change the direction of their products. (In my opinion, MS would be in much better shape and useful to me if Word had stuck with version 5.2 other than compatibility updates. ;-) However, the important thing in mathematics are the ideas. The Mathematica, c++, or other codes are 'just' implementations. The hard part of any task is solving the problem. One the problem is solved, the implementation can, in some sense, be termed trivial. Over the years, I have had to implement the solution to the same problem several different times, as the tools available changed -- from PDP-5s to my MacBook Pro. Mathematica is an efficient means. I have to write far less code than I would implementing a solution in c. Despite minor problems with documentation, using Mathematica has far less hassle than dealing with a set of open source tools. One is 'locked in' to Mathematica only if one is using the system as a crutch: not learning how to integrate because Mathematica does it for you or not learning how to deal with matrices. Granted, it takes time to master any system, and 'experts' may be locked in because their job depends on knowing the specific magic incantations for Mathematica, but this is true for almost any job. All of us are dependent on the kindness of strangers, even those who make it possible to solve problems without re-inventing the wheel. In principle, software tools are essentially the same. Unlike my work in the 1970s and 1980s, I don't have to roll my own routines or design my own graphics. I see no insurmountable problem with 'changing brands'. If Mathematica disappeared tomorrow, it would take time to learn the specifics of another system, but my knowledge of the problem and the solutions to problems would not change. I am reminded of the lines from a temp secretary in the movie Dave : I learned on the Wang, and they put me on the IBM. I can't do the IBM. (This was a 1993 movie when Wang sold intelligent typewriters.) Some people are interested in Mathematica for its own sake, just as there are people who are interested in c++ for its own sake. For my part, I am interested in finding out things using mathematics. Mathematica is a wonderful tool that I use on this journey, but it is only a tool. I can use other tools, but I cannot replace my knowledge of mathematics, logic, chemistry, philsophy, .... Mathematica, at its best, lets me solve problems efficiently so that I have time for my real work. george woodrow > Its the danger of being locked-in to a product that people are > concerned > about. Changing chalk brand isn't going to ruin your Maths day, > unless the > chalk is rubbish of course. One can imagine there is some risk to > getting > locked-in to Mathematica or any other proprietary brand competitor. > Even > with C++, Fortran etc you can get so dependent on proprietary > libraries, > which may be black-boxes, that you'd be struggling to cope if you > had to > change brand ? 2009/3/11 I don't think Mathematica should replace mathematics. It is an > important tool, but very importantly, a commercial closed-source > tool. > It costs a great deal of money and you do not know what it is doing > (although most of the time it gives correct results). Only systems > that can be considered to generally replace Mathematics have got > to be > open source (although I admit I do not use any). If at least the > basis > of Mathematica was made open-source with paid-for support from > Wolfram > that would make things a lot better. As it stands, we should not > chain > people to commercial software. >> Other than people who use pencils and paper, or blackboards and >> chalk*, everyone is chained to commercial products in their >> workplaces. We need to free our minds a bit from the idea that >> software should somehow be an exception to everything else that >> occurs >> in our workplaces. Or alternatively perhaps someone can explain to me >> why software should be any different to scientific equipment, cars, >> dishwashers... I cannot use an open source mass spectrometer, drive >> an >> open source car [although GM and Ford are verging on open source :), >> or at least maybe publicly owned soon] etc. >> Mike >> *these are also commercial products of course > -- > Peter Lindsay === Subject: Re: Mathematica 7.0.1.0 and some General Comments > Its the danger of being locked-in to a product that people are concerned > about. Changing chalk brand isn't going to ruin your Maths day, unless the > chalk is rubbish of course. One can imagine there is some risk to getting > locked-in to Mathematica or any other proprietary brand competitor. thats a fair point but no one forces you to buy mathematica. If being locked in is that much of a concern you have other options other than purchasing Mathematica in the first place. On a more general note being locked in, or symbiotic type relationships, are a fact of life. Car part makers are locked in to the car industry. They may be the best run businesses in the country but if Ford/GM go bust so do they. I realize that's a bit of a digression but the point being that totally relying on something or someone is relatively common. At least with computer algebra you make the conscious choice from the outset whether to choose commercial or open source but having made that choice you shouldn't expect the commercial company to change their business model. Even > with C++, Fortran etc you can get so dependent on proprietary libraries, > which may be black-boxes, that you'd be struggling to cope if you had to > change brand ? ...and I would imagine that to most people who write their own code a compiler is a black box. At some level most, if not all, of us use things that are opaque to us. 2009/3/11 I don't think Mathematica should replace mathematics. It is an > important tool, but very importantly, a commercial closed-source tool. > It costs a great deal of money and you do not know what it is doing > (although most of the time it gives correct results). Only systems > that can be considered to generally replace Mathematics have got to be > open source (although I admit I do not use any). If at least the basis > of Mathematica was made open-source with paid-for support from Wolfram > that would make things a lot better. As it stands, we should not chain > people to commercial software. Other than people who use pencils and paper, or blackboards and > chalk*, everyone is chained to commercial products in their > workplaces. We need to free our minds a bit from the idea that > software should somehow be an exception to everything else that occurs > in our workplaces. Or alternatively perhaps someone can explain to me > why software should be any different to scientific equipment, cars, > dishwashers... I cannot use an open source mass spectrometer, drive an > open source car [although GM and Ford are verging on open source :), > or at least maybe publicly owned soon] etc. Mike *these are also commercial products of course -- > Peter Lindsay === Subject: Re: Mathematica 7.0.1.0 and some General Comments > thats a fair point but no one forces you to buy mathematica. If being > locked in is that much of a concern you have other options other than > purchasing Mathematica in the first place. I think that is the point of this whole subthread: that _could_ be the reason no one suggested the use of Mathematica in that group. (But learning to use the basic tools may be another explanation). cheers, Peltio === Subject: Re: Mathematica 7.0.1.0 and some General Comments > ...and I would imagine that to most people who write their own code a > compiler is a black box. At some level most, if not all, of us use > things that are opaque to us. There is a huge difference between being opaque because the information is not made available (even if for sound reasons, like profiting for the hard work made in developing the tool), and being opaque because of one's ignorance or laziness (or simply beacuse when everything seems to work noone cares). Moreover the opacity in Mathematica is way closer to the user implementation of an algorithm that the optimization choice of a compiler could ever be. cheers, Peltio === Subject: Re: Mathematica 7.0.1.0 and some General Comments >> I don't think Mathematica should replace mathematics. It is an >> important tool, but very importantly, a commercial closed-source tool. >> It costs a great deal of money and you do not know what it is doing >> (although most of the time it gives correct results). Only systems >> that can be considered to generally replace Mathematics have got to be >> open source (although I admit I do not use any). If at least the basis >> of Mathematica was made open-source with paid-for support from Wolfram >> that would make things a lot better. As it stands, we should not chain >> people to commercial software. Other than people who use pencils and paper, or blackboards and > chalk*, everyone is chained to commercial products in their > workplaces. We need to free our minds a bit from the idea that > software should somehow be an exception to everything else that occurs > in our workplaces. Or alternatively perhaps someone can explain to me > why software should be any different to scientific equipment, cars, > dishwashers... It is because 1) once made you, can make as many copies as you wish at zero cost. This > significally differs from say, cars. So because something has a small marginal cost (packaging & handling & shipping) the producer should make it open source or free? How would wolfram pay for future development, not to mention pay for HR staff, receptionists, cleaners and afford to lease its offices? ...or should a software company cease to exist once a product is developed? Do you really think we'd be using V7 of Mathematica if this was made open source in 1988? > 2) The scientific software and computers OS are UNIVERSAL tools. Nobody > wants to build your own tool on the soft/weak ground. If you write your > program for windows OS, do it mean you work for Microsoft? For free ... Electricity and water are more UNIVERSAL tools and more important than software. The marginal cost of supplying an extra quantum of electricity or an extra litre of water (except in times of drought) is, like software, virtually nil. Should these things also be free? I'm sure it would be possible to come up with plenty of other examples of (almost) zero marginal cost products which fail to attract the criticism that software does. My reason for posting was to challenge this assumption that software should somehow be different. I'm waiting for someone to make the case. I cannot use an open source mass spectrometer, drive an open source car [although GM and Ford are verging on open source :), > or at least maybe publicly owned soon] etc. These are limited/specialized tools. But thing about roads and > communication lines owned by sigle company. I doubt you could convenient > drive Fiat car on Fords highways. but nevertheless toll roads exist, owned by private companies, do they not? > Mike *these are also commercial products of course === Subject: Re: Mathematica 7.0.1.0 and some General Comments > I don't think Mathematica should replace mathematics. It is an > important tool, but very importantly, a commercial closed-source > tool. > It costs a great deal of money and you do not know what it is doing > (although most of the time it gives correct results). Only systems > that can be considered to generally replace Mathematics have got > to be > open source (although I admit I do not use any). If at least the > basis > of Mathematica was made open-source with paid-for support from > Wolfram > that would make things a lot better. As it stands, we should not > chain > people to commercial software. > Other than people who use pencils and paper, or blackboards and >> chalk*, everyone is chained to commercial products in their >> workplaces. We need to free our minds a bit from the idea that >> software should somehow be an exception to everything else that >> occurs >> in our workplaces. Or alternatively perhaps someone can explain to me >> why software should be any different to scientific equipment, cars, >> dishwashers... I cannot use an open source mass spectrometer, drive = = >> an >> open source car [although GM and Ford are verging on open source :), >> or at least maybe publicly owned soon] etc. Well, if you come up with a proof of a theorem > which depends on non-trivial Mathematica code > to do non-trivial computations, in what way can > you possibly say that you know how the proof works, > if *you* yourself, the author of the proof, do not > know what Mathematica is really doing? Using > closed-source code simply goes against the very > spirit of open review which is essential to > the scientific endeavor. There was a recent discussion in this subject > . -- m The truth is that, on the one hand, a great many mathematicians > (perhaps the majority) rely on results of other mathematicians whose > proofs they have not fully (and sometimes not at all) understood, or > even tried to understand. Moreover, many of such proofs have only been = = published in a sketchy form with various parts left to the reader > and or accompanied by comments like it can be shown etc. Anyone who > does not know that must have had no contact with real world research > in mathematics. On the other hand, all algorithms use by Mathematica are standard and > can be found in books and papers. So the issue is only whether they > are correctly implemented. While we cannot check this for sure, they > are ways to check this with a very high degree of confidence, which is > at least as high as that of the correctness of proofs checked by human > mathematicians, many of which have only been read carefully by a > handful of persons. Whether you choose to believe in a purely human proof or a computer > assisted one you are always relying on trust and can never have 100% > assurance. There are cases of mathematical proofs that have been > accepted as correct for many years before it was discovered that they > contained gaps or mistakes. There are also many theorems that have > been fully proved by humans and yet if you talk to the experts you > will find out that they would not be very surprised if some day they > turn out to be incorrect or incomplete. Indeed. History is full of such events. Mathematics is a human activity, so to expect anything else would simply be against all evidence, and only people who have no real understanding of the way mathematics is done are surprised by that. But that is really unrelated to the fact that black boxes that produce results essentially out of the blue are quite not exactly desirable tools for the scientific endeavor. An example: a while ago in this list there was an interesting sys.math.mathematica/browse_frm/thread/6529a588a3fb12c4/ bed4bcf7c952334e?lnk=gst&q=#bed4bcf7c952334e> on what Simplify really does. What it does is, of course, amazingly complex, but Daniel Lichblau observed that FullSimplify can make mistakes on measure zero sets. We do not generally regard this phenomenon as a bug, though we reconsider on case by case basis. The documentation certainly does not include enough information for me to tell what generally means in this context, and which cases were special-cased, and so on---I conjecture that such information is not available to normal users. Of course, in my work as a mathematician I have seen (too!) many papers in which I could not tell why something followed from something, or why something was equal to something else. But: the difference between traditional computation (I do not have a better term...) and computation done using closed applications is that in the first, at least in principle, there is complete openness as to what was done, while in the second there is a party *actively* withholding possibly relevant information. (The motivation for that withholding is probably not confounding mathematicians all over the globe; it is not difficult, e.g., to come up with a few possible reasons which make WRI not keep an openly accessible list of bugs, all more trite than world domination) -- m === Subject: Re: Mathematica 7.0.1.0 and some General Comments > Other than people who use pencils and paper, or blackboards and > chalk*, everyone is chained to commercial products in their > workplaces. We need to free our minds a bit from the idea that > software should somehow be an exception to everything else that occurs > in our workplaces. Or alternatively perhaps someone can explain to me > why software should be any different to scientific equipment, cars, If a car gets you from A to B, in reasonable comfort, you probably don't care too much exactly how the car works and so you are unlikely to need the source code to prove it got you to B. You *know* it got you there - there is no uncertainty of that fact. > dishwashers... If the plates are clean, the power consumption is not too high, and it does not make too much noise, I doubt anyone cares. There is little point in having the source code for a dishwasher. > I cannot use an open source mass spectrometer, You have a point with the mass spectrometer. People should be more critical with a mass-spectrometer. Unlike the case of the car and dishwasher, it is not so obvious if the results are wrong. However, I suspect is is easier to detect problems with a mass spectrometer than with a result from Mathematica. Read the archives of sci.math.symbolic and you will find many examples where commercial computer algebra systems give incorrect results. One obvious problem, even if the source to Mathematica was available, is that few people would be able to make use of it. However, I suspect it would improve the quality of the software, as some people will be able to check it. Solaris has improved since Sun took it from a closed source system to an open-source one. They have stopped selling Solaris, but of course charge for support on it. Is it any wonder that the most trusted encryption techniques are open source? Connect to your bank to make transactions, and you will be using SSL, the source to which is open for all to see. It would never surprise me if more and more companies or governments insist on the source of software being available. Far too many people are concerned about the issues of closed source software, and this awareness is growing steadily (not just with mathematical software). However, I can't see too many companies or governments wanting the source for the dishwashers or cars they or their sub-contractors use. === Subject: Re: importing fixed width data G'day, Try ReadList or use options with Import, for example, Import[file, {Text, Words}] Assuming you are using V7 you will find more information on he following page from the Help- -> Docmentation Center. tutorial/ImportingAndExportingFiles Yas > in a fixed width format. The Import[file, Table] command is the > closest I can get to what I'd like, but then the data is divided using > whitespace, so I get a lot of extraneous fields, and no way to tell > whether what Mathematica imported as two fields is actually just one > that contained a whitespace. Any ideas on how to proceed? > === Subject: importing fixed width data in a fixed width format. The Import[file, Table] command is the closest I can get to what I'd like, but then the data is divided using whitespace, so I get a lot of extraneous fields, and no way to tell whether what Mathematica imported as two fields is actually just one that contained a whitespace. Any ideas on how to proceed? === Subject: Re: importing fixed width data > in a fixed width format. The Import[file, Table] command is the > closest I can get to what I'd like, but then the data is divided using > whitespace, so I get a lot of extraneous fields, and no way to tell > whether what Mathematica imported as two fields is actually just one > that contained a whitespace. Any ideas on how to proceed? Is the problem because some of your fixed-width data fields are blank and you would like Mathematica to import a blank when the field is really blank, instead of thinking this line has fewer number of fields? Well, if you are on a Mac or Linux/Unix system you could edit the file first in a command shell window with the vi editor and change sets of continuous spaces to a comma (Mathematica will take a comma separated set of data very readily). I assume this is either a mixture of numeric and alphanumeric data or just alphanumeric data - which is it. So, for example using the vi editor on a file of data that has a fixed field width of 10, and some of the fields are all blank (and possibly several in a row) and the rest of the fields only contain numbers, first need to add a comma at the end of all non-blank-but-numeric fields with the vi command :%s/([0-9][0-9]*)/1,/g then need to change fields that are all blank (assuming 10 blanks in a row) with the vi command :%s/ /,/g which would change every set of 10 blanks to a comma to indicate an empty field. But then need to remove the comma at the end of all lines (otherwise will end up with one extra field on each line when you import into Mathematica) with the vi command :%s/,$// Then you could import into Mathematica and it should figure it out and put null items in the list so that things come out in the correct order. If you are on Windows, you can download a Windows version of the vi program called vim from http://www.vim.org/download.php and do the same thing. Make sure to edit on a copy of the file in case you make a mistake. Don't mean to be so confusing with the weird syntax of the vi commands, but if you are not familiar with using wild cards and saved patterns in vi, you might want to consult your closest vi expert or look at a book or the man pages. Hope that helps. If not, post a few typical lines from your data file and I will try and make another suggestion depending on it's structure. If the data is sensitive or confidential, just dummy up something that exhibits the same exact pattern (spaces, tabs, special characters like quotes or others are important so include them in your example). For example if the data file looked like this (note that some lines have blanks at the end and some don't but all have 7 10-wide-fields so want to make sure that Mathematica ends up with a lists that are each 7 elements in length) and all fields are right-justified: 111 44 66 211 44 66 311 44 66 411 44 66 77 would get changed to this: 111,,, 44,, 66, 211,,, 44,, 66, 311,,, 44,, 66, 411,,, 44,, 66, 77 and the first, second and third lines that appear to have 3 values to Mathematica using spaces as a filler in blank fields, in the comma version look to have the actual 7 values (but some of them are null or blank) that all lines do. Just thought of another thing you could do - use Excel (the spreadsheet program) to import the data, and it has the ability to parse the data assuming a fixed field length, then export as a comma separated file and then import directly into Mathematica. See the Excel manual or help for an explanation of how to import and parse data. -Bob === Subject: Re: Return Ambiguity > How do you determine how far Return actually returns? I have avoided > using this function after having difficult getting it to return to the > proper level of execution. In general, does it return to the nearest held expression? > The documentation is really ambiguous. I asked the same question a while back. See the thread (It's a long URL; watch for a line break that shouldn't be there.) === Subject: Re: Return Ambiguity > How do you determine how far Return actually returns? I have avoided > using this function after having difficult getting it to return to the > proper level of execution. In general, does it return to the nearest held expression? > The documentation is really ambiguous. I don't see any ambiguity. It returns one enclosing construction. === Subject: Re: Return Ambiguity Doc page quote: Return[expr] exits control structures within the definition of a function, and gives the value expr for the whole function. Most of the exaples you provide here show the use of Return not in the DEFINITION of a fuction. So, clearly not the intended use. Put them in a function definition and they work fine and as expected. See below: In[60]:= a := (Return[#]; 1) &[2] a a := Block[{}, Return[1]; 2] a a := If[True, Return[1], 2] a a := (Do[Return[1], {1}]; 2) a a := (Block[{}, Return[1]]; 2) a a := Do[Return[Evaluate[Return[1]]], {1}] a f := (Module[{}, If[True, Return[1]]]; 2); f a := 1 /. {1 :> (Return[1]; 2)} a Out[61]= 2 Out[63]= 1 Out[65]= 1 Out[67]= 2 Out[69]= 1 Out[71]= 1 Out[72]= 1 Out[74]= 1 > No ambiguity? :p What do these return? (Return[#]; 1) &[2] Block[{}, Return[1]; 2] If[True, Return[1]; 2] (Do[Return[1], {1}]; 2) (Block[{}, Return[1]]; 2) Do[Return[Evaluate[Return[1]]], {1}] f := (Module[{}, If[True, Return[1]]]; 2); f 1 /. {1 :> (Return[1]; 2)} It seems like the documentation should say: 1. Properly exits to nearest Do[...]-instruction or SetDelayed- > evaluation. > 2. Exits all other evaluations oddly by wrapping result in head > Return, including a pure function. I feel that Catch/Throw introduces significant speed overhead. > A simple return shouldn't need to invoke pattern matching. Usually, the use of Return can be avoided, however, often the > equivalent Return-less code usually has excessive indenting. I'd say a proper replacement, would be a function that returns to > nearest scoping construct, ie. Block/Module/With. === Subject: Re: Return Ambiguity No ambiguity? :p What do these return? (Return[#]; 1) &[2] Block[{}, Return[1]; 2] If[True, Return[1]; 2] (Do[Return[1], {1}]; 2) (Block[{}, Return[1]]; 2) Do[Return[Evaluate[Return[1]]], {1}] f := (Module[{}, If[True, Return[1]]]; 2); f 1 /. {1 :> (Return[1]; 2)} It seems like the documentation should say: 1. Properly exits to nearest Do[...]-instruction or SetDelayed- evaluation. 2. Exits all other evaluations oddly by wrapping result in head Return, including a pure function. I feel that Catch/Throw introduces significant speed overhead. A simple return shouldn't need to invoke pattern matching. Usually, the use of Return can be avoided, however, often the equivalent Return-less code usually has excessive indenting. I'd say a proper replacement, would be a function that returns to nearest scoping construct, ie. Block/Module/With. === Subject: Re: Return Ambiguity Don't use Return at all. It's poor style and will encourage bad habits. Just say, No! to Return. Bobby > How do you determine how far Return actually returns? I have avoided > using this function after having difficult getting it to return to the > proper level of execution. In general, does it return to the nearest held expression? > The documentation is really ambiguous. > -- DrMajorBob@bigfoot.com === Subject: Re: Return Ambiguity > A line of code at the top of a function that disposes of an unwanted > case: If[condition,Return[$Failed]]; is at least arguably easier to read > than an If[....] that spans the rest of the function. For complicated functions, I prefer separate patterns, something like: f[x_,y_]/;x> Don't use Return at all. It's poor style and will encourage bad habits. >> Just say, No! to Return. >> Bobby > How do you determine how far Return actually returns? I have avoided > using this function after having difficult getting it to return to the > proper level of execution. In general, does it return to the nearest held expression? > The documentation is really ambiguous. I hate the kind of programming advice that reads like dietary leaflets, > or a sex manual from the 1950's - full of don't's and tut-tut's! All those commands like Return, While, Do, (but maybe not Goto!) have > their place. Sometimes the logic of a program is more transparent using > one of these deprecated constructs. Different programmers may prefer > different styles, and depending on their problem, efficiency may not > even be an issue. A line of code at the top of a function that disposes of an unwanted > case: If[condition,Return[$Failed]]; is at least arguably easier to read > than an If[....] that spans the rest of the function. David Bailey > http://www.dbaileyconsultancy.co.uk > -- DrMajorBob@bigfoot.com === Subject: Re: Return Ambiguity > Don't use Return at all. It's poor style and will encourage bad habits. Just say, No! to Return. Bobby >> How do you determine how far Return actually returns? I have avoided >> using this function after having difficult getting it to return to the >> proper level of execution. >> In general, does it return to the nearest held expression? >> The documentation is really ambiguous. > I hate the kind of programming advice that reads like dietary leaflets, or a sex manual from the 1950's - full of don't's and tut-tut's! All those commands like Return, While, Do, (but maybe not Goto!) have their place. Sometimes the logic of a program is more transparent using one of these deprecated constructs. Different programmers may prefer different styles, and depending on their problem, efficiency may not even be an issue. A line of code at the top of a function that disposes of an unwanted case: If[condition,Return[$Failed]]; is at least arguably easier to read than an If[....] that spans the rest of the function. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Return Ambiguity I generally never use Return. Try using Catch and Throw, which give you much more sophisticated control of things... Also Reap and Sow are quite worth looking intto... --David http://scientificarts.com/worklife > How do you determine how far Return actually returns? I have avoided > using this function after having difficult getting it to return to the > proper level of execution. In general, does it return to the nearest held expression? > The documentation is really ambiguous. === Subject: Re: Return Ambiguity Ambiguous Documentation ? No - it must be we who are at fault.Peter 2009/3/12 Raffy using this function after having difficult getting it to return to the > proper level of execution. In general, does it return to the nearest held expression? > The documentation is really ambiguous. -- Peter Lindsay === Subject: Re: The Go Back Button doesn't work I get the behaviour described on my intel iMac running OS X 10.5.6 and Mathematica 7.0.1. I don't have other options to test. I don't think that PowerPC/Intel makes any difference here. The Show Toolbar menu item adds the toolbar. To customize it, you have to do the non-standard (for Mac OS) right click on the grey background to the toolbar to get the customize toolbar item in the contextual menu. If you don't have a mouse or trackpad with a right menu, you can use control-click to bring up the contextual menu. Oddly, I don't have the back button as the default, but with the customize panel, the default toolbar, which you can drag up to replace what is there, *does* have the back button. george I am running version 7.0.0 on a Mac G4 (non-Intel) with OSX ver > 10.5.6. However, I do NOT have the 'go back' button on the toolbar > (showing), nor > does 'Customize' give me this option. It is the same story on a Mac > G5 > running OSX 10.4.11 and Mathematica 7.0.0. I have seen the 'go back' button on a PC with Windows and > Mathematica ver > 7.0.0. Do you know if (i) this problem is specific to a Mac running version 7.0.0 ? (ii) If I update to 7.0.1 will the problem disappear? > Tom Dowling. > Forgive my ignorance, but where is this button on a Mac? It > certainly >> does > not appear on the toolbar as it used to in v5.1. I am running version 7.0 on a Power PC G4 (non-Intel). This is a long-running issue for me. Wolfram told me that they would >> e-ma= >> il > me when the 'go-back' button was replaced (after it > 'disappeared'). I > didn't realize it had returned. (I too have a lot of hyperlinks). >> If you are running 7.0.1 on Mac OS X and the back button does not >> appear in the toolbar you may need to customize the toolbar (control- >> click on the toolbar background then choose Customize Toolbar... >> from the menu) to re-add the back button. >> -Rob > > === Subject: Re: The Go Back Button doesn't work > I am running version 7.0.0 on a Mac G4 (non-Intel) with OSX ver 10.5.6. However, I do NOT have the 'go back' button on the toolbar (showing), nor > does 'Customize' give me this option. It is the same story on a Mac G5 > running OSX 10.4.11 and Mathematica 7.0.0. I have seen the 'go back' button on a PC with Windows and Mathematica ver > 7.0.0. Do you know if (i) this problem is specific to a Mac running version 7.0.0 ? (ii) If I update to 7.0.1 will the problem disappear? Mathematica 6.0.0 through 7.0.0 does not have the Back button available in the toolbar. Mathematica 7.0.1 *does* have the Back button available in the toolbar. -Rob === Subject: Re: The Go Back Button doesn't work I am running version 7.0.0 on a Mac G4 (non-Intel) with OSX ver 10.5.6. However, I do NOT have the 'go back' button on the toolbar (showing), nor does 'Customize' give me this option. It is the same story on a Mac G5 running OSX 10.4.11 and Mathematica 7.0.0. I have seen the 'go back' button on a PC with Windows and Mathematica ver 7.0.0. Do you know if (i) this problem is specific to a Mac running version 7.0.0 ? (ii) If I update to 7.0.1 will the problem disappear? Tom Dowling. > Forgive my ignorance, but where is this button on a Mac? It certainly > does > not appear on the toolbar as it used to in v5.1. I am running version 7.0 on a Power PC G4 (non-Intel). This is a long-running issue for me. Wolfram told me that they would > e-ma= > il > me when the 'go-back' button was replaced (after it 'disappeared'). I > didn't realize it had returned. (I too have a lot of hyperlinks). If you are running 7.0.1 on Mac OS X and the back button does not > appear in the toolbar you may need to customize the toolbar (control- > click on the toolbar background then choose Customize Toolbar... > from the menu) to re-add the back button. -Rob === Subject: Re: The Go Back Button doesn't work > Forgive my ignorance, but where is this button on a Mac? It certainly does > not appear on the toolbar as it used to in v5.1. I am running version 7.0 on a Power PC G4 (non-Intel). This is a long-running issue for me. Wolfram told me that they would e-ma= il > me when the 'go-back' button was replaced (after it 'disappeared'). I > didn't realize it had returned. (I too have a lot of hyperlinks). If you are running 7.0.1 on Mac OS X and the back button does not appear in the toolbar you may need to customize the toolbar (control- click on the toolbar background then choose Customize Toolbar... from the menu) to re-add the back button. -Rob === Subject: Re: The Go Back Button doesn't work Forgive my ignorance, but where is this button on a Mac? It certainly does not appear on the toolbar as it used to in v5.1. I am running version 7.0 on a Power PC G4 (non-Intel). This is a long-running issue for me. Wolfram told me that they would e-mail me when the 'go-back' button was replaced (after it 'disappeared'). I didn't realize it had returned. (I too have a lot of hyperlinks). Tom Dowling. > Hard to provide an example, since it just doesn't work, but I am told > that it does work for 7.0.1. I am upgrading right now. Kevin It works for me. Could you provide us with an example? >> I have a lot of hyperlinks in my notebooks, and occasionally use the >> back button to, well, go back to where I was. I note that in version 7, >> possibly 6 as well, that this button does not work. Any ideas? >> Kevin === Subject: Re: Maintaining a Mathematica bug list I think this is the case of the perfect being the enemy of the useful. It is not so important that every single bug be in a maintained bug list for users. It is more important that major new bugs that affect a large number of users be on a list. I could see a useful bug list being less than a few dozen items. If some relatively savvy Mathematica user wanted to maintain such a list they might publish it on MathGroup once a week, say. They might pick up the bugs from MathGroup, or once they became known, users might send bugs to them directly. But if it is something obscure and difficult to verify the list maintainer shouldn't be expected to spend a lot of time checking it, or put it on the list. Sometimes he might just say that so-and-so reported trouble with such-and-such a function. Sometimes WRI might even send him bugs, or comment or correct the list. A short list of high impact bugs would be useful. A long exhaustive list with deep analysis and verification would be too much work. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ >Presently the only way to learn about bugs is to follow MathGroup >closely, but even when I remember that I've seen a bug (that might >be relevant to me at the moment) mentioned a couple of months ago, I >cannot always find the posts that described it. Given Wolfram doesn't post bugs to Mathgroup, it is clear there has to be another way to learn of bugs which is to experience them yourself. The advantage of a bug list is that it (ideally) provides a means to check whether some unexpected result you get is a bug or not. But, without Wolfram's involvement I doubt this ideal will be achieved with a third party bug list. There are several issues. First, what criteria will be used to determine a given result is a bug? A new user might see Mathematica's failure to simplify Sqrt[x^2] to x as a bug. Mathgroup is full of posts from less experienced users labeling results as bugs more experience users know are expected and are not bugs. Assume for the moment all entries on the hypothetical bug list are truly bugs. How will the list be organized and the bugs cataloged? Given many functions in Mathematica are interdependent, a single bug could impact more than one function. Would there be a separate entry for each function affected by the bug? And for a reported bug that is validated, without the source code, how can anyone know if the bug is limited to just the specific function reported? Similarly, without the source code, how could you determine two separate reports for differing functions are really separate manifestations of the same bug? My guess is without Wolfram's involvement, the bug list will rapidly become a list of unexpected results rather than a true bug list. As a consequence, this bug list will become no more useful than Mathgroup with respect to finding information on bugs. === Subject: Re: Maintaining a Mathematica bug list >Presently the only way to learn about bugs is to follow MathGroup >closely, but even when I remember that I've seen a bug (that might >be relevant to me at the moment) mentioned a couple of months ago, I >cannot always find the posts that described it. Given Wolfram doesn't post bugs to Mathgroup, it is clear there has to be another way to learn of bugs which is to experience them yourself. The advantage of a bug list is that it (ideally) provides a means to check whether some unexpected result you get is a bug or not. But, without Wolfram's involvement I doubt this ideal will be achieved with a third party bug list. There are several issues. First, what criteria will be used to determine a given result is a bug? A new user might see Mathematica's failure to simplify Sqrt[x^2] to x as a bug. Mathgroup is full of posts from less experienced users labeling results as bugs more experience users know are expected and are not bugs. Assume for the moment all entries on the hypothetical bug list are truly bugs. How will the list be organized and the bugs cataloged? Given many functions in Mathematica are interdependent, a single bug could impact more than one function. Would there be a separate entry for each function affected by the bug? And for a reported bug that is validated, without the source code, how can anyone know if the bug is limited to just the specific function reported? Similarly, without the source code, how could you determine two separate reports for differing functions are really separate manifestations of the same bug? My guess is without Wolfram's involvement, the bug list will rapidly become a list of unexpected results rather than a true bug list. As a consequence, this bug list will become no more useful than Mathgroup with respect to finding information on bugs. === Subject: Re: Two Notebooks Open at the Same Time > That is a very interesting question. Starting with Version 6 the Help page notebooks have their own > internal > context and don't interfere with notebooks in the Global` context. So > perhaps it ought to be able to have a notebook set its own context. > But I > have no idea how to do this and I hope your question will elicit > some useful > responses from WRI or some expert. > [I'm NOT an expert on this stuff, but...] Evaluation > Notebook's Default Context is probably useful, especially the Unique to This Notebook setting. Brett Champion > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ > Hello everyone, Is it possible to have more than one notebook active at a time, that > is, so that the variables of one do not conflict with variables in > another whose names are the same. I notice that when I open a > Mathematica 7 notebook, under the Evaluation menu, the Default Kernel > is local, the Notebook's Kernel is local, and the Notebook's Default > Context is global. Do I need to change anything? > Gregory > === Subject: Re: Two Notebooks Open at the Same Time The reason I ask is that very often when I'm working on one problem, I come up with some scripts that I want to save to use later, but I need to change them slightly and document them right away because the chances of me doing it later are pretty slim. Gregory > That is a very interesting question. Starting with Version 6 the Help page notebooks have their own > internal > context and don't interfere with notebooks in the Global` context. So > perhaps it ought to be able to have a notebook set its own context. > But I > have no idea how to do this and I hope your question will elicit > some useful > responses from WRI or some expert. David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ > Hello everyone, Is it possible to have more than one notebook active at a time, that > is, so that the variables of one do not conflict with variables in > another whose names are the same. I notice that when I open a > Mathematica 7 notebook, under the Evaluation menu, the Default Kernel > is local, the Notebook's Kernel is local, and the Notebook's Default > Context is global. Do I need to change anything? > Gregory === Subject: Re: Two Notebooks Open at the Same Time That is a very interesting question. Starting with Version 6 the Help page notebooks have their own internal context and don't interfere with notebooks in the Global` context. So perhaps it ought to be able to have a notebook set its own context. But I have no idea how to do this and I hope your question will elicit some useful responses from WRI or some expert. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hello everyone, Is it possible to have more than one notebook active at a time, that is, so that the variables of one do not conflict with variables in another whose names are the same. I notice that when I open a Mathematica 7 notebook, under the Evaluation menu, the Default Kernel is local, the Notebook's Kernel is local, and the Notebook's Default Context is global. Do I need to change anything? Gregory === Subject: Re: Two Notebooks Open at the Same Time > Hello everyone, Is it possible to have more than one notebook active at a time, that > is, so that the variables of one do not conflict with variables in > another whose names are the same. I notice that when I open a > Mathematica 7 notebook, under the Evaluation menu, the Default Kernel > is local, the Notebook's Kernel is local, and the Notebook's Default > Context is global. Do I need to change anything? > Gregory You will definitely have problems using the same variables in two different open notebooks at the same time causing unexpected and difficult to resolve problems. You should read the tutorial on Modularity and the naming of things, in the Documentation Center, especially the sections on 'Contexts' and 'Modules and local variables' (and others too). There is only one Global context and by default all variables are in this Global context (well there is also a System` context so guess that is not quite correct), so that is why the same variable name in two notebooks, open at the same time, will collide with each other. Using Module[] or With[] functions to guarantee the scope of a variable will help, but you can always create a variable with its own Context by specifying the full name as xxxcontextnamexxx`variablename where xxxcontextnamexxx` is the Context and variablename is the short name of the variable and there is a $ContextPath that tells what order Contexts should be searched, that by default is System` and then Global` (note the ` aka backquote is important) and the context name can be any string I think. You can use the Context[shortvariablename] function to tell you what Mathematica thinks the context of the specified shortname of the variable is to be certain it's what you think. HTH... -Bob === Subject: ANOVA PostHoc Dunnett Hi there, ..has anyone tried to use the Dunnett test? For example: ----------------- << Statistics`ANOVA` ANOVA[{{1,1},{1,2},{2,4},{2,5},{3,2},{3,2}},PostTests -> Dunnett] ----------------- I always get: NIntegrate::singd: NIntegrate's singularity handling has failed at point {Statistics`ANOVA`Private`xx}={........ Can anyone help me here? I am currently using Mathematica 5.0 Any idea is very much appreciated! So long... Volker === Subject: Re: Comparing Corresponding Columns of Two Matrices Marvelous stuff! I'll have to study the @@ thing, but it's a happy coincidence because the depth of arrays has posed problems for me in other situations. You may be helping me kill more than one bird with a single stone Gregory > Gregory, Here is one method. Whenever I want to perform some operation on two > equal > length vectors I think of the Inner command. In your problem we are > going to > apply this twice, once to compare the elements in two columns, and > once to > accumulate a list of results for all the columns. Here is a routine to compare the elements in two columns, each > column given > by a list, to see if all the elements in the first column are > greater than > the corresponding elements in the second column. greaterColumn[column1_, column2_] := > Inner[#1 > #2 &, column1, column2, And] Try it out on two cases. greaterColumn[{2, 3, 4, 5}, {1, 2, 3, 4}] > True greaterColumn[{2, 3, 4, 5}, {1, 6, 3, 7}] > False The following will generate text xmat and ymat matrices. I make them > only 8 > rows long instead of 100. I also bias xmat to be greater than ymat > so that > we might get some True conditions. (xmat = Table[ > RandomInteger[{3, 7}], {x, 1, 8}, {y, 1, 4}]) // MatrixForm > (ymat = Table[ > RandomInteger[{0, 5}], {x, 1, 8}, {y, 1, 4}]) // MatrixForm The following then compares the two matrices column by column. Inner[greaterColumn[#1, #2] &, f @@ Transpose[xmat], > f @@ Transpose[ymat], List] There is one caveat or trick that I have used. For arrays, Inner > works like > Dot and this is not what we want. We want the two items to look like > vectors > and not arrays, so I used f@@ on the transposed matrices to change > the outer > List brackets to f, and now they no longer look like 2-dimensional > arrays, > but like 1-dimensional vectors. > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ > Hello everyone, I'm trying to develop a modest skill in mapping functions and I've > been working on this problem. Suppose I have two 100 x 4 matrices, X and Y, and I want to see > whether each value in a column of X is bigger than each value in the > corresponding column of Y. In other words, compare column 1 of X with > column 1 of Y, column 2 of X with column 2 of Y, and so on. It's easy to generate a 100 x 4 table of Booleans using Table as Table[Boole[X[[i , j]] > Y[[i, j]]], {i, 100}, {j, 4}] But what about without Table? I am able to do it for the comparison > of any one column as Boole[#[[1]] > #[[2]]] & /@ Transpose[{X[[All, ]], Y[[All, 1]]}] but I'm not sure how to extend this to other columns. Any tip would > be much appreciated. > Gregory === Subject: Re: Comparing Corresponding Columns of Two Matrices Gregory, Here is one method. Whenever I want to perform some operation on two equal length vectors I think of the Inner command. In your problem we are going to apply this twice, once to compare the elements in two columns, and once to accumulate a list of results for all the columns. Here is a routine to compare the elements in two columns, each column given by a list, to see if all the elements in the first column are greater than the corresponding elements in the second column. greaterColumn[column1_, column2_] := Inner[#1 > #2 &, column1, column2, And] Try it out on two cases. greaterColumn[{2, 3, 4, 5}, {1, 2, 3, 4}] True greaterColumn[{2, 3, 4, 5}, {1, 6, 3, 7}] False The following will generate text xmat and ymat matrices. I make them only 8 rows long instead of 100. I also bias xmat to be greater than ymat so that we might get some True conditions. (xmat = Table[ RandomInteger[{3, 7}], {x, 1, 8}, {y, 1, 4}]) // MatrixForm (ymat = Table[ RandomInteger[{0, 5}], {x, 1, 8}, {y, 1, 4}]) // MatrixForm The following then compares the two matrices column by column. Inner[greaterColumn[#1, #2] &, f @@ Transpose[xmat], f @@ Transpose[ymat], List] There is one caveat or trick that I have used. For arrays, Inner works like Dot and this is not what we want. We want the two items to look like vectors and not arrays, so I used f@@ on the transposed matrices to change the outer List brackets to f, and now they no longer look like 2-dimensional arrays, but like 1-dimensional vectors. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hello everyone, I'm trying to develop a modest skill in mapping functions and I've been working on this problem. Suppose I have two 100 x 4 matrices, X and Y, and I want to see whether each value in a column of X is bigger than each value in the corresponding column of Y. In other words, compare column 1 of X with column 1 of Y, column 2 of X with column 2 of Y, and so on. It's easy to generate a 100 x 4 table of Booleans using Table as Table[Boole[X[[i , j]] > Y[[i, j]]], {i, 100}, {j, 4}] But what about without Table? I am able to do it for the comparison of any one column as Boole[#[[1]] > #[[2]]] & /@ Transpose[{X[[All, ]], Y[[All, 1]]}] but I'm not sure how to extend this to other columns. Any tip would be much appreciated. Gregory === Subject: Re: Comparing Corresponding Columns of Two Matrices If I understand the problem correctly, then... in order of increasing speed or simplicity (I think): x = RandomInteger[{0, 3}, {10, 4}] y = RandomInteger[{0, 3}, {10, 4}] {{3, 3, 0, 3}, {3, 1, 2, 3}, {1, 2, 1, 1}, {0, 1, 3, 1}, {1, 2, 1, 2}, {0, 2, 3, 2}, {0, 1, 0, 3}, {0, 3, 1, 1}, {0, 0, 1, 1}, {0, 0, 3, 2}} {{0, 0, 3, 3}, {2, 1, 1, 1}, {1, 3, 2, 2}, {3, 1, 1, 3}, {0, 0, 2, 0}, {2, 1, 0, 2}, {2, 3, 3, 2}, {0, 0, 2, 1}, {3, 1, 2, 2}, {3, 3, 1, 1}} Map[Boole, Thread /@ Thread[Transpose@x > Transpose@y], {2}] {{1, 1, 0, 0, 1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 1, 1, 0, 1, 0, 0}, {0, 1, 0, 1, 0, 1, 0, 0, 0, 1}, {0, 1, 0, 0, 1, 0, 1, 0, 0, 1}} or Map[Boole, Positive /@ (Transpose@x - Transpose@y), {2}] {{1, 1, 0, 0, 1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 1, 1, 0, 1, 0, 0}, {0, 1, 0, 1, 0, 1, 0, 0, 0, 1}, {0, 1, 0, 0, 1, 0, 1, 0, 0, 1}} or f[a_] = Boole@Positive@a; SetAttributes[f, Listable] f /@ (Transpose@x - Transpose@y) {{1, 1, 0, 0, 1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 1, 1, 0, 1, 0, 0}, {0, 1, 0, 1, 0, 1, 0, 0, 0, 1}, {0, 1, 0, 0, 1, 0, 1, 0, 0, 1}} or f[a_] = Boole@Positive@a; SetAttributes[f, Listable] f /@ Transpose[x - y] {{1, 1, 0, 0, 1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 1, 1, 0, 1, 0, 0}, {0, 1, 0, 1, 0, 1, 0, 0, 0, 1}, {0, 1, 0, 0, 1, 0, 1, 0, 0, 1}} or Clear[f] f[a_, b_] := Boole@Positive[a - b]; SetAttributes[f, Listable] f[Transpose@x, Transpose@y] {{1, 1, 0, 0, 1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 1, 1, 0, 1, 0, 0}, {0, 1, 0, 1, 0, 1, 0, 0, 0, 1}, {0, 1, 0, 0, 1, 0, 1, 0, 0, 1}} or Clear[f] f[a_, b_] := Boole@Positive[a - b]; SetAttributes[f, Listable] Transpose@f[x, y] {{1, 1, 0, 0, 1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 1, 1, 0, 1, 0, 0}, {0, 1, 0, 1, 0, 1, 0, 0, 0, 1}, {0, 1, 0, 0, 1, 0, 1, 0, 0, 1}} Bobby > Hello everyone, I'm trying to develop a modest skill in mapping functions and I've > been working on this problem. Suppose I have two 100 x 4 matrices, X and Y, and I want to see > whether each value in a column of X is bigger than each value in the > corresponding column of Y. In other words, compare column 1 of X with > column 1 of Y, column 2 of X with column 2 of Y, and so on. It's easy to generate a 100 x 4 table of Booleans using Table as Table[Boole[X[[i , j]] > Y[[i, j]]], {i, 100}, {j, 4}] But what about without Table? I am able to do it for the comparison > of any one column as Boole[#[[1]] > #[[2]]] & /@ Transpose[{X[[All, ]], Y[[All, 1]]}] but I'm not sure how to extend this to other columns. Any tip would > be much appreciated. > Gregory > -- DrMajorBob@bigfoot.com === Subject: Re: Comparing Corresponding Columns of Two Matrices >Suppose I have two 100 x 4 matrices, X and Y, and I want to see >whether each value in a column of X is bigger than each value in the >corresponding column of Y. In other words, compare column 1 of X >with column 1 of Y, column 2 of X with column 2 of Y, and so on. >It's easy to generate a 100 x 4 table of Booleans using Table as >Table[Boole[X[[i , j]] > Y[[i, j]]], {i, 100}, {j, 4}] >But what about without Table? I am able to do it for the comparison >of any one column as >Boole[#[[1]] > #[[2]]] & /@ Transpose[{X[[All, ]], Y[[All, 1]]}] >but I'm not sure how to extend this to other columns. Any tip would >be much appreciated. While this particular problem could be solved using Map or MapThread, there is much simpler and more efficient way to get the desired result Unitize[Sign[x -y] +1] will return a matrix of 1's and 0's. Element i,j will be 1 if y[[i,j]]Copy As>Plain Text and paste into e-mail. Bobby > i'm working in the quantum optics group of the university of Leiden, > and i use mathematica 7 a lot. > we have both windows machines and macs. On a mac i was trying to > minimize the function j[s_] := Sum[F2[n1, k1, n2, k2], {n1, 0, 2 s - 1}, {k1, 0, 2 s - 1}, > {n2, 0,2s - 1}, {k2, 0, 2s - 1}] + R2[s] Where > R2[s_] := (1 - 1/=CF=80 Sum[(-1)^(n1 + 1) Subscript[z, n1], {n1, 1, 2 s - > 1}])^4 and > F2[n1_, k1_, n2_, k2_] := (-1)^(n1 + k1 + n2 + k2)/(360 =CF=80^4) (8 > =CF=80^4 - > 60 =CF=80^2 Mod[-Subscript[z, k1] + Subscript[z, n1] - Subscript[z, k2] + > Subscript[z, n2], 2 =CF=80]^2 + 60 =CF=80 Mod[-Subscript[z, k1] + > Subscript[z, > n1] - Subscript[z, k2] + Subscript[z, n2], 2 =CF=80]^3 -15 Mod[- > Subscript[z, k1] + Subscript[z, n1] - Subscript[z, k2] + Subscript[z, > n2], 2 =CF=80]^4) (sorry for the mess, on the screen the subscripts simply appear as > subscripts...) and i get certain results for s=1,2,3,4,5,etc.. > on the windows machine though, i get worse results! the version of > mathematica is the same, machineprecision value is the same, even > the .nb file is the same! (the processor is different: a dualcore2duo > on the mac and a quad core xeon on the windows machine) > The mac can work well until s=6, the windows machine can go on to > greater values, but still giving less good results. > Do you have any idea how i can solve this issue? > Filippo= > -- DrMajorBob@bigfoot.com === Subject: Re: Weird NMinimize behaviour woops sorry i didn't see that! F2[n1_,k1_,n2_,k2_]:=(-1)^(n1+k1+n2+k2)/(360 [Pi]^4) (8 [Pi]^4-60 [Pi]^2 Mod[-Subscript[z, k1]+Subscript[z, n1]-Subscript[z, k2]+Subscript[z, n2],2 [Pi]]^2+60 [Pi] Mod[-Subscript[z, k1]+Subscript[z, n1]-Subscript[z, k2]+Subscript[z, n2],2 [Pi]]^3-15 Mod[-Subscript[z, k1]+Subscript[z, n1]-Subscript[z, k2]+Subscript[z, n2],2 [Pi]]^4) R2[s_]:=(1-1/[Pi] Sum[(-1)^(n1+1) Subscript[z, n1],{n1,1,2s-1}])^4 j[s_]:=Sum[F2[n1,k1,n2,k2],{n1,0,2s-1},{k1,0,2s-1},{n2,0,2s-1}, {k2,0,2s-1}]+R2[s] there is also the condition Subscript[z, 0]=0 For example if I try: NMaximize[{1/j[4],0 =CF=80 ??? Post readable code. Use Edit>Copy As>Plain Text and paste into e-mail. Bobby >> i'm working in the quantum optics group of the university of Leiden, >> and i use mathematica 7 a lot. >> we have both windows machines and macs. On a mac i was trying to >> minimize the function >> j[s_] := Sum[F2[n1, k1, n2, k2], {n1, 0, 2 s - 1}, {k1, 0, 2 s - 1}, >> {n2, 0,2s - 1}, {k2, 0, 2s - 1}] + R2[s] >> Where >> R2[s_] := (1 - 1/=CF=80 Sum[(-1)^(n1 + 1) Subscript[z, n1], {n1, 1, >> 2 s - >> 1}])^4 >> and >> F2[n1_, k1_, n2_, k2_] := (-1)^(n1 + k1 + n2 + k2)/(360 =CF=80^4) >> (8 =CF=80^4 - >> 60 =CF=80^2 Mod[-Subscript[z, k1] + Subscript[z, n1] - Subscript[z, >> k2] + >> Subscript[z, n2], 2 =CF=80]^2 + 60 =CF=80 Mod[-Subscript[z, k1] + >> Subscript[z, >> n1] - Subscript[z, k2] + Subscript[z, n2], 2 =CF=80]^3 -15 Mod[- >> Subscript[z, k1] + Subscript[z, n1] - Subscript[z, k2] + >> Subscript[z, >> n2], 2 =CF=80]^4) >> (sorry for the mess, on the screen the subscripts simply appear as >> subscripts...) >> and i get certain results for s=1,2,3,4,5,etc.. >> on the windows machine though, i get worse results! the version of >> mathematica is the same, machineprecision value is the same, even >> the .nb file is the same! (the processor is different: a dualcore2duo >> on the mac and a quad core xeon on the windows machine) >> The mac can work well until s=6, the windows machine can go on to >> greater values, but still giving less good results. >> Do you have any idea how i can solve this issue? >> Filippo= > > -- > DrMajorBob@bigfoot.com === Subject: Weird NMinimize behaviour i'm working in the quantum optics group of the university of Leiden, and i use mathematica 7 a lot. we have both windows machines and macs. On a mac i was trying to minimize the function j[s_] := Sum[F2[n1, k1, n2, k2], {n1, 0, 2 s - 1}, {k1, 0, 2 s - 1}, {n2, 0,2s - 1}, {k2, 0, 2s - 1}] + R2[s] Where R2[s_] := (1 - 1/=CF=80 Sum[(-1)^(n1 + 1) Subscript[z, n1], {n1, 1, 2 s - 1}])^4 and F2[n1_, k1_, n2_, k2_] := (-1)^(n1 + k1 + n2 + k2)/(360 =CF=80^4) (8 =CF=80^4 - 60 =CF=80^2 Mod[-Subscript[z, k1] + Subscript[z, n1] - Subscript[z, k2] + Subscript[z, n2], 2 =CF=80]^2 + 60 =CF=80 Mod[-Subscript[z, k1] + Subscript[z, n1] - Subscript[z, k2] + Subscript[z, n2], 2 =CF=80]^3 -15 Mod[- Subscript[z, k1] + Subscript[z, n1] - Subscript[z, k2] + Subscript[z, n2], 2 =CF=80]^4) (sorry for the mess, on the screen the subscripts simply appear as subscripts...) and i get certain results for s=1,2,3,4,5,etc.. on the windows machine though, i get worse results! the version of mathematica is the same, machineprecision value is the same, even the .nb file is the same! (the processor is different: a dualcore2duo on the mac and a quad core xeon on the windows machine) The mac can work well until s=6, the windows machine can go on to greater values, but still giving less good results. Do you have any idea how i can solve this issue? Filippo= === Subject: Re: list/sequence problem: a 'keep' list to a list of 'kept' lists assume p and d are prior-vector and data: p = {False, True, False, True, False, False, True, True, True, False, True}; d = Table[i, {i, Length[p]}]; we then construct data items {dat,boolean} and put them in a list:{{dat,boolean}. Next we apply repeatedly a rule that considers two neighbours and appends the left neighbor to the list of the right one if the right list consists of one item with boolean value of True. Last, we pick out the data values: t = t //. {x1 : ___, x2 : {__}, x3 : {{_, True}}, x4___} :> {x1, x2, Append[x2, x3[[1]]], x4} ; t[[All, All, 1]] hope this helps, Daniel > I have a list of Booleans, indicating whether prior values in sequence > are to be 'kept'. I want to generate a list of accumulated 'kept' > positions for each position in the sequence. The following code > works, but I would love to see a cleaner, more obivous approach. > Anyone? In[]= keepPrior= > {False,True,False,True,False,False,True,True,True,False,True}; keptPriors=Function[aclist,If[Split[aclist][[-1,1]]==True,Range[Length > [aclist]-Length[Split[aclist][[-1]]],Length[aclist]],{Length > [aclist]}]]/@Rest[FoldList[Append,{},keepPrior]]; TableForm[Transpose[{keepPrior,ToString/@keptPriors}],TableHeadings- {Automatic,None}] > Out[]= 1 False {1} > 2 True {1, 2} > 3 False {3} > 4 True {3, 4} > 5 False {5} > 6 False {6} > 7 True {6, 7} > 8 True {6, 7, 8} > 9 True {6, 7, 8, 9} > 10 False {10} > 11 True {10, 11} === Subject: Re: Version problem with FindRoot Hi Robert, FindRoot first calls gun[x] with a symbolic argument to check if it can make simplifications. To prevent evaluation of gun with a symbolic argument, declare it so that is evaluated only for numeric arguments: gun[x_?NumericQ] := (soln = NDSolve[system[x], {w, v, f}, {n, 0, 10}])[[1, 2, 2]][10.] hope this helps, Daniel according to a short note of Alan Hayes, TJM Vol.3, issue 3 (1993 ! ) > there is a 3-liner given for solving boundary problems of ODEs with the > help of the so-called shooting method. The subsequent program system[x_]={2 w'[n]+f[n]* w[n]==0,w[n]==v'[n],v[n]==f'[n],w[0]==x > ,v[0]==0,f[0]==0 } gun:=(soln=NDSolve[system[#],{w,v,f},{n,0,10}])[[1,2,2]][10.]& FindRoot[gun[x]==1,{x,1,.5}] (* should give x->0.332058 *) works with earlier Mathematica versions 3.0, 4.2 but NOT for 5.2 (which > I am currently still using in order to finish a manuscript before I will > adapt this to version 7.0). In Mathematica version 6.0 and 7.0 FindRoot > will work again if the following (version 6 ) system option is used : SetSystemOptions[EvaluateNumericalFunctionArgument->False] There is no problem to plot the function gun[x]with Plot[gun[x],{x,0,1}] > in Mathematica. > However, in Mathematica version 5.2 FindRoot gives rise to the following > (error) message : NDSolve::ndinnt: Initial condition x is not a number or a rectangular > array of numbers. FindRoot::nlnum : The function value {-1.+v«[n][10.`] is not a list of > numbers with > dimensions {1} at {x} = {1.`}.} for any suggestion. Robert Kragler email: kragler@hs-weingarten.de > === Subject: The Go Back Button doesn't work I have a lot of hyperlinks in my notebooks, and occasionally use the back button to, well, go back to where I was. I note that in version 7, possibly 6 as well, that this button does not work. Any ideas? Kevin === Subject: Re: The Go Back Button doesn't work It works for me. Could you provide us with an example? > I have a lot of hyperlinks in my notebooks, and occasionally use the > back button to, well, go back to where I was. I note that in version 7, > possibly 6 as well, that this button does not work. Any ideas? > Kevin === Subject: Re: JLink problem, Mathematica 6, OSX, Java SE 6 (64 bit). I've just been told by someone at Wolfram that as of version 7.0.1, java6 on OS X works. I'm having a problem with JLink in Mathematica 6, on OSX 10.5, with Jav= a = > SE 6 > (64 bit). In particular, I get error messages LinkConnect::linkc: > Unable to connect to LinkObject['/Applications/Mathema<<92>>/ > m0000011741, > <<2>>]. > InstallJava::fail: A link to the Java runtime could not be > established. when first loading JLink, and later running InstallJava[] results in LinkOpen::linke: Error 19 > InstallJava::launch: The Java runtime could not be launched. Going to Java preferences, I can switch back to J2SE 5.0 (32 bit) (but > not 64 bit), after which the problems go away. For performance > reasons, I'd really prefer to be able to use a 64 bit runtime. Does > anyone know of a fix for this problem? I don't have the same problem with Mathematica 7, but for now I'm havin= g = > some > mysterious problems in Mathematia 7 (my existing packages randomly hang= ..= > .?) > that I'd like to be able to switch back for a while. ScottMorrison Open the Info.plist in Mathematica.app/SystemFiles/Links/JLink/ > JLink.app. Edit the Root/Java/JVMVersion, I changed mine to '1.5'. I > can keep the system at Java6 64bit and Mathematica still works using > the old version. Looks like 6.0.3 might fix the problem with Java6. === Subject: Re: JLink problem, Mathematica 6, OSX, Java SE 6 (64 bit). > Open the Info.plist in Mathematica.app/SystemFiles/Links/JLink/JLink.app. Edit the Root/Java/JVMVersion, I changed mine to '1.5'. I > can keep the system at Java6 64bit and Mathematica still works using > the old version. Hmm -- but the point is that I want Mathematica to use Java6! In particular, I'd like to be able to profile my Java program while it's being called from Mathematica. scott === Subject: about mathlink connection Hi mathematica community, I have a c++ program in which I established a comunication with mathematica via mathlink. But when my program is executed, a Choose a MathLink Program to Launch dialog box appears and ask me to choose between some executables. This is how I established the connection: link = MLOpenString(env,-linkname C:Wolfram ResearchMathematica 6.0MathKernel.exe,&error); Note that I have chosen to launch mathkernel.exe so why the dialog box appears and How can I get rid of this dialog box? === Subject: Re: about mathlink connection typical this dialog box pops up when MathLink alone can't start the binary, i.e., a missing command line argumente like -mathlink in your string .. Jens > Hi mathematica community, > I have a c++ program in which I established a comunication with > mathematica via mathlink. > But when my program is executed, a Choose a MathLink Program to > Launch dialog box appears and ask me to choose between some > executables. This is how I established the connection: > link = MLOpenString(env,-linkname C:Wolfram ResearchMathematica > 6.0MathKernel.exe,&error); > Note that I have chosen to launch mathkernel.exe so why the dialog box > appears and How can I get rid of this dialog box? > === Subject: Re: Maximum in a list I could not resist adding another: Last[ SortBy[mylist, Last] ] Enjoy. ADL === Subject: Re: Help Some of these could be done with Histogram, some with MatrixPlot or ArrayPlot or Raster or Image and ImageData, some you would have to program yourself with graphics primitives. You've got some reading to do, I guess. Have you tried some of the tutorials in the Mathematica documentation? If you encounter problems while reading and working your way through the Mathematica details come back here and we'll help you. On Mar 9, 12:18 pm, prageeth saraka wimalaweera 2668130 > I want to create set of Histograms.(like the link show)..Could any body > please tell me how to create a this kind of combination graph using > Mathamatica software.I`m new to Mathamatica. prageeth === Subject: Re: Careless use of Scaled leads to hard crash in V7 Yup. 7.0 for Linux x86 (32-bit) (November 11, 2008) gives nothing (an output line, but nothing there, and I can do other calculations on other lines). BUT clicking on the blank output line shows the error (caught by starting Mathematica from the command line) of: Mathematica has detected a possible internal error. If possible, please report the error to support@wolfram.com, quoting Assertion 'lines != __null' failed at LineWrapBox.c:1467, and describe in as much detail as possible what you were doing when the error occurred. with the processor stuck at around 80% and the memory slowly filling up. --C.O. > I just saw a crash in Mathematica V 7 on Mac OS X Tiger and Leopard. The > program (reproducibly) quits unexpectedly after doing the following: 1) > Evaluate > Graphics3D[{Arrowheads[Scaled[.05]], Arrow[Tube[{{0, 0, 0}, {1, 0, > 0}}, Scaled[.05]]]}] 2) > Use arrow keys to go back to previous input cell and try to delete the > occurrence of Scaled[.05] in Arrowheads, replacing it with .1 or some > other value. You may not even get this far, the crash sometimes > happens earlier. 3) > Repeat steps 1 and 2 if necessary. There briefly is an Internal Self Test Error message before the > crash wipes Mathematica off the screen. This is not exactly the most pleasant way of learning that Scaled > lengths can't be used inside Arrowhead. > I wonder if this crash also happens on other platforms. Jens > -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: Memory leak in StringSplit in Mathematica 7 Confirmed: the same thing here in V. 7 for linux. > I'm on OSX 10.5, running Mathematica 7. There's apparently a memory leak in > StringSplit -- 16 bytes get used up every call. See below for a by > hand implementation of StringSplit, and two test runs showing the > difference. The problem had caused big problems; a long run of one of my programs > was mysteriously starting to page memory unnecessarily, and switching > to the by hand implementation fixes the problem. In[135]:= StringSplitWithoutMemoryLeak[S_,V_]:=StringTake[S,#]&/ > @Partition[{1}~Join~Flatten[#+{-1,1}&/@StringPosition[S,V]]~Join~{-1}, > 2] > In[145]:= StringSplitWithoutMemoryLeak[12341234,2]==StringSplit > [12341234,2] > Out[145]= True > In[137]:= randomString:=StringJoin@@RandomChoice[{0,,1,2},10] > In[143]:= Do[Print[Memory in use: ,MemoryInUse[]];Print[Time for > 100000 StringSplits: ,AbsoluteTiming[Do[StringSplit[randomString,0], > {100000}]][[1]]],{4}] > During evaluation of In[143]:= Memory in use: 130297096 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.312322 > During evaluation of In[143]:= Memory in use: 131897496 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.345231 > During evaluation of In[143]:= Memory in use: 133497496 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.314813 > During evaluation of In[143]:= Memory in use: 135097496 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.403105 > In[144]:= Do[Print[Memory in use: ,MemoryInUse[]];Print[Time for > 100000 StringSplits: ,AbsoluteTiming[Do[StringSplitWithoutMemoryLeak > [randomString,0],{100000}]][[1]]],{4}] > During evaluation of In[144]:= Memory in use: 136701120 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.918605 > During evaluation of In[144]:= Memory in use: 136701480 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.948706 > During evaluation of In[144]:= Memory in use: 136701480 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.952957 > During evaluation of In[144]:= Memory in use: 136701480 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.916070 -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: Memory leak in StringSplit in Mathematica 7 I just got a reply from Wolfram acknowledging this bug; they say it will be fixed in the next release. > I'm on OSX 10.5, running Mathematica 7. There's apparently a memory leak = in > StringSplit -- 16 bytes get used up every call. See below for a by > hand implementation of StringSplit, and two test runs showing the > difference. The problem had caused big problems; a long run of one of my programs > was mysteriously starting to page memory unnecessarily, and switching > to the by hand implementation fixes the problem. In[135]:= StringSplitWithoutMemoryLeak[S_,V_]:=StringTake[S,#]&/ > @Partition[{1}~Join~Flatten[#+{-1,1}&/@StringPosition[S,V]]~Join~{-1}, > 2] > In[145]:= StringSplitWithoutMemoryLeak[12341234,2]==StringSplit > [12341234,2] > Out[145]= True > In[137]:= randomString:=StringJoin@@RandomChoice[{0,,1,2},10] > In[143]:= Do[Print[Memory in use: ,MemoryInUse[]];Print[Time for > 100000 StringSplits: ,AbsoluteTiming[Do[StringSplit[randomString,0], > {100000}]][[1]]],{4}] > During evaluation of In[143]:= Memory in use: 130297096 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.312322 > During evaluation of In[143]:= Memory in use: 131897496 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.345231 > During evaluation of In[143]:= Memory in use: 133497496 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.314813 > During evaluation of In[143]:= Memory in use: 135097496 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.403105 > In[144]:= Do[Print[Memory in use: ,MemoryInUse[]];Print[Time for > 100000 StringSplits: ,AbsoluteTiming[Do[StringSplitWithoutMemoryLeak > [randomString,0],{100000}]][[1]]],{4}] > During evaluation of In[144]:= Memory in use: 136701120 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.918605 > During evaluation of In[144]:= Memory in use: 136701480 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.948706 > During evaluation of In[144]:= Memory in use: 136701480 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.952957 > During evaluation of In[144]:= Memory in use: 136701480 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.916070 === Subject: Re: Memory leak in StringSplit in Mathematica 7 Hi Scott, You are exactly right, there is a small, but very unfortunate memory leak here affecting any StringSplit call. Will be fixed in next release. It's not a new bug, by the way, but it's the first time I've heard about it. Oyvind Tafjord Wolfram Research > I'm on OSX 10.5, running Mathematica 7. There's apparently a memory leak in > StringSplit -- 16 bytes get used up every call. See below for a by > hand implementation of StringSplit, and two test runs showing the > difference. The problem had caused big problems; a long run of one of my programs > was mysteriously starting to page memory unnecessarily, and switching > to the by hand implementation fixes the problem. In[135]:= StringSplitWithoutMemoryLeak[S_,V_]:=StringTake[S,#]&/ > @Partition[{1}~Join~Flatten[#+{-1,1}&/@StringPosition[S,V]]~Join~{-1}, > 2] > In[145]:= StringSplitWithoutMemoryLeak[12341234,2]==StringSplit > [12341234,2] > Out[145]= True > In[137]:= randomString:=StringJoin@@RandomChoice[{0,,1,2},10] > In[143]:= Do[Print[Memory in use: ,MemoryInUse[]];Print[Time for > 100000 StringSplits: ,AbsoluteTiming[Do[StringSplit[randomString,0], > {100000}]][[1]]],{4}] > During evaluation of In[143]:= Memory in use: 130297096 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.312322 > During evaluation of In[143]:= Memory in use: 131897496 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.345231 > During evaluation of In[143]:= Memory in use: 133497496 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.314813 > During evaluation of In[143]:= Memory in use: 135097496 > During evaluation of In[143]:= Time for 100000 StringSplits: 1.403105 > In[144]:= Do[Print[Memory in use: ,MemoryInUse[]];Print[Time for > 100000 StringSplits: ,AbsoluteTiming[Do[StringSplitWithoutMemoryLeak > [randomString,0],{100000}]][[1]]],{4}] > During evaluation of In[144]:= Memory in use: 136701120 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.918605 > During evaluation of In[144]:= Memory in use: 136701480 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.948706 > During evaluation of In[144]:= Memory in use: 136701480 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.952957 > During evaluation of In[144]:= Memory in use: 136701480 > During evaluation of In[144]:= Time for 100000 StringSplits: 3.916070 > === Subject: Re: Expiry warning breaks Workbench This is annoying, but the real problem is that it breaksWorkbench, which= can no longer start the front end. > I don't have a solution, but I seem to have a similar problem. I'm not getting an expiry warning dialogue box but when I attempt of start Workbench I get the following message: An error has occurred. See the log file ... /.WolframWorkbench/123666932633.log. (in my user directory) Unfortunately, I can't find any such directory or file. The only coincidental factor that I can think of is that I've just downloaded Mathematica 7.01. If anyone can shed any light on this it would be great. Art Diggle === Subject: Re: Notebook that auto-executes when opened? I do not know the answer to your question as it is. However, I have a very alike procedure. If you have some Mathematica notebook that already has been open, you may execute few simple commands that will open the notebook that you have in mind, open the cell groups (if any), execute all executable cells (if any) and return to the initial structure (that is close cells groups, if any). As the result you have the notebook with all operators executed when open. In case this may help you, please have a look below: nb1 = NotebookOpen[ Full_path_to_your_notebook_to_be_open_and_executed] (* This opens your notebook *) FrontEndTokenExecute[nb1, SelectAll] (* This selects all cells in it in order to... *) FrontEndTokenExecute[nb1, OpenCloseGroup] (* ...open all cell groups, if any *) FrontEndTokenExecute[nb1, EvaluateCells] (* ...and execute all executable cells *) FrontEndTokenExecute[nb1, SelectAll] (* This again selects all cells in it in order to... *) FrontEndTokenExecute[nb1, SelectionCloseAllGroups] (* ...close all cell groups to represent your notebook in a most compact form *) You may need or may not need the last two steps. If you have no cell group structure, you do not need also the step 3. Have fun and success, Alexei > Possible to set an option for a notebook such that it automatically > begins executing when opened, that is, when the nb icon is dbl-clicked > on the desktop, or however else files are opened in the operating system > that's being used? I guess I'm also assuming here an OS which, along with opening the file > itself, if necessary first opens the app which executes the file, since > that's the only type of OS that I'm familiar with. Are there any > Mathematica compatible operating systems that don't do this? > -- 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: Starting Mathematica without GUI Hi Jochen, > i would like to know, if it is possible to start Mathematica > without GUI, only by using command line interface? Sure. Look for Math or MathKernel in MAthematica's home directory. The former is suitable for consoles while the latter is (perhaps) more suitable for copying input in Windows system. YMMV with either choice. Dave. === Subject: Re: Starting Mathematica without GUI i would like to know, if it is possible to start Mathematica without > GUI, only by using command line interface? We need to optimise the time of compilation. J.A. > The Math command will start Mathematica in a command box (in appearance rather like running under the old DOS). However, unless you are very short of memory, you will not gain any appreciable performance (I am not quite sure what you mean by 'compilation' - are you referring to the Compile command?). This is because the GUI frontend starts the kernel as a separate process, and it is the latter that does the calculations, and which you start directly by executing Math. The usual reason to want to avoid the GUI is because you want to perform tasks as a batch, or because your program supplies an alternative GUI (e.g. Java) and uses Mathematica invisibly. In this latter case, it is often cleaner to start the kernel via MathLink. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Forgets Variables? Ok Raffy, your suggestion helped me a lot at least i could get a step further. I would love to make functions out of some of my procedures, nevertheless i get often times .. or tag .. is protected error. Well that shouldn't matter to much as it should work just like this too. I suspect that the problem is that I'm calling my callNormValue out of a sum function ... and callNormValue consists of 2 other Sum functions. Is it possible that the nested Sum functions might cause trouble? there you see how i call callNormValue (with ReleaseHold.. as it otherwise wouldn't work at al, model35S contains a statement describing a mathematical modell) to normalize my model sumfunc = Sum[ ( (model35S /. {t -> tsum5})/(ReleaseHold[ callNormValue /. {lifetime35S -> 15, P -> 0.7}]) - (interpolatedExpData35S[tsum5]) )^2 , {tsum5, 60, 900, 60}]; execute the above statement with: sumfunc /. {P -> 0.7, lifetime35S -> 15} gives me a result... so but to get the thing to work i need to have the values which i set when i call sumfunc therefore: Sumfunc = Sum[ ( (model35S /. {t -> tsum5})/(ReleaseHold[ callNormValue /. {lifetime35S -> lifetime35S, P -> P}]) - (interpolatedExpData35S[tsum5]) )^2 , {tsum5, 60, 900, 60}]; execute the above statement with: sumfunc /. {P -> 0.7, lifetime35S -> 15} but in this case i just get my not evaluated statement back maybe someone has something generally to say about that Ktota > report here again. This model evolved over time.. i think i will have > also to spend to optimize it as Bob suggests.. his suggestions are > very nice... i'm busy learning Mathematica it seems to be a very > helpfull tool ;). > Ktota > I can't get the first statement to execute (in the time I'm willing to = > wait). If you gave us the values of maxX, eqTime, v, lifetime27SA, et > cetera, we'd waste a lot less time guessing what your problem might be. If you want help, ALWAYS start us off where you are. Don't make us > flounder around where you've already been. Because, of course, why should= > we? That said, I'd start by simplifying until the code is understandable, at = > which point the error will reveal itself. For instance, this: If[v*(tsum - lifetime35S - eqTime) < 4000, > v*(tsum - lifetime35S - eqTime), 4000] is equivalent to the simpler (and faster) Min[v*(tsum - lifetime35S - eqTime), 4000] Similarly, this expression: If[v*(tsum - eqTime) < 4000, Max[v*(tsum - eqTime), 0], 4000] is equivalent to Max[0, Min[v*(tsum - eqTime), 4000]] Next, it's easy to see that If[v*(tsum2 - eqTime) < 4000, > Sum[Max[v*(tsum - eqTime), 0], {tsum, tsum2 - lifetime27SANTC + 1, > tsum2}], > Sum[Max[0, Min[v*(tsum - eqTime), 4000]], {tsum, > tsum2 - lifetime27SANTC + 1, tsum2}]] is equivalent to Clear[q] > q[ts_] := v*(ts - eqTime); > If[q@tsum2 < 4000, > Sum[Max[q@tsum, 0], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}], > Sum[Max[0, Min[q@tsum, 4000]], {tsum, tsum2 - lifetime27SANTC + 1, > tsum2}]] and that's equivalent to (since the Sums have the same limits): Clear[q] > q[ts_] := v*(ts - eqTime); > Sum[If[q@tsum2 < 4000, Max[q@tsum, 0], > Max[0, Min[q@tsum, 4000]]], {tsum, tsum2 - lifetime27SANTC + 1, > tsum2}] Similarly, the first If statement: If[v*(tsum2 - lifetime35S - eqTime) < 4000, > Sum[Max[v*(tsum - lifetime35S - eqTime), 0], {tsum, > tsum2 - lifetime27SA + 1, tsum2}], > Sum[Min[v*(tsum - lifetime35S - eqTime), 4000], {tsum, > tsum2 - lifetime27SA + 1, tsum2}]] is equivalent to Clear[q] > q[ts_] := v*(ts - lifetime35S - eqTime); > Sum[If[q@tsum2 < 4000, Max[q@tsum, 0], Min[q@tsum, 4000]], {tsum, > tsum2 - lifetime27SA + 1, tsum2}] Combining both tricks into one reduces the original expression to: Clear[q] > q[life_][ts_] := v (ts - life - eqTime) > callNormValue = > 60/maxX Sum[ > Sum[If[q[lifetime35S]@tsum2 < 4000, Max[q[lifetime35S]@tsum, 0= > ], > Min[q[lifetime35S]@tsum, 4000]], {tsum, > tsum2 - lifetime27SA + 1, tsum2}]*(1 - P) + > Sum[If[q[0]@tsum2 < 4000, Max[q[0]@tsum, 0], > Max[0, Min[q[0]@tsum, 4000]]], {tsum, > tsum2 - lifetime27SANTC + 1, tsum2}]*P, {tsum2, 60, t2= > , 60}]; That still won't evaluate without values for all the parameters, but > you're the only one that knows those, or even knows what ranges they migh= > t > lie in. One trick you MIGHT pull, however, is this: Clear[q] > q[life_][ts_] := v (ts - life - eqTime) > callNormValue = > 60/maxX sum[ > sum[If[q[lifetime35S]@tsum2 < 4000, Max[q[lifetime35S]@tsum, 0= > ], > Min[q[lifetime35S]@tsum, 4000]], {tsum, > tsum2 - lifetime27SA + 1, tsum2}]*(1 - P) + > sum[If[q[0]@tsum2 < 4000, Max[q[0]@tsum, 0], > Max[0, Min[q[0]@tsum, 4000]]], {tsum, > tsum2 - lifetime27SANTC + 1, tsum2}]*P, {tsum2, 60, t2= > , 60}]; (Now the statement executes.) callNormValue /. {lifetime35S -> 17, P -> 0.7, t2 -> maxX, sum -> Sum} (The other parameters still need values, but those could be added to the = > rule list.) Bobby Hi there, i have the following procedure: callNormValue = (Sum[ > If[v*(tsum2 - lifetime35S - eqTime) < 4000, > Sum[Max[v*(tsum - lifetime35S - eqTime), 0], {tsum, > tsum2 - lifetime27SA + 1, tsum2, 1}], > Sum[If[v*(tsum - lifetime35S - eqTime) < 4000, > v*(tsum - lifetime35S - eqTime), 4000], {tsum, > tsum2 - lifetime27SA + 1, tsum2, 1}]]*(1 - P) + > If[v*(tsum2 - eqTime) < 4000, > Sum[Max[v*(tsum - eqTime), 0], {tsum, > tsum2 - lifetime27SANTC + 1, tsum2, 1}], > Sum[If[v*(tsum - eqTime) < 4000, Max[v*(tsum - eqTime),= > 0], > 4000], {tsum, tsum2 - lifetime27SANTC + 1, tsum2, 1= > }]]* > P, {tsum2, 60, t2, 60}])/(maxX/60); i call it with: > callNormValue /. {lifetime35S -> 17, P -> 0.7, t2 -> maxX} it gives me a proper result, but as soon i change t2 to maxX in the Ok, certainly i can rewrite my program... nevert > first expression (where i do the sums) it doesn't evaluate the the > procedure anymore (maxX has a global value already set). I have > actually quite a lot of trouble to hand over values to this > procedure.. and i have no idea why it doesn't work. (for except lifetime35S,P and t2 all the variables have a set value) thank you, Ktota -- > DrMajor...@bigfoot.com === Subject: Re: Please help, factorisation question > Hi all, > i am having trouble finding a way to do the following: i have a list of numbers P, and i need ask the question: which members of the set are products of other members and what are their factorisations by these other members. i notice there are graph/tree functions in mathematica to represent this sort of thing visually but im at a loss for how to implement them anyway for an example P = {a, b, c, d} OUTPUT: a -> c^2 * d > b -> c * d^2 > c -> c > d -> d Good day, Here is one possible solution using Tuples [it may not be very fast and... the output is not exactly what you wished ]: In[1]:= fac[numbers_List, oneNumber_Integer] := Module[{factors, factors2, factors3}, factors = {}; factors2 = Select[numbers, Divisible[oneNumber, #] &]; Do[factors3 = Select[Tuples[factors2, n], Times @@ # == oneNumber &]; If[factors3 == {}, Break[]]; factors = Join[factors, Union[Sort /@ factors3]], {n, 2, Length[factors2]}]; factors]; In[2]:= numbers = {2, 3, 6, 12, 5, 30, 10, 15, 11, 13}; In[3]:= {#, fac[numbers, #]} & /@ numbers Out[3]= {{2, {}}, {3, {}}, {6, {{2, 3}}}, {12, {{2, 6}, {2, 2, 3}}}, {5, {}}, {30, {{2, 15}, {3, 10}, {5, 6}, {2, 3, 5}}}, {10, {{2, 5}}}, {15, {{3, 5}}}, {11, {}}, {13, {}}} V.Astanoff === Subject: Re: The Go Back Button doesn't work > I have a lot of hyperlinks in my notebooks, and occasionally use the > back button to, well, go back to where I was. I note that in version 7, > possibly 6 as well, that this button does not work. Any ideas? > Kevin Upgrade to 7.0.1. You should find that the button is once again working in 7.0.1. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: MatrixRank[m, Modulus -> 5] is broken Hi Daniel, what you write is o.k. But Ilan has a more interesting fact. Lets call the original and the augmented matrix m1,m2. The rank of m1 drops from 5 to 4 when one uses modulo 5. That this is possible is not hard to see. However, more interesting: in augmenting m1 mod 5 to m2 mod 5 the rank is increased, whereas in R it is NOT increased. Ilan then reasons that if the additional raw is linear dependent on m1 in R it must be linear dependent on m1 mod 5. However, this is false. The reason is that by taking mod 5 we may map a component to zero, thereby loosing a dimension. Here is an example: m1={{1,0,0,0,0},{0,1,0,0,0},{0,0,1,0,0},{0,0,0,1,0},{0,0,0,0,5}} Additional raw: v={0,0,0,0,1} MatrixRank[m1] == MatrixRank[m2] == 5 MatrixRank[m1, Modulus -> 5] == 4 and MatrixRank[m2, Modulus -> 5] ==5 Daniel (Huber) >> I have a strange problem. >> I ask for MatrixRank of matrix over the reals without Modulus and I get some number, assume 5; >> next I add a raw into this matrix and ask for the rank and I get 5; >> next I do both calculations using Modulus -> 7 and get 4 and 5. >> There is a problem!!! >> if a the additional raw was linear depended over the reals, it m-u-s-t be linear depended over Modulus because a linear combination for this extra row using other rows is valid when we apply Modulus -> 7. >> Therefor I suppose to get 4 and 4. >> what is the conclusion? A linear dependency over the rationals can evaporate over a field of > positive characteristic (by becoming, in effect, 0==0). Below is an example. In[75]:= mat1 = {{3, 4}, {4, 3}}; > mat2 = Append[mat1, {1, 1}]; > {MatrixRank[mat1], MatrixRank[mat2], MatrixRank[mat1, Modulus -> 7], > MatrixRank[mat2, Modulus -> 7]} Out[77]= {2, 2, 1, 2} Daniel Lichtblau > Wolfram Research > === Subject: Re: Quantum Mathematica sneak preview of commutator and operator Good job , Jose. I look forward to using the new version when it will be available === Subject: Re: Polygon with holes HK Am 10.03.2009 um 11:34 schrieb Harrie Kraai: > Hi group, Does anyone know of a facility for Polygons (graphics) with holes > inside? > I guess there is no such thing as an oriented polygon in Mathematica? > Or a polygon consisting of disjoint lines (inner and outer contours, > clockwise and counterclockwise)? I can see that it is possible to connect outer and inner contours > using > a dummy line, but that is not so easy to program in a generic way. Solutions such as creating an artificial hole by another Polygon in > the > background colour are not really acceptable. Polygon's with holes would be very useful for maps etc. > HK > general you may find the general polygon clipping library of interest for your purpose. It can deal with polygons with holes. http://www.cs.man.ac.uk/~toby/alan/software/ Frank === Subject: Polygon with holes Hi group, Does anyone know of a facility for Polygons (graphics) with holes inside? I guess there is no such thing as an oriented polygon in Mathematica? Or a polygon consisting of disjoint lines (inner and outer contours, clockwise and counterclockwise)? I can see that it is possible to connect outer and inner contours using a dummy line, but that is not so easy to program in a generic way. Solutions such as creating an artificial hole by another Polygon in the background colour are not really acceptable. Polygon's with holes would be very useful for maps etc. HK === Subject: Re: Polygon with holes > Does anyone know of a facility for Polygons (graphics) with holes inside? Sure. Try this: With[{pts = {{0.1, 0.1}, {0.1, 0.9}, {0.9, 0.9}, {0.9, 0.1}, {0.1, 0.1}, {0.3, 0.3}, {0.7, 0.3}, {0.7, 0.7}, {0.3, 0.7}, {0.3, 0.3}}}, Show[Graphics[Polygon[pts]], PlotRange -> {{0, 1}, {0, 1}}]] Pillsy === Subject: Re: Polygon with holes > Does anyone know of a facility for Polygons (graphics) with holes inside? > I guess there is no such thing as an oriented polygon in Mathematica? > Or a polygon consisting of disjoint lines (inner and outer contours, > clockwise and counterclockwise)? I can see that it is possible to connect outer and inner contours using > a dummy line, but that is not so easy to program in a generic way. This is currently the only way to achieve the desired affect. MultiContourPolygon[polys_List] := Module[ {contours = Append[#, First[#]] & /@ polys}, { Polygon@Join[Join @@ contours, Reverse[First /@ contours]], Line[contours] } ] Graphics@MultiContourPolygon[{{{0, 0}, {0, 1}, {1, 1}, {1, 0}}, {{.25, .25}, {.75, .25}, {.75, .75}, {.25, .75}}, {{.4, .4}, {.6, .4}, {.6, .6}, {.4, .6}}}] > Solutions such as creating an artificial hole by another Polygon in the > background colour are not really acceptable. Polygon's with holes would be very useful for maps etc. Agreed. -Rob === Subject: Slicing a surface I've generated a surface in Mathematica 6 by solving some simultaneous equations for three variables (x[s,t], y[s,t] and z[s,t]) and parametric plotting the variables against each other, with s and t the surface parameters. I want to get a one-dimensional cross-section of the surface, ie a slice through constant z, but I don't know how to do this. Taking a constant s or t is the best I can do, but isn't nearly the same. I'd like the line cross-section to be displayed as a flat 2D graph, rather than be embedded in the original 3D space. Any suggestions on how to do this? James === Subject: Re: typsetting bug still present in It is indeed a Mathematica bug, and it has further consequences, as we can see typing escape int escape f[x] DifferentialD[x] (that is: typing the integral sign followed by f[x] and then typing DifferentialD[x]). The integral is not recognized and is considered a syntax error. But it shouldn't! === Subject: Re: typsetting bug still Bobby, I'm here to tell you: Its true. Peter 2009/3/9 DrMajorBob The problem is this. First, look up the documentation: ?DifferentialD Now, try it: DifferentialD[x] Do you get the same thing as the documentation says you should? Andrzej Kozlowski > In version 7.0 on XP I cannot see any bug. >> What is the problem? > > -- > DrMajorBob@bigfoot.com -- Peter Lindsay === Subject: Re: typsetting bug still present in Mathematica 7.01 I meant it is a simple bug in Mathematica and not a bug in Mathematica's documentation. It always amazes me to see how much effort some people will make to misunderstand the simplest things (and written in plain English). But I have to confess that in this particular case I am not at all surprised. Andrzej Kozlowski > I meant to say... do what the documentatin says, and it DOESN'T > work, but do something completely different, and it DOES work? And that is certainly not a problem with the documentation, but > rather an oversight? Sorry, totally missing the distinction, here. Bobby >> Umm... what's that again, in English? Do what documentation says, >> and it works, do something else and it DOES work? >> Is that it? >> Bobby > This time it is certainly not a problem with the documentation. What > the documentation says is exactly what should happen: in fact it is > the only sensible thing that could happen. What actually happens is > not at all sensible since is the result of an oversight, which, in > fact, can be fixed with a single line of code: MakeBoxes[DifferentialD[x_],fmt_]:=RowBox[{ > [DifferentialD],ToBoxes[x,fmt]}] But, of course, it should not be left to the user to have to do it. Andrzej Kozlowski >> Documentation that isn't accurate? >> I can NOT believe it. >> Bobby > The problem is this. First, look up the documentation: ?DifferentialD Now, try it: DifferentialD[x] Do you get the same thing as the documentation says you should? Andrzej Kozlowski > In version 7.0 on XP I cannot see any bug. >> What is the problem? > > -- >> DrMajorBob@bigfoot.com > > -- > DrMajorBob@bigfoot.com === Subject: Re: typsetting bug still present in Mathematica 7.01 I meant to say... do what the documentatin says, and it DOESN'T work, but do something completely different, and it DOES work? And that is certainly not a problem with the documentation, but rather an oversight? Sorry, totally missing the distinction, here. Bobby > Umm... what's that again, in English? Do what documentation says, and it > works, do something else and it DOES work? Is that it? Bobby >> This time it is certainly not a problem with the documentation. What >> the documentation says is exactly what should happen: in fact it is >> the only sensible thing that could happen. What actually happens is >> not at all sensible since is the result of an oversight, which, in >> fact, can be fixed with a single line of code: >> MakeBoxes[DifferentialD[x_],fmt_]:=RowBox[{ >> [DifferentialD],ToBoxes[x,fmt]}] >> But, of course, it should not be left to the user to have to do it. >> Andrzej Kozlowski > Documentation that isn't accurate? I can NOT believe it. Bobby > The problem is this. First, look up the documentation: >> ?DifferentialD >> Now, try it: >> DifferentialD[x] >> Do you get the same thing as the documentation says you should? >> Andrzej Kozlowski > In version 7.0 on XP I cannot see any bug. > What is the problem? > -- > DrMajorBob@bigfoot.com -- DrMajorBob@bigfoot.com === Subject: Re: typsetting bug still present in Mathematica 7.01 Umm... what's that again, in English? Do what documentation says, and it works, do something else and it DOES work? Is that it? Bobby > This time it is certainly not a problem with the documentation. What > the documentation says is exactly what should happen: in fact it is > the only sensible thing that could happen. What actually happens is > not at all sensible since is the result of an oversight, which, in > fact, can be fixed with a single line of code: MakeBoxes[DifferentialD[x_],fmt_]:=RowBox[{ > [DifferentialD],ToBoxes[x,fmt]}] But, of course, it should not be left to the user to have to do it. Andrzej Kozlowski >> Documentation that isn't accurate? >> I can NOT believe it. >> Bobby > The problem is this. First, look up the documentation: ?DifferentialD Now, try it: DifferentialD[x] Do you get the same thing as the documentation says you should? Andrzej Kozlowski > In version 7.0 on XP I cannot see any bug. >> What is the problem? > > -- >> DrMajorBob@bigfoot.com > > -- DrMajorBob@bigfoot.com === Subject: simple vector plots I have a stream of data points, in the sense that they follow a curve, like if I had them drawn by a 2D parametric plot. I want to plot some arrows like I see when I look at some ListStreamPlot exemples. What's the fastest way? If I use ListVectorPlot the arrows are huge, while StreamScale and StreamPoints doesn't help me, it seems. Davide === Subject: Re: simple vector plots data = Table[{Cos[t], Sin[t]} // N, {t, 0, Pi/2, Pi/32}]; Manipulate[ Graphics[{Arrowheads[Table[scale, {n}]], Arrow[data]}], {n, 1, 10}, {{scale, 0.1}, 0, 1}] ?? Jens > I have a stream of data points, in the sense that they follow a curve, > like if I had them drawn by a 2D parametric plot. > I want to plot some arrows like I see when I look at some > ListStreamPlot exemples. > What's the fastest way? > If I use ListVectorPlot the arrows are huge, while StreamScale and > StreamPoints doesn't help me, it seems. > Davide > === Subject: read real*8 binary This binary file I could read without problems using Import[....Real32]; But when I changed real to real*8 in the fortran program I could not read the file anymore (I used Real64 instead of Real32), meaning I get numbers like 10^275. I used the same fortran compiler (ifort 10) and the same computer (Mac Pro) in both computations. Anyone has an idea why this does not work??? Jan === Subject: Piechart labels Mathematica 7 Hello all, I'm creating pie charts with sector labels but unfortunately the labels are partially hidden by the next section of the pie chart because the slice itself is rather narrow. Is there a way to place labels such that the label for a narrow slice isn't partially obscured by the next one? I've searched the documentation and the forum but haven't been able to figure this out. This is the code I'm using. varAFreq={{Alive, 41169}, {Dead, 1916}, {Missing, 2009}}; PieChart[varAFreq[[All, 2]], ImageSize -> Medium, ChartStyle -> {LightGreen, Red, LightRed}, PlotLabel -> Column[{Style[Phase I Trees, Bold, 14], Style[Row[{ (, NumberForm[Total[varAFreq[[All, 2]]], DigitBlock -> 3], trees surveyed)}], Italic, 14]}], ChartLabels -> Placed[N[varAFreq[[All, 2]]/Total[varAFreq[[All, 2]]]*100] %, RadialCallout, Style[NumberForm[#, {3, 1}], 12] &], SectorOrigin -> {.5 Pi, -1}, LabelingFunction -> (Placed[ Style[NumberForm[#, DigitBlock -> 3], Italic, 12], RadialCenter] &)] -jackie === Subject: Re: Piechart labels Mathematica 7 varAFreq = {{Alive, 41169}, {Dead, 1916}, {Missing, 2009}}; pc = PieChart[varAFreq[[All, 2]], ImageSize -> Medium, ChartStyle -> {LightGreen, Red, LightRed}, PlotLabel -> Column[{Style[Phase I Trees, Bold, 14], Style[Row[{ (, NumberForm[Total[varAFreq[[All, 2]]], DigitBlock -> 3], trees surveyed)}], Italic, 14]}], ChartLabels -> Placed[N[varAFreq[[All, 2]]/Total[varAFreq[[All, 2]]]*100] %, RadialCallout, Style[NumberForm[#, {3, 1}], 12] &], SectorOrigin -> {.5 Pi, -1}, LabelingFunction -> (Placed[ Style[NumberForm[#, DigitBlock -> 3], Italic, 12], RadialOuter] &)] and Show[DeleteCases[pc, _Text, Infinity], Graphics[Cases[cc , _Text, Infinity]]] will bring the text labels in front, but destroy the dynamic functionality of the pie chart Jens > Hello all, I'm creating pie charts with sector labels but unfortunately the labels are > partially hidden by the next section of the pie chart because the slice > itself is rather narrow. Is there a way to place labels such that the label > for a narrow slice isn't partially obscured by the next one? I've searched > the documentation and the forum but haven't been able to figure this out. This is the code I'm using. varAFreq={{Alive, 41169}, {Dead, 1916}, {Missing, 2009}}; PieChart[varAFreq[[All, 2]], > ImageSize -> Medium, > ChartStyle -> {LightGreen, Red, LightRed}, > PlotLabel - Column[{Style[Phase I Trees, Bold, 14], > Style[Row[{ (, > NumberForm[Total[varAFreq[[All, 2]]], DigitBlock -> 3], > trees surveyed)}], Italic, 14]}], > ChartLabels - Placed[N[varAFreq[[All, 2]]/Total[varAFreq[[All, 2]]]*100] %, > RadialCallout, Style[NumberForm[#, {3, 1}], 12] &], > SectorOrigin -> {.5 Pi, -1}, > LabelingFunction -> (Placed[ > Style[NumberForm[#, DigitBlock -> 3], Italic, 12], > RadialCenter] &)] -jackie === Subject: Re: Mathematica 7.0.1.0 and some General Comments I am astonished that anyone would believe that any software, open source or commercial, could actually replace mathematics (at least during the next few centuries). Andrzej Kozlowski > I don't think Mathematica should replace mathematics. It is an > important tool, but very importantly, a commercial closed-source tool. > It costs a great deal of money and you do not know what it is doing > (although most of the time it gives correct results). Only systems > that can be considered to generally replace Mathematics have got to be > open source (although I admit I do not use any). If at least the basis > of Mathematica was made open-source with paid-for support from Wolfram > that would make things a lot better. As it stands, we should not chain > people to commercial software. > === Subject: Re: Mathematica 7.0.1.0 and I don't recall why I know what I explained below. One possibility is that I just followed my nose, installed the software, and noticed there were now two versions with different names. It seems to me that's what happened under Windows, until (thank God!) I ditched that beast a year ago. But I could be misremembering how it worked, in that environment (hell). On the Mac, it's automatically a bit clearer, since you complete the install by moving the new version into the Applications directory and the OS asks if you want to overwrite. If you're not sure, you rename the old one and THEN move the new. So the OS itself warns me what I'm doing. Bobby > But does it SAY that somewhere on the page where one downloads an > installer, or on a printed piece of paper if one receives physical > installation media, or in a readme file that accompanies the installer, > or, ... ? Does it even say that when you run the installer? (After I uninstalled > 7.0.0 and ran the installer for 7.0.1, I received no such notice even > though I still had 5.2 and 6.0.3 installed.) Why the secrecy? Is one supposed to intuit the answer? Hence my complaint -- and it's a complaint, as I said, much more > generally applicable than about Mathematica. > I believe, with Mathematica, the procedure is to simply install the new >> update. If you choose to give it the same name as the old (simply >> (at least) two versions. File associations should go to the new version, >> but if they don't, just change them. >> I used to keep old versions, but I no longer do that. >> Bobby > Is there some installation instructions I missed that tell you the > 7.0.1 > installer will uninstall 7.0.0? If so, where? I didn't see such, so I did the same thing I always do when such a > minor > update arrives: first uninstall the old version and then install the > new > version. (With a major version change, of course, I leave the old > version installed until I can migrate everything affected.) One of my biggest complaints about software in general is how seldom > there is up-front information on how to handle an update/upgrade: you > must uninstall the old version first; you may uninstall the old version > first; you should NOT uninstall the old version first; the installer > will automatically uninstall the old version first; the installer will > not uninstall the old version first; the installer will give you the > option of uninstalling the old version first. Considering how often many software products come out with updates, new > releases, upgrades, etc., and how much effort is often devoted to > pushing and selling such new versions, it remains amazing to me at how > inattentive so many software publishers are at dealing with this > so-obvious matter. > > ... And the 7.0.1 installation is pretty easy if you already have > > 7.0.0 installed. If you accept all the default options, it goes > ahead > > and uninstalls 7.0.0, sucks up your mathpass and init.m files, and > > installs 7.0.1. -- DrMajorBob@bigfoot.com === Subject: Re: Mathematica 7.0.1.0 and some General Comments > Some of these alternatives can only be considered to be free as long as= you > count your own time as free. Free as in 'free beer', but also as in 'free speech'. As more functions > get moved into the kernel, customization becomes hard if not > unfeasible. To reinvent the wheel must always be considered > as unprofessional malpractice. Agreed. But when the student leaves school can he still afford the pro > tool? Is the company he is applying for a job willing to buy it because > he says it's good? when the student graduates he can obtain a home edition for under $300 -- which seems affordable for someone professionally employed. Mike Will you get ready within finite time with the task you might do > in a week using the professional tools? I agree with this. But what if one does not see a favorable return on > the investment? > Peltio === Subject: Re: Mathematica 7.0.1.0 and some General Comments > And yet, there have never been more ways for Mathematica to communicate > its results with other software. It supports huge numbers of > import/export formats, and programming interfaces such as J/Link. > Even though Mathematica supports a huge number of Import/Export file formats, I keep coming across implementations of Im/Export that are unsatisfactory. This might be bad luck onmy side, but Mathematica, in its 7th major version, is still not able to properly read in HDF4 files (from the many possible HDF4 contents only one particular format, namely SDS is supported), HDF5 (no compound data import possible, and maybe even broken ?), FITS used to be limited to one header block (seems to be working now in V7), and even PDF/PS export is always a challenge. Other scientific tools like IDL, _younameit_ are able to handle these formats properly and as a consequence are in common use (at least in astronomy/astrophysics.) If WRI wants Mathematica to get its foot into the scientific door, they should take better care of what their customer need - e.g. reading/writing their data comfortably. Sorry for my rant - I couldn't help it. Despite my excitement for Mathematica I am always frustrated the most when I waste my time on these unneccesary bugs. Markus Roellig === Subject: Re: Mathematica 7.0.1.0 and some General Comments Regarding: > Types of elements typically supported include: What does the word typically mean? Presumably it means that the > author > could not be bothered to obtain a definitive list - even as of some > particular version. To make matters worse, since the elements are > specified as strings, there is absolutely no way to discover the > elements that the author happened to forget (or, indeed the > corresponding functionality!). I complained to Theo Gray about this very topic when Mathematica 6 came out. There has been no movement as far as I can tell. As a programmer, I'd really like to know exactly what all the options are, and, if possible, have them available with a simple command. (Options[] does not provide a complete list.) I found that trolling the demonstrations for code written by Wolfram people often turns up interesting things. As for the electronic format: other than the above problem, I'm pretty happy, especially with the new stuff. I sent an e-mail to Wolfram suggesting one of their free seminars to cover just documentation, since a lot of things -- task specific screen-casts, for example -- are not easy to discover. I also see the need for a short introductory book, similar to Gray and Glynn's Beginner's guide, now hopelessly out of date. I started an unofficial update to V6 some time ago, but got bogged down. There is simply so much stuff that a guide is necessary, particularly for beginners. Wolfram seems to think that this is a third party need to have inside information. Let's hope that Wolfram follows the lead of Apple with their Snow Leopard for the next version: NO NEW Features, just optimization and fixes. george woodrow > One other requirement to make a breakthrough is the necessity of >> anyone to >> be able to freely read an active and dynamic Mathematica notebook. >> It should >> be something like the model of the free Acrobat reader. PlayerPro >> would do >> the job but it is too expensive. I know there are problems here. I >> wouldn't >> care if the reader couldn't print or save the notebook. Perhaps >> dynamic >> InputFields could be limited in the total number of typed >> characters for the >> notebook. Anyway, if it is so easy to hack PlayerPro in a usable >> way, why >> don't some people just pay the $200 and do it? A free general >> Mathematica >> reader would do more to smash the old technology and advertise the >> power of >> Mathematica notebooks than anything else I can think of. > > Just to concentrate on one of your issues - that of documentation, I > am > sure that the people at WRI who decided to move to paperless > documentation used arguments such as: 1) We can redirect all the effort that went into a finished book into > providing more and better information. 2) Virtual documentation is so much better because it can be updated > so > easily. In reality, what has happened is a retreat from quality > documentation in > the belief that whatever is wrong can always be fixed at the next > pass. > Thus for example, we find the following phrase in the help for Import: Types of elements typically supported include: What does the word typically mean? Presumably it means that the > author > could not be bothered to obtain a definitive list - even as of some > particular version. To make matters worse, since the elements are > specified as strings, there is absolutely no way to discover the > elements that the author happened to forget (or, indeed the > corresponding functionality!). The documentation of new or enhanced features is littered with > phraseology of this sort. Compare, for example, the documentation of > 'Import' with an old favourite like 'Map'. Furthermore, I don't think people learn a new package well by just > invoking the help system. The help system is more suitable for people > with at least some experience, who know what they want to look up. I learned Mathematica from the old book. People laughed at it > because of > its size, but it gave me a clear idea as to what was important, and > what > to read first - and of the overall scope of the software. As an > example, > I doubt if any newish Mathematica users think they need a clear > understanding of the frontend/kernel architechture - so they never > read > about this, and suffer from a variety of misconceptions as a result. A > book spoon-feeds the information in roughly the right order. David Bailey > http://www.dbaileyconsultancy.co.uk === Subject: Re: Mathematica 7.0.1.0 and some General Comments But does it SAY that somewhere on the page where one downloads an installer, or on a printed piece of paper if one receives physical installation media, or in a readme file that accompanies the installer, or, ... ? Does it even say that when you run the installer? (After I uninstalled 7.0.0 and ran the installer for 7.0.1, I received no such notice even though I still had 5.2 and 6.0.3 installed.) Why the secrecy? Is one supposed to intuit the answer? Hence my complaint -- and it's a complaint, as I said, much more generally applicable than about Mathematica. > I believe, with Mathematica, the procedure is to simply install the new > update. If you choose to give it the same name as the old (simply > (at least) two versions. File associations should go to the new version, > but if they don't, just change them. I used to keep old versions, but I no longer do that. Bobby >> Is there some installation instructions I missed that tell you the 7.0.1 >> installer will uninstall 7.0.0? If so, where? >> I didn't see such, so I did the same thing I always do when such a minor >> update arrives: first uninstall the old version and then install the new >> version. (With a major version change, of course, I leave the old >> version installed until I can migrate everything affected.) >> One of my biggest complaints about software in general is how seldom >> there is up-front information on how to handle an update/upgrade: you >> must uninstall the old version first; you may uninstall the old version >> first; you should NOT uninstall the old version first; the installer >> will automatically uninstall the old version first; the installer will >> not uninstall the old version first; the installer will give you the >> option of uninstalling the old version first. >> Considering how often many software products come out with updates, new >> releases, upgrades, etc., and how much effort is often devoted to >> pushing and selling such new versions, it remains amazing to me at how >> inattentive so many software publishers are at dealing with this >> so-obvious matter. >> > > ... And the 7.0.1 installation is pretty easy if you already have >> > 7.0.0 installed. If you accept all the default options, it goes ahead >> > and uninstalls 7.0.0, sucks up your mathpass and init.m files, and >> > installs 7.0.1. > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Mathematica 7.0.1.0 and some General Comments I don't think Mathematica should replace mathematics. It is an important tool, but very importantly, a commercial closed-source tool. It costs a great deal of money and you do not know what it is doing (although most of the time it gives correct results). Only systems that can be considered to generally replace Mathematics have got to be open source (although I admit I do not use any). If at least the basis of Mathematica was made open-source with paid-for support from Wolfram that would make things a lot better. As it stands, we should not chain people to commercial software. === Subject: Re: Mathematica 7.0.1.0 and some General Comments > I don't think Mathematica should replace mathematics. It is an > important tool, but very importantly, a commercial closed-source tool. > It costs a great deal of money and you do not know what it is doing > (although most of the time it gives correct results). Only systems > that can be considered to generally replace Mathematics have got to be > open source (although I admit I do not use any). If at least the basis > of Mathematica was made open-source with paid-for support from Wolfram > that would make things a lot better. As it stands, we should not chain > people to commercial software. Other than people who use pencils and paper, or blackboards and chalk*, everyone is chained to commercial products in their workplaces. We need to free our minds a bit from the idea that software should somehow be an exception to everything else that occurs in our workplaces. Or alternatively perhaps someone can explain to me why software should be any different to scientific equipment, cars, dishwashers... I cannot use an open source mass spectrometer, drive an open source car [although GM and Ford are verging on open source :), or at least maybe publicly owned soon] etc. Mike *these are also commercial products of course === Subject: Re: Mathematica 7.0.1.0 and some General Comments > Some of these alternatives can only be considered to be free as long as you > count your own time as free. Free as in 'free beer', but also as in 'free speech'. As more functions get moved into the kernel, customization becomes hard if not unfeasible. > To reinvent the wheel must always be considered > as unprofessional malpractice. Agreed. But when the student leaves school can he still afford the pro tool? Is the company he is applying for a job willing to buy it because he says it's good? > Will you get ready within finite time with the task you might do > in a week using the professional tools? I agree with this. But what if one does not see a favorable return on the investment? Peltio === Subject: Re: Unexpected zoom when rotating Plot3D This happened to me from versions 6.00 to 7.01, under Windows XP and Vista. I could not find any way to prevent it and it appears unpredictable: some plots show this behavior, some don't. ADL === Subject: Re: Unexpected zoom when rotating Plot3D Go to the Mathematica Preference Dialog. In that Dialog select the Interface tab. In that tab, check the box that says Automatically re-fit 3-D graphics after rotation. I am not sure why the graphic zooms so much if that box is unchecked: it seems as though it is much too much of a zoom, and perhaps this is a bug. That checkbox covers the global setting of the option RotationAction. Hope that this helps, David http://scientificarts.com/worklife Extending Mathematica's Reach.... On Mar 10, 6:37 am, Michael Young I am running Mathematica 7.0.1 under OSX 10.5.6 using an ATI Radeon HD = > 2600 graphics card. In looking at the Plot3D documentation, I evaluated the notebook to > rotate its figures. Following this there was no apparent change, but = > immediately upon mouse-rotation, images 2 and 4 of the Basic Examples > appeared to zoom in very close to center so that the entire plot could = > not be fully viewed. Apart from that nothing else seemed wrong. Why might this be? > === Subject: Re: L-shaped ListContourPlot Ulises, from your explanation, I would suggest that, when a Region is specified, the triangulation determined by RegionPlot should be used as the basis for further refinements or subsequent actions. In fact, since a Region is a mathematical concept and not a graphical object, its violation is not welcome: RegionFunction should always work by clipping sharply the shapes shown in the plotted figure. ADL === Subject: Re: L-shaped ListContourPlot If you change the InterpolationOrder option, the problem should go away. Try something like ListContourPlot[data, ColorFunction -> Function[{z}, ColorData[VisibleSpectrum][380 + 370 z]], PlotRange -> All, RegionFunction -> Function[{x, y, z}, (y < 5) || (x < 5)], Epilog -> Point[data[[All, {1, 2}]]], InterpolationOrder -> 0] > however that this kind of behaviour of ListContourPlot and > RegionFunction is quite unstable, in fact it appears for very thin > gaps of points: my example had a very raw mesh, but even if I use a > very fine mesh the same thing happens, if the interval appears to be a > little outside the data. Flavio Cimolin > On 6 Mar, 11:39, Jens-Peer Kuska try ListContourPlot[data, ColorFunction -> Rainbow, PlotRange -> All, > RegionFunction -> Function[{x, y, z}, (y < 5) || (x < 2)], > Epilog -> (Point[Take[#, 2]] & /@ data)] and you see that at x==2 are data points, for 2 data points and making a cut in the drawing where > no data exist will cause errors in the interpolation of the > data for drawing. Jens > I have some pressure data coming from an external FE solver, which I > want to plot in Mathematica, for a L-shaped domain. I have tried to > use ListContourPlot (or ListDensityPlot), but I have found an > unexpected behaviour in controlling the shape of the domain with the > RegionFunction option. I am using Mathematica 6.0. The command I use for the plot is the following: ListContourPlot[data, ColorFunction -> Rainbow, PlotRange -> All, > RegionFunction -> Function[{x, y, z}, (y < 5) || (x < 2)]] Now... if I keep the (x < 2), everything goes well, but if I put (x < > 3), instead of having an L-shaped domain, I obtain a strange oblique > boundary. Is there an explanation to this? In order to test it, you can consider the following data: data = {{0.`, 0.`, 39.99`}, {0.`, 1.`, 39.99`}, {0.`, 2.`, > 40.4`}, {0.`, 3.`, 42.24`}, {0.`, 4.`, 41.88`}, {2.`, 0.`, > 39.37`}, {2.`, 1.`, 39.32`}, {2.`, 2.`, 39.56`}, {2.`, 3.`, > 44.06`}, {2.`, 4.`, 41.01`}, {4.`, 0.`, 35.72`}, {4.`, 1.`, > 35.63`}, {4.`, 2.`, 35.48`}, {4.`, 3.`, 37.45`}, {4.`, 4.`, > 29.15`}, {6.`, 0.`, 30.95`}, {6.`, 1.`, 30.89`}, {6.`, 2.`, > 30.59`}, {6.`, 3.`, 29.59`}, {6.`, 4.`, 29.7`}, {8.`, 0.`, > 27.12`}, {8.`, 1.`, 27.12`}, {8.`, 2.`, 27.03`}, {8.`, 3.`, > 26.33`}, {8.`, 4.`, 26.99`}, {10.`, 0.`, 23.94`}, {10.`, 1.`, > 23.93`}, {10.`, 2.`, 23.9`}, {10.`, 3.`, 23.56`}, {10.`, 4.`, > 23.7`}, {12.`, 0.`, 21.05`}, {12.`, 1.`, 21.04`}, {12.`, 2.`, > 20.99`}, {12.`, 3.`, 20.75`}, {12.`, 4.`, 20.64`}, {14.`, 0.`, > 18.44`}, {14.`, 1.`, 18.42`}, {14.`, 2.`, 18.29`}, {14.`, 3.`, > 17.82`}, {14.`, 4.`, 17.37`}, {16.`, 0.`, 16.39`}, {16.`, 1.`, > 16.36`}, {16.`, 2.`, 16.07`}, {16.`, 3.`, 14.82`}, {16.`, 4.`, > 12.77`}, {18.`, 0.`, 15.3`}, {18.`, 1.`, 15.28`}, {18.`, 2.`, > 14.93`}, {18.`, 3.`, 12.67`}, {18.`, 4.`, 11.7`}, {20.`, 0.`, > 15.15`}, {20.`, 1.`, 15.14`}, {20.`, 2.`, 14.7`}, {20.`, 3.`, > 12.46`}, {20.`, 4.`, 12.08`}, {0.`, 5.`, 41.35`}, {0.`, 6.`, > 40.95`}, {0.`, 7.`, 40.94`}, {0.`, 8.`, 41.23`}, {0.`, 9.`, > 41.7`}, {2.`, 5.`, 37.5`}, {2.`, 6.`, 38.08`}, {2.`, 7.`, > 39.48`}, {2.`, 8.`, 40.55`}, {2.`, 9.`, 41.42`}, {17.`, > 5.`, -8.22`}, {17.`, 6.`, -4.96`}, {17.`, 7.`, -3.1`}, {17.`, > 8.`, -1.44`}, {17.`, 9.`, -0.29`}, {19.`, 5.`, 10.19`}, {19.`, > 6.`, 5.42`}, {19.`, 7.`, 2.01`}, {19.`, 8.`, 0.52`}, {19.`, 9.`= > , > 0.09`}}; > Flavio Cimolin > -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: L-shaped ListContourPlot Use: ListContourPlot[data, ColorFunction -> Rainbow, PlotRange -> All, RegionFunction -> Function[{x, y, z}, (y < 5) || (x < 3)], MaxPlotPoints -> 30] To understand why this is, compare these two: ListContourPlot[data, ColorFunction -> Rainbow, PlotRange -> All, RegionFunction -> Function[{x, y, z}, (y < 5) || (x < 3)], Mesh -> All] ListContourPlot[data, ColorFunction -> Rainbow, PlotRange -> All, RegionFunction -> Function[{x, y, z}, (y < 5) || (x < 3)], MaxPlotPoints -> 30, Mesh -> All] The default for ListDensityPlot, ListContourPlot and ListPlot3D for irregular data is to use the original data as the support for a triangulation. Setting MaxPlotPoints->30 will force a resampling which will add new information to the mesh n the domain and this will make a closer approximation for the RegionFunction. -Ulises Cervantes WRI === Subject: Palettes Remembering Their Positions In a recent post I stated that there was a problem with WRI system palettes remembering their positions. This was only partially true. The new palettes do remember their position. It is only the older palettes in the Other folder, such as Basic Math Input, that do not remember their position. I was informed by WRI that this was an oversight and this probably will be fixed in a future update. (I was being something of an old fogy in using the Basic Math Input palette. I was just used to it. But the new palettes such as Basic Math Assistant really are better.) I also suggested that this problem could be corrected by changing the Security permissions for the Wolfram Palettes folder. This does work, but it is bad practice to change the permissions on Wolfram installation folders. So, if you are using the new palettes, there is no problem, and if you are using some of the old palettes the best thing might be to live with it until the next update. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Bug in Pattern Matching with Condition? > Hi Jens, can you elaborate a bit. According to the definition of Verbatim , Verbatim[Condition][_, _]] should match literally Condition][_, _] and not Condition[a, b]. Therefore it looks more like another bug to me an= d adds to the mystery of why MatchQ[Condition[a, b], Condition[_, _]] evaluates to False. Daniel > but MatchQ[Condition[a, b], Verbatim[Condition][_, _]] Jens > Hi Mathematica group, do you get any idea of >> why the following sentences don't give true? > MatchQ[Condition[a, b], Condition[_,_]] >> MatchQ[Condition[a, b], Condition[__]] >> MatchQ[Condition[a, b], HoldPattern[Condition[__]]] > Is this a bug? > Cesar As I said above, as a pattern, Condition[_,_] cannot match anything by definition. Since, Condition[_,_] => _ /; _ where the second _ must evaluate to true for the rule to be accepted. Since _ is obviously not true, the rule can never be true. If you want to use pattern matching to match Condition, I'd recommend swapping its head with something else. === Subject: Re: Bug in Pattern Matching with Condition? > Well, I can't answer this with any certainly but it seems to me > reasonable that _/;True should match anything just as _ does and that > _/;False should not match anything. It seems logical that if you agree > with that than you get strange behaviour as below: MatchQ[a /; False, _ /; False] > False MatchQ[a /; False, _ /; True] > True It's not really an explanation but it does make sense (to me) so I would > say it is a feature. Andrzej >> so strangely. Is it a bug or feature? >> Daniel > No, the Varbatim is wrapped around the Head, Condition not around the > entire expression. You can do it also with HoldPattern: > MatchQ[a /; b, HoldPattern[Condition][_, _]] > True > Once you hold the Head of the pattern expression it no longer has its > special meaning. You can check that Condition behaves is a very > special way when used in a pattern, e.g. > MatchQ[x, Condition[_, True]] > True > MatchQ[x, Condition[_, False]] > False > Of course if you replace Condition by Verbatim[Condition] or > HoldPattern[Condition] you will always get False. > Andrzej Kozlowski >> Hi Jens, >> can you elaborate a bit. According to the definition of Verbatim , >> Verbatim[Condition][_, _]] should match literally Condition][_, _] >> and >> not Condition[a, b]. Therefore it looks more like another bug to me >> and >> adds to the mystery of why MatchQ[Condition[a, b], Condition[_, _]] >> evaluates to False. >> Daniel > > but > > MatchQ[Condition[a, b], Verbatim[Condition][_, _]] > > Jens > >> Hi Mathematica group, do you get any idea of >> why the following sentences don't give true? >> MatchQ[Condition[a, b], Condition[_,_]] >> MatchQ[Condition[a, b], Condition[__]] >> MatchQ[Condition[a, b], HoldPattern[Condition[__]]] >> Is this a bug? >> Cesar > >> -- >> 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: Bug in Pattern Matching with Condition? Well, I can't answer this with any certainly but it seems to me reasonable that _/;True should match anything just as _ does and that _/;False should not match anything. It seems logical that if you agree with that than you get strange behaviour as below: MatchQ[a /; False, _ /; False] False MatchQ[a /; False, _ /; True] True It's not really an explanation but it does make sense (to me) so I would say it is a feature. Andrzej > so strangely. Is it a bug or feature? > Daniel > No, the Varbatim is wrapped around the Head, Condition not around >> the entire expression. You can do it also with HoldPattern: >> MatchQ[a /; b, HoldPattern[Condition][_, _]] >> True >> Once you hold the Head of the pattern expression it no longer has >> its special meaning. You can check that Condition behaves is a very >> special way when used in a pattern, e.g. >> MatchQ[x, Condition[_, True]] >> True >> MatchQ[x, Condition[_, False]] >> False >> Of course if you replace Condition by Verbatim[Condition] or >> HoldPattern[Condition] you will always get False. >> Andrzej Kozlowski > Hi Jens, can you elaborate a bit. According to the definition of Verbatim , Verbatim[Condition][_, _]] should match literally Condition][_, > _] and not Condition[a, b]. Therefore it looks more like another bug to > me and adds to the mystery of why MatchQ[Condition[a, b], Condition[_, _]] evaluates to False. Daniel >> but >> MatchQ[Condition[a, b], Verbatim[Condition][_, _]] > Jens Hi Mathematica group, do you get any idea of why the following sentences don't give true? MatchQ[Condition[a, b], Condition[_,_]] MatchQ[Condition[a, b], Condition[__]] MatchQ[Condition[a, b], HoldPattern[Condition[__]]] Is this a bug? > Cesar > -- Daniel Huber > Metrohm Ltd. > Oberdorfstr. 68 > CH-9100 Herisau > Tel. +41 71 353 8585, Fax +41 71 353 8907 > E-Mail: No, the Varbatim is wrapped around the Head, Condition not around the > entire expression. You can do it also with HoldPattern: MatchQ[a /; b, HoldPattern[Condition][_, _]] > True Once you hold the Head of the pattern expression it no longer has its > special meaning. You can check that Condition behaves is a very special > way when used in a pattern, e.g. MatchQ[x, Condition[_, True]] > True MatchQ[x, Condition[_, False]] > False Of course if you replace Condition by Verbatim[Condition] or > HoldPattern[Condition] you will always get False. > Andrzej Kozlowski > >> Hi Jens, >> can you elaborate a bit. According to the definition of Verbatim , >> Verbatim[Condition][_, _]] should match literally Condition][_, _] and >> not Condition[a, b]. Therefore it looks more like another bug to me and >> adds to the mystery of why MatchQ[Condition[a, b], Condition[_, _]] >> evaluates to False. >> Daniel > > but > > MatchQ[Condition[a, b], Verbatim[Condition][_, _]] > > Jens > >> Hi Mathematica group, do you get any idea of >> why the following sentences don't give true? >> MatchQ[Condition[a, b], Condition[_,_]] >> MatchQ[Condition[a, b], Condition[__]] >> MatchQ[Condition[a, b], HoldPattern[Condition[__]]] >> Is this a bug? >> Cesar > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: Bug in Pattern Matching with Condition? No, the Varbatim is wrapped around the Head, Condition not around the entire expression. You can do it also with HoldPattern: MatchQ[a /; b, HoldPattern[Condition][_, _]] True Once you hold the Head of the pattern expression it no longer has its special meaning. You can check that Condition behaves is a very special way when used in a pattern, e.g. MatchQ[x, Condition[_, True]] True MatchQ[x, Condition[_, False]] False Of course if you replace Condition by Verbatim[Condition] or HoldPattern[Condition] you will always get False. Andrzej Kozlowski > Hi Jens, can you elaborate a bit. According to the definition of Verbatim , Verbatim[Condition][_, _]] should match literally Condition][_, _] > and not Condition[a, b]. Therefore it looks more like another bug to me > and adds to the mystery of why MatchQ[Condition[a, b], Condition[_, _]] evaluates to False. Daniel >> but >> MatchQ[Condition[a, b], Verbatim[Condition][_, _]] > Jens Hi Mathematica group, do you get any idea of why the following sentences don't give true? MatchQ[Condition[a, b], Condition[_,_]] MatchQ[Condition[a, b], Condition[__]] MatchQ[Condition[a, b], HoldPattern[Condition[__]]] Is this a bug? > Cesar === Subject: Re: Bug in Pattern Matching with Condition? Hi Jens, can you elaborate a bit. According to the definition of Verbatim , Verbatim[Condition][_, _]] should match literally Condition][_, _] and not Condition[a, b]. Therefore it looks more like another bug to me and adds to the mystery of why MatchQ[Condition[a, b], Condition[_, _]] evaluates to False. Daniel but MatchQ[Condition[a, b], Verbatim[Condition][_, _]] Jens > >> Hi Mathematica group, do you get any idea of >> why the following sentences don't give true? >> MatchQ[Condition[a, b], Condition[_,_]] >> MatchQ[Condition[a, b], Condition[__]] >> MatchQ[Condition[a, b], HoldPattern[Condition[__]]] >> Is this a bug? >> Cesar > === Subject: Re: Bug in Pattern Matching with Condition? > can you elaborate a bit. According to the definition of Verbatim , Verbatim[Condition][_, _]] should match literally Condition][_, _] and not Condition[a, b]. you need to be very carefully to where the Verbatim ends. I think everything is in order (this time even the documentation, although it is rather on the short side): Match the Condition-Head verbatim, but treat its arguments _,_ as a pattern: In[6]:= MatchQ[Condition[a,b],Verbatim[Condition][_,_]] Out[6]= True Match the whole expression Condition[_,_] verbatim: In[7]:= MatchQ[Condition[a,b],Verbatim[Condition[_,_]]] Out[7]= False In[8]:= MatchQ[Condition[_,_],Verbatim[Condition[_,_]]] Out[8]= True > Therefore it looks more like another bug to me and adds to the mystery of why MatchQ[Condition[a, b], Condition[_, _]] evaluates to False. I can see no bug and no mystery here. The problem is that patterns in Mathematica are built as Mathematica expressions just like everything else. If you want to match one of building blocks for pattern-expressions (or expressions containing them) verbatim, you need to wrap them with Verbatim, which seems rather straightforward once one has seen it. It's a little like the escape characters in string patterns that are unavoidable if you use strings to describe the patterns, as has been discussed in another thread. hth, albert === Subject: Re: Wolfram/Alpha (Wikipedia page restored) I made the point to the Wikipedia editor that removed the entry ( Accounting4Taste) that a Google search of Wolfram Alpha generated 2.1 million hits and that any technology which is generating 2.1 million Google hits before it is officially released, must be conceived by many to have significant importance. He/she accepted this, and the page has now been restored. So if someone who knows about the technology can edit the Wikipedia page http://en.wikipedia.org/wiki/Wolfram_Alpha you can now do so. === Subject: Re: Style for function calls? For constructions where you re-use data several times @ can be shorter and sometimes faster than standard function call: myList = RandomReal[{0, 10}, {10000, 2}]; finding the coordinate with the largest value at the end: Cases[#, {_, x_} /; x == Max[#[[All, 2]]]] & @ ( myList^2) // Timing {5.156, {{50.8683, 99.998}}} Cases[ myList^2, {_, x_} /; x == Max[(myList^2)[[All, 2]]]] // Timing Out[32]= {10.875, {{50.8683, 99.998}}} [BTW: try this without the square and the difference becomes very small] > I'm fairly new to Mathematica and have a style question rather than a > functionality question. I'm aware with the operator forms for Postfix (//), Prefix (@), and > Infix (~), and I've found the // operator useful for piping long results > through the ...Form functions, or N, or the like, as a quick > afterthought while typing a lot of stuff. What are the analogous situations where @ or ~ are used? Looking at > random notebooks around I've from time to time seen them used but there > doesn't seem to be any rhyme or reason; it's not clear when > stylistically they'd be useful, as opposed to the // operator, which I > can see and use myself. -- > Erik Max Francis && m...@alcyone.com &&http://www.alcyone.com/max/ > San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis > To understand is to forgive, even oneself. > -- Alexander Chase === Subject: Re: Style for function calls? Hi Erik, as you mention, // is more like an afterthought, but @ seems rather like a main thought. It is mainly used in functional programming style where you feed the output of one function into the next function. If you use it, beware of precedence. Concening ~, I never used it so far. Daniel > I'm fairly new to Mathematica and have a style question rather than a > functionality question. I'm aware with the operator forms for Postfix (//), Prefix (@), and > Infix (~), and I've found the // operator useful for piping long results > through the ...Form functions, or N, or the like, as a quick > afterthought while typing a lot of stuff. What are the analogous situations where @ or ~ are used? Looking at > random notebooks around I've from time to time seen them used but there > doesn't seem to be any rhyme or reason; it's not clear when > stylistically they'd be useful, as opposed to the // operator, which I > can see and use myself. > === Subject: Re: Notebook that auto-executes when opened? >>Is it possible to set an option for a notebook such that it >>automatically begins executing when opened? -- that is, when the nb >>icon is dbl-clicked? >and Jens-Peer Kuska replied: >>no, it would be the first Mathematica written virus >>My favorite command would be >>DeleteFile/@ FileNames[*.*, {C:}, 4] >And in any case, if you were malevolent in this fashion, could you >not fairly easily hide your favorite command within a closed but >still executable cell within some large and apparently benevolent >nb, which you might then make available to other people for them to >use in doing some apparently useful task? >Or perhaps bury it in a Mathematica package, or demonstration, or >??? that was then called and executed by this benevolent >program? (I'm not skilled enough in the complexities of >Mathematica to know >just what can and can't be included in structures other than >notebooks.) Yes, such a command can be constructed in a way that would make it difficult to find. Additionally, it could be written in a platform independent way. >Related thought: Should Mathematica perhaps have an option or >preference (which is normally set to ON by default) under which your >favorite command, and others like it, would always trigger an _Are >you sure_ you want to do this? dialog before executing? Seems to >me many of the other apps I use have some capability like this, for >protection against accident as much as malevolence. There is something built in to the last few versions of Mathematica to assist in preventing this type of problem. That is the concept of trusted/untrusted directories which the user can set. The idea being anything in an untrusted directory doesn't get executed without some warning to the user. But this isn't equivalent to a Are you sure? warning for deleting files. Nor is such a warning desirable for Mathematica. Mathematica is far more than the typical application that contains similar warning messages. Mathematica can be viewed as being a general purpose programming language. In this regard it is no more appropriate to put Are you sure? warnings in Mathematica than say a C/C++ compiler. As is the case with a C/C++ compiler, the assumption is the user knows what he is doing with commands such as DeleteFile. === Subject: Maintaining a Mathematica bug list Note: I moved the discussion on maintaining a Mathematica bug list to a new thread. While the number of Mathematica functions is growing exponentially, the satisfaction among the users (especially those, who have been using Mathematica for years) does not seem to increase too rapidly. The old-fashioned way Mathematica users have to submit their bug reports is incompatible with the futuristic Wolfram Alpha project. Also the claim that Mathematica delivers unprecedented reliability does not fit with the words such as improvement and enhancement being used to describe the recent changes, instead of calling them bug-fixes and documenting in a proper way. Such descriptions are appropriate only for advertising a new version of laundry detergent, not a programming language. Honestly, I think that maintaining our own list of bugs would be an act of desperation. I am not sure if that would have any impact on WRI, but it would definitely make the life much easier for Mathematica users. I do not have enough experience to set up such a thing (e.g., bug tracking system, Wiki, database, etc.). However, I believe that there are users on this forum who have such an experience. I would like to encourage Mathematica users to express their thoughts regarding whether such a step is really necessary. I am certain that WRI have enough resources to allocate for improving the communication with the Mathematica user community. I think that it is just a question of recognizing the problem and willing to solve it. Mathematica is really a great tool and we all are willing to contribute to make it even more better! > Do you know of something like this that exists > already for any other software product? Surely, most of the open source projects nowadays have their own bug tracking systems. However, it is not very common for users of proprietary software to maintain their own bug lists. Here is one example that I found on the web: The Delphi Bug List http://buglist.jrsoftware.org/ If you read this page, you can see that Delphi users had a very similar experience as we do. It is not clear though whether they succeeded or not. On their What's New page http://buglist.jrsoftware.org/whatsnew.htm you can see that their bug list is no longer maintained, since Borland has made available their own bug tracking system QualityCentral. However, the supplied link http://qc.borland.com/ does not respond. Another example of a user-maintained bug list is ColdFusion Bug Hunt http://www.cfbughunt.org/ There are more examples of companies that actively encourage feedback from the user community. For example, Adobe, see Adobe Public Bug Database and Issue Reporting System http://bugs.adobe.com/ and Adobe Labs http://labs.adobe.com/about/ Even Microsoft welcomes user feedback: Microsoft Connect https://connect.microsoft.com/ ~Maris Ozols~ P.S. Here are the two most ridiculous Mathematica bugs that I know of. 1. If you are using Mathematica 6, try to evaluate this number: -1/Sqrt[(5-2Sqrt[2]-Sqrt[5-2Sqrt[2]])(5+2Sqrt[2]-Sqrt[5+2Sqrt[2]])/2] Actually WRI guys are not that evil, since this is fixed in 7.0 (I reported it on March 2007, though). I was very pleased when I found By the way, I don't know if that happened by an accident or not, but their reply to my bug report contained two interesting links: > see https://bugs.wolfram.com/show?number=54568 > and > https://bugs.wolfram.com/show?number=76559 Unfortunately, bugs.wolfram.com is not working, so I believe it is an internal system. So, WRI, please make it publicly available! Mathematica users would really appreciate that! 2. Open the Documentation Center and press Ctrl+Enter or Ctrl+, in the search bar at the top. I reported this for 6.0.3. Since 7.0 was released very soon, probably they didn't have time to fix this for 7.0. So, I hope it has been fixed for 7.0.1, since it should be really trivial to do this. > One thing that Mathematica users could do is to set up a Wiki where > they maintain their own list of known Mathematica bugs. Of course, > this is really what WRI should do, not us. But, here are a few reasons > why it might be an advantage for us to do so: * In this way Mathematica users would declare their position regarding > the way Mathematica is being developed. * Individuals and organizations that are considering buying > Mathematica would see that it actually contains lots of bugs and those > bugs don't get fixed. That would discourage them from buying > Mathematica and make WRI to rethink their strategy. * Mathematica users could check if their bugs are already known > without wasting their time to submit the bug reports. * It would be easier to monitor which bugs get fixed and which don't. ~Maris Ozols~ > Hi. I think this is a wonderful idea and would be willing to volunteer > time to help out. Do you know of something like this that exists > already for any other software product? If anyone else thinks this > would be of help please let your comments be known so the level of > interest could be gauged. I too, agree that Wolfram should already > have something like this, and would love to be able to look somewhere > and see if the bug/problem I am experiencing has already been reported > rather than waste time reporting something already known. Where would > be a good place to locate something like this? GREAT IDEA!!!! -Bob > Maris Ozols has made a practical suggestion, which SHOULD be discussed > further about the possibility to really implement it. ADL === Subject: Re: Notebook that auto-executes when opened? Now that the ability to load data off the net is built-in to Mathematica (paclets) there needs to be a sandboxing mode so that you can load Mathematica programs off the net and run them without danger. Then we could safely have a database of potential newbie errors out on the web somewhere, that could be autoloaded when an error occurred, .... Is it possible to set an option for a notebook such that it automatically > begins executing when opened? -- that is, when the nb icon is > dbl-clicked? and Jens-Peer Kuska replied: no, it would be the first Mathematica written virus My favorite command would be DeleteFile/@ FileNames[*.*, {C:}, 4] > Interesting point, and one I'd certainly not thought of -- although I > was asking about creating this capability in notebooks that I'd write > myself, for myself, not ones to be distributed to others. And in any case, if you were malevolent in this fashion, could you not > fairly easily hide your favorite command within a closed but still > executable cell within some large and apparently benevolent nb, which > you might then make available to other people for them to use in doing > some apparently useful task? Or perhaps bury it in a Mathematica package, or demonstration, or ??? > that was then called and executed by this benevolent program? (I'm not > skilled enough in the complexities of Mathematica to know just what can > and can't be included in structures other than notebooks.) Related thought: Should Mathematica perhaps have an option or > preference (which is normally set to ON by default) under which your > favorite command, and others like it, would always trigger an _Are you > sure_ you want to do this? dialog before executing? Seems to me many > of the other apps I use have some capability like this, for protection > against accident as much as malevolence. === Subject: Re: Notebook that auto-executes when opened? > Is it possible to set an option for a notebook such that it >> automatically >> begins executing when opened? -- that is, when the nb icon is dbl- >> clicked? and Jens-Peer Kuska replied: > no, it would be the first Mathematica written virus >> My favorite command would be >> DeleteFile/@ FileNames[*.*, {C:}, 4] > Interesting point, and one I'd certainly not thought of -- although I > was asking about creating this capability in notebooks that I'd write > myself, for myself, not ones to be distributed to others. And in any case, if you were malevolent in this fashion, could you not > fairly easily hide your favorite command within a closed but still > executable cell within some large and apparently benevolent nb, which > you might then make available to other people for them to use in doing > some apparently useful task? Or perhaps bury it in a Mathematica package, or demonstration, or ??? > that was then called and executed by this benevolent program? (I'm > not > skilled enough in the complexities of Mathematica to know just what > can > and can't be included in structures other than notebooks.) Related thought: Should Mathematica perhaps have an option or > preference (which is normally set to ON by default) under which your > favorite command, and others like it, would always trigger an _Are > you > sure_ you want to do this? dialog before executing? Seems to me many > of the other apps I use have some capability like this, for protection > against accident as much as malevolence. > Yes, one can do all of the above, which is why the Wolfram Demonstration Site has features designed to prevent users uploading demonstrations containing potentially malicious code. I assume packages downloaded from MathSource should also be safe (but I would be a little more doubtful in this case than in the case of the Demonstrations Project). Other than that, if you download a notebook or a package and run it on your computer without carefully examining its contents you run exactly the same risks as when running any program you download form the Internet. I don't see the point of the last idea. A mathematica notebook is just an ASCI file which may contain executable code. Mathematica has no way of distinguishing code that can actually do something from, say, a list of numbers, symbols etc, that have been put into an Input Cell. I can't imagine how such messages could tell anyone anything would be of the slightest use in deciding whether to evaluate an input cell or not, without examining its contents. Of course it would be possible to write a package that would attempt to analyze any piece of code for malicious potential, but it could never be foolproof and in fact would be easy to get around for any reasonably skilled Mathematica programmer. Andrzej Kozlowski Andrze === Subject: Re: Notebook that auto-executes when opened? As is the case with most other viruses, it would not work on a Mac ;-) Andrzej Kozlowski no, it would be the first Mathematica written virus My favorite command would be DeleteFile/@ FileNames[*.*, {C:}, 4] Jens >> Possible to set an option for a notebook such that it automatically >> begins executing when opened, that is, when the nb icon is dbl- >> clicked >> on the desktop, or however else files are opened in the operating >> system >> that's being used? >> I guess I'm also assuming here an OS which, along with opening the >> file >> itself, if necessary first opens the app which executes the file, >> since >> that's the only type of OS that I'm familiar with. Are there any >> Mathematica compatible operating systems that don't do this? > === Subject: Re: Notebook that auto-executes when opened? > Is it possible to set an option for a notebook such that it automatically > begins executing when opened? -- that is, when the nb icon is dbl-clicked? and Jens-Peer Kuska replied: > no, it would be the first Mathematica written virus My favorite command would be DeleteFile/@ FileNames[*.*, {C:}, 4] Interesting point, and one I'd certainly not thought of -- although I was asking about creating this capability in notebooks that I'd write myself, for myself, not ones to be distributed to others. And in any case, if you were malevolent in this fashion, could you not fairly easily hide your favorite command within a closed but still executable cell within some large and apparently benevolent nb, which you might then make available to other people for them to use in doing some apparently useful task? Or perhaps bury it in a Mathematica package, or demonstration, or ??? that was then called and executed by this benevolent program? (I'm not skilled enough in the complexities of Mathematica to know just what can and can't be included in structures other than notebooks.) Related thought: Should Mathematica perhaps have an option or preference (which is normally set to ON by default) under which your favorite command, and others like it, would always trigger an _Are you sure_ you want to do this? dialog before executing? Seems to me many of the other apps I use have some capability like this, for protection against accident as much as malevolence. === Subject: Re: Notebook that auto-executes when opened? > Possible to set an option for a notebook such that it automatically > begins executing when opened, that is, when the nb icon is dbl-clicked > on the desktop, or however else files are opened in the operating system > that's being used? Notebook[{Cell[ BoxData[DynamicBox[ ToBoxes[$CellContext`x = FrontEndTokenExecute[EvaluateNotebook]; Print[Evaluating Notebook...]; $CellContext`x, StandardForm]]], Output], Cell[BoxData[RowBox[{2, +, 2}]], Input]}] === Subject: Re: Notebook that auto-executes when opened? Yes, SetOptions[EvaluationNotebook[], InitializationCellWarning -> False, InitializationCellEvaluation -> True] Then make set your input cells initialization cells and the notebook will evaluate when you open it. Test on Mac OS X with two initialized input cells: Plot[x^2, {x, -2, 2}] Plot[y^3, {y, -2, 2}] Both cells automatically evaluate when the notebook is opened. Mike On Mar 9, 5:19 am, Jens-Peer Kuska no, it would be the first Mathematica written virus My favorite command would be DeleteFile/@ FileNames[*.*, {C:}, 4] Jens Possible to set an option for a notebook such that it automatically > begins executing when opened, that is, when the nb icon is dbl-clicked > on the desktop, or however else files are opened in the operating syste= m > that's being used? I guess I'm also assuming here an OS which, along with opening the file > itself, if necessary first opens the app which executes the file, since > that's the only type of OS that I'm familiar with. Are there any > Mathematica compatible operating systems that don't do this? === Subject: reversing axes orientation is there a simple way to reverse the orientation of the axes of a plot, e.g. in Plot[x, {x, 1, 0}] really plot from 1 to 0 (from left to right)? joerg === Subject: StringCases and Shortest Hello! I want to select shortest substring between brackets from the string. For example: Func[f(a+b) some text (comments) ] should give: {a+b,comments}, and Func[(f(a+b) some text (comments) ] should give: {(a+b),(comments)} too. In the help I found this line: in[]: StringCases[-(a)--(bb)--(c)-, Shortest[( ~~ __ ~~ )]] out: {(a),(bb),(c)} which, at first sight, works as I desire. But when I add bracket at start of line then answer is incorrect in[]: StringCases[(-(a)--(bb)--(c)-, Shortest[( ~~ __ ~~ )]] out: {(-(a),(bb),(c)} What is wrong? And how to solve this problem? === Subject: Re: StringCases and Shortest StringCases[(-(a)--(bb)--(c)-, Shortest[( ~~ q__ ~~ )] /; StringFreeQ[q, (]] ?? Jens > Hello! > I want to select shortest substring between brackets from the string. > For example: Func[f(a+b) some text (comments) ] should give: {a+b,comments}, and Func[(f(a+b) some text (comments) ] should give: {(a+b),(comments)} too. In the help I found this line: in[]: StringCases[-(a)--(bb)--(c)-, Shortest[( ~~ __ ~~ )]] > out: {(a),(bb),(c)} which, at first sight, works as I desire. But when I add bracket at start of line then answer is incorrect > in[]: StringCases[(-(a)--(bb)--(c)-, Shortest[( ~~ __ ~~ )]] > out: {(-(a),(bb),(c)} What is wrong? And how to solve this problem? > === Subject: Re: Wolfram/Alpha you've failed to specify the number-base.Peter 2009/3/10 Jens-Peer Kuska it is already well known that the answer will be 42 Jens I am not involved, and know nothing about it, so I can speak open about > it > without risking being killed for that (hopefully!). I am as curious as > anyone. There is more to read beneath the following link > http://www.twine.com/item/122mz8lz9-4c/wolfram-alpha-is-coming-and-it-could- Saturday morning (March 7, 2009) I found the following on Wikipedia, > Wolfram Alpha: > Wolfram|Alpha is a new futuristic search engine equipped with artificial > intelligence, to be introduced in May 2009 by Wolfram Research. Its > spiritual father, Stephen Wolfram, explains that it will be able to > translate natural language into a format comprehensible to computers and > search through trillions of pieces of curated data and millions of lines > of > algorithms to provide the user with a valuable answer. In the same evening, the entry was deleted, since it met Wikipedia's > forum, webcomic, podcast, browser game, or similar web content that does > not > indicate the importance or significance of the subject. What to say about that? Ingolf Dahl > Sweden >> -----Original Message----- === >> Subject: Re: Wolfram/Alpha >> As you might expect, any who are in the know, and who tell, >> would have to kill or be killed. >> Suffice it to say that it is very interesting and will grow >> into something quite overarching. >> --David (who wants to remain alive) >> http://scientificarts.com/worklife > I just read the latest intriguing blog entry on the Wolfram site. > It reports the May 09 opening of the the Wolfram/Alpha >> site: a sort of Does anybody knows a bit more (and is willing to speak :-) ) ? What I find also amazing is that this project must have engaged a > considerable amount of WRI resources, financial time and human, yet > they managed to keep all this very quiet. Exciting isn't it? > -- Peter Lindsay === Subject: Re: Wolfram/Alpha > In the same evening, the entry was deleted, since it met Wikipedia's > forum, webcomic, podcast, browser game, or similar web content that does not > indicate the importance or significance of the subject. What to say about that? Wikipedia is swamped by people looking for a free advertising about WA is just the same as one about an obscure blog. its significance is established. Robert Dodier === Subject: Re: Wolfram/Alpha it is already well known that the answer will be 42 Jens > I am not involved, and know nothing about it, so I can speak open about it > without risking being killed for that (hopefully!). I am as curious as > anyone. There is more to read beneath the following link http://www.twine.com/item/122mz8lz9-4c/wolfram-alpha-is-coming-and-it-could- Saturday morning (March 7, 2009) I found the following on Wikipedia, > Wolfram Alpha: > Wolfram|Alpha is a new futuristic search engine equipped with artificial > intelligence, to be introduced in May 2009 by Wolfram Research. Its > spiritual father, Stephen Wolfram, explains that it will be able to > translate natural language into a format comprehensible to computers and > search through trillions of pieces of curated data and millions of lines of > algorithms to provide the user with a valuable answer. In the same evening, the entry was deleted, since it met Wikipedia's > forum, webcomic, podcast, browser game, or similar web content that does not > indicate the importance or significance of the subject. What to say about that? Ingolf Dahl > Sweden >> -----Original Message----- === >> Subject: Re: Wolfram/Alpha >> As you might expect, any who are in the know, and who tell, >> would have to kill or be killed. >> Suffice it to say that it is very interesting and will grow >> into something quite overarching. >> --David (who wants to remain alive) >> http://scientificarts.com/worklife > I just read the latest intriguing blog entry on the Wolfram site. > It reports the May 09 opening of the the Wolfram/Alpha >> site: a sort of Does anybody knows a bit more (and is willing to speak :-) ) ? What I find also amazing is that this project must have engaged a > considerable amount of WRI resources, financial time and human, yet > they managed to keep all this very quiet. Exciting isn't it? > === Subject: Re: Wolfram/Alpha Well...it shows that Wikipedia is very efficient at enforcing its rules. === Subject: Share symbols among packages Hello group, How to use Global symbols in several user packages? That is, I have: BeginPackage[MyPack1`] myVar::usage=My var; myFun1::usage=My fun1; Begin[`Private`]; ... (* use myVar *) ... End[] EndPackage[] BeginPackage[MyPack2`] myVar::usage=My var; myFun2::usage=My fun2; Begin[`Private`]; ... (* use myVar *) ... End[] EndPackage[] And then I would like to do like this: myVar=data; myFun1[a,b,c] myVar=data; myFun2[a,b,c] The problem is: myVar::shdw: Symbol myVar appears in multiple contexts !({MyPack1` , MyPack2`}); definitions in context !(MyPack2`) may shadow or be shadowed by other definitions. Any ideas? -Andrey === Subject: Re: String substitution system THX for the answers. While I'm at it anyway, is it still that easy when I need substitution rules with placeholders? E.g. XY->YZ for fixed X,Z but any string Y? -- Hauke Reddmann <:-EX8 fc3a501@uni-hamburg.de Nur Schufte schuften - Genie genie§t. === Subject: Re: Do What I Mean - a suggestion for a bit of a ramble: The purpose of language is communication [ I think ]. There are so many modes of communication; music, mathematics, spoken/written word, etc. Within those modes there are so many levels of sophistication; Chopsticks to Brandenburg Concerto, Addition to Incompleteness Theory, Where's my coffee ? to Slouching towards Bethlehem. Language has to accommodate precision, otherwise you won't know what the other person means. Overly precise rules of language stifle creativity. But too-slack rules generate imprecision and communication breakdown. I've never tried writing poetry, but I know if I did - fortran would not be my language of choice. Similarly, if I was trying to write code for Fourier transforms - Gaelic would not be at the top of my list. In any case, the great thing about language is it can generate new ideas. My first point: But you need to be fluent in the language before that can happen. That fluency comes with practise and learning the precise rules of the language so well that they are second nature. That's when the ideas start coming. My second point: I think Mathematica is great language. I'm only an engineer, but i'm told by experts that languages like Mathematica can be used for theorum-proving as well as excelling at number-crunching. The best languages [ in any mode ] can do both low and high levels of sophistication. Peter 2009/3/7 David Park international phone calls' or 'driving a car' (say). There the task is > fairly routine and almost everybody is expected to be able to do it. With > engineering, every task is new. Mathematica is not like an HP or TI > calculator, or an older slide rule. It is, by its very nature far more > complex to learn because we are asking it to do far more. The model is more > like learning to be good at expository writing, or good at mathematics > itself, or learning to be a good poet. There is no royal road. It is not > just button-pushing. Mathematica is both very powerful and evolving. In my opinion we are still > learning how to use it. I don't think anyone knows how to fully exploit it > yet - not even the people at WRI. So it's an adventure, and a rather > exciting one. Join in. > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ I do not think it is even a good > idea to attempt to make Mathematica accessible to users with > minimal computer/mathematics experience/knowledge assuming this > is even possible. I guess we'll just have to disagree -- vehemently! -- on this one (and > also with great sadness on my part, if this should represent Wolfram's > anything like Wolfram's actual views or objectives). By sheer coincidence, a few minutes after seeing the above post I read > the following post in another newsgroup (it's a big long, but just skim > down to the end): POST FROM COMP.DCOM.TELECOM, FEB 2009: This thread reminded me of one of my favorite > published papers (because of its sheer readability) and I could not > resist bringing it to the attention of others, old and dated though it > may be. Scrounge through the stacks of your local engineering > library: Test yourself: how much do you know about international > communications? [International numbering systems] Robrock, A. (Italtel, Milan) > IEEE Communications Magazine, December 1989 > Volume: 27, Issue: 12 Abstract We like to think of international telephone communications as > `transparent', the successful outcome of 100 years of technical > progress and standards setting, but the author shows us that it is > not. The user still has to be something of an expert to understand how > to make international calls, and there are chaotically differing > numbering systems for telephony, telex, and electronic mail. We should > be reminded that usability of services, not just their usefulness, is > a critical component of communications. Simplicity, consistency, and > rationality of service features and the `human interface' that allows > users to invoke them should be a high priority for communications > engineers as they work toward the integrated services networks of the > future Besides the chaotically differing phraseology, it's the final two > sentences that catch my eye. Should Mathematica interface designers > maybe be reminded that it's the _usability_ of software, not just its _usefulness_, > that's a critical component of software interface design and even better Simplicity, consistency, and rationality of software features > ** and the `human interface' that allows users to invoke them ** > should be a high priority for software designers as they work toward > the integrated services networks -- sorry, integrated software > packages -- of the future. Interesting -- _integrated_ software packages? -- don't I recall that > that's one of the big selling points for Mathematica? (although one that > I personally believe can really only be effectively achieved -- for > software that is, not necessarily for networks -- using a much more > modular approach. > There are a great many things in mathematics that work in > specialized cases. For example, a user with little experience in > mathematics likely would expect Sqrt[x^2] to simplify to x. But > that transformation is only valid when x is real and positive. > If Mathematica were to automatically do this simplification (or > many others of a similar nature) it would not be an adequate > tool for me or many other users since it would be creating > erroneous output. Worse, even for those users where this > happened to be the correct output, the issue gets hidden and > they would learn to trust Mathematica only to lose trust when > things were more complex. The point is mathematics is complex. A tool designed to > implement mathematics can hardly be less complex. Attempts to > reduce the complexity invariably mean some aspects (typically > special cases) of the mathematics are being ignored or hidden. > Ignoring or hiding such special cases limits the usefulness of > Mathematica. Don't really disagree on the facts here -- just the operational > conclusions: 1) Are you really saying that the whole series of superb hp calculators > out of which I got so many useful scientific and engineering results in > earlier years -- and which, incidentally and painlessly, also gave me at > least an introduction to the concepts of Reverse Polish notation and > stacks as an aside -- should not have had a Sqrt[x] key? [And incidentally: Would you not like to see Mathematica be as widely > used, and useful, as were those superb tools?] 2) I'm an engineer and physicist; other potential Mathematica users > might be from innumerable other practical fields (econ, stat, business, > etc etc). We know some math; varying amounts for different fields and > levels within fields. We know there are complexities in math that we > may not understand. But we also have the protection that when we > calculate results using some, we can (and do!) look at them and apply > physically reasonable criteria (or realistic results in other > fields) as part of our criteria. We don't denigrate rigor, or fail to > take care about the possibility of unanticipated special cases. But we > have _other_ tools that mathematicians don't have, to help us cope with > the possibility of those. -- Peter Lindsay === Subject: Re: Version 7.0.1 bug with initial Palette positions I always find that a nice cup of tea helps in these situations.Peter 2009/3/7 Bob F some of the palettes correctly when starting up. I have a dual-screen > Mac setup and I put all my palettes on the left screen, and Notebooks > on the right primary screen so I have visibility of my notebook > windows at all times and not obscurred by the palettes that don't like > to cohabitate with normal windows (something I still find to be a > royal pain -- why cant they be like any other windows - yes I know you > can change their floating attributes, but the whole idea of not > behaving like any other window is so contrary IMO, you can't resize > them, you cant minimize them, etc). So in this case the WindowMargins parameter in the init.m setup file > had a negative left and top number and Auto for right and bottom. But, > for some strange reason only the ClassroomAssistant palette was > incorrectly placed on the left screen and before with 7.0 and 6.0 and > 5.2 things were fine (all the other 4 or 5 palettes came up in the > expected position which is even more bizarre actually - I can only > guess that the code that does the placement of the palettes is > individually isolated to each and every palette and not a general > purpose routine that all share, otherwise all would exhibit the > problem cause they are all on the left screen). The most bizarre > problem is that sometimes one of the other palettes would do this and > not the Classroom assistant, but not very often, and certainly not > repeatable as far as I can tell. The really ugly thing is that the ClassroomAssistant palette was > positioned so that the title bar was underneath the main Apple/ > Mathematica menu along the top of the primary screen and no matter > what I did, I could not move it. It's title bar was underneath and > totally not reachable. What I ended up doing was using the OptionInspector to change the > WindowMargins parameters so that it was lower on the primary screen so > that I could drag it where I wanted it on the left screen, or just > change it to what it should have been to begin with. But when exiting > Mathematica and then restarting, the same thing occurs all over again. > WHAT A PAIN!!!! And on top of that the init.m file is rewritten on the > fly when Mathematica starts up to change what it considers as an > invalid margin setting and changes them to what it thinks are valid, > but no message ever indicates that it just mucked with the settings in > the init.m on it's own prerogative for this ClassroomAssistant > palette, so you are forced to move it to where you really want to > every time you start up Mathematica as I described with the Option > Inspector and I spend a minute or two every time Mathematica starts up > to fix a problem it caused! I can't believe this simple user interface issue escaped the QA > process, and the beta testers. The only thing I can guess is that a > two screen setup is not common. When I called Wolfram to see about > this, the person in support was able to locate a dual-screen Mac and > verify that the problem occurs there also. So they have the ability to > test dual screen setups, but guess they either didn't do at all, or > not very extensively. Very disappointed in my first excursion into > 7.0.1 land -- but I will get over it. Now I will only have to wait 6 > months or maybe a year and the fix will be available. And I pay money > for this??? In the meantime, I know how to get around the problem - > thank goodness for the option inspector. Why oh why oh why do people put up with this kind of software > problems!! Wolfram get your act together and come up with some way to > get patches to people on a timely basis for when you create bugs and > problems and don't catch trivial bugs you create in releasing new > versions, let alone the hard ones. This is not the first time this has > happened, far from it. I am sure everyone on this list has stories > that would cause us all to shake our heads in familiar disappointment > and belief. If people feel the same, please let your Wolfram sales and > support contacts know how disappointing this kind of problem is and > encourage them to come up with a solution. That Mathematica is such a powerful tool is it's saving grace, but > Wolfram -- wake up and smell the coffee! Remember a company called > Quark, who was so world famous about not giving a rat's behind about > customers problems -- now Adobe has virtually killed them off because > better job of QA and do a better job of coming up with a way to solve > bugs, rather than wait for months and years and the next release. > THERE HAS TO BE A BETTER WAY. Solve it and you will have even more > loyal and fanatic customers. Of course, I realize that the problem is not rampant, but a relatively > rare, and certainly Wolfram is not the only one suffering from this > problem. It only becomes such a frustrating issue when it affects > things in what I am doing or try to do, and I say to myself that this > ought to work, that I get so disappointed. And I am sure that we all > have shared in this frustrating experience before. But the fact that it happens again and again and again is the part > that completely baffles me and makes me think how could they shoot me > in the foot again and think I wouldn't say ENOUGH IS ENOUGH!!!! I am > so disappointed with bad, careless, and sloppy programming - why after > about 60 or 70 years of the science of programming and all the > advancements of computer hardware, do things like this continue to > occur? It is not just Wolfram, but rampant in the entire field of > software. The complexity of code today and the difficulty in solving > trivial as well as difficult problems is hardly any better today than > decades ago. Since the overall complexity of software solutions is so > many orders of magnitude greater, the only saving grace is that the > hardware is so much faster as well. Otherwise we would be in a truly > dismal position. But I am sure there is a solution for this problem, and Wolfram does > have some of the most talented and resourceful and intelligent people > in the world. My wish is that they solve some really fundamental > problems so that customers don't have to continually have to go thru > this frustration on every release and every bug, but instead remember > and chant to themselves Just wait for the next release - the problem will be solved, or at > least moved to some other, hopefully unimportant, spot. In the meantime, just don't do it that way, no matter how much you > think that it should work or not work that way. Adapt and be happy, as > the alternative is rather miserable. -Bob -- Peter Lindsay === Subject: Maximum in a list Suppose a list mylist={{1,2},{3,4},{8,3}} I would like to extract the element {i,j} of mylist for which j is max (here, it is the second one {3,4}). Somebody could help me, please? Pacotomi === Subject: Re: Bug in Pattern Matching with Condition? Condition[_,_] as a pattern will match nothing since its test expression is _ aka Blank[] and is not equal to True. === Subject: Re: Style for function calls? I agree with some of the above statements. 1. I never use postfix in any routines. I usually only for testing and debugging code in notebook format. As said above, its useful for doing lazy transformation and works well under the analog of pipes. 2. I never use infix beyond the built in uses. 3. I prefer to use prefix for avoiding trails of end-brackets, however I never prefix to a single value. ie. f[g[h[i]]]] -> f@g@h[i] 4. I try to avoid the use of explicit parentheses. ie. f /@ ( .... ), to me, looks better as: Map[f, ...] 5. Lastly, I am free to break any rule and restructure my code if order of operation is not obvious. However, this rarely happens if you stick to the above or similar criterion. === Subject: Careless use of Scaled leads to hard crash in V7 I just saw a crash in Mathematica V 7 on Mac OS X Tiger and Leopard. The program (reproducibly) quits unexpectedly after doing the following: 1) Evaluate Graphics3D[{Arrowheads[Scaled[.05]], Arrow[Tube[{{0, 0, 0}, {1, 0, 0}}, Scaled[.05]]]}] 2) Use arrow keys to go back to previous input cell and try to delete the occurrence of Scaled[.05] in Arrowheads, replacing it with .1 or some other value. You may not even get this far, the crash sometimes happens earlier. 3) Repeat steps 1 and 2 if necessary. There briefly is an Internal Self Test Error message before the crash wipes Mathematica off the screen. This is not exactly the most pleasant way of learning that Scaled lengths can't be used inside Arrowhead. I wonder if this crash also happens on other platforms. Jens === Subject: Re: A newbee to Mathematica Mathematica has two sets of graph functions, one set natively built-in in 7 and one delivered by the Combinatorica package. The latter one is an external development and its graph structures differ from the internal ones. Mathematica can use the Combinatorica graph structurs, but not vice versa. is from Combinatorica and GraphPlot3D is a built-in function. If it were the other way around you would need to convert the graph. The built-in functions can handle adjaceny matrices, so you wouldn't need Combinatorica if the only thing you want is visualizing a graph. I believe that the adjacency matrices Mathematica uses are binary and you are using edge weights. However, the problem you have follows from typos. Instead of: EdgeLabeling -> True] GraphPlot3D[g] you probably intended to write: GraphPlot3D[g, VertexLabeling -> True, EdgeLabeling -> True] This works, but there are issues as well. Syntax coloring shows that EdgeLabeling is not an option of GraphPlot3D. It is an option of GraphPlot. However, since you haven't given any edge labels this option doesn't make sense. > Hi I have just started using mathematica,and therefore have a very silly = question that needs an answer. > I am trying to run this: > Needs[GraphUtilities`] > Needs[Combinatorica`] > am = {{1, 0, 1, 2, 0, 1, 2}, {0, 0, 0, 0, 1, 1, 1}, {1, 0, 0, 1, 1, 1, > 1}, {0, 3, 1, 4, 1, 0, 1}, {0, 1, 1, 1, 0, 1, 0}, {1, 1, 1, 0,= 1, > 0, 0}, {1, 1, 5, 1, 0, 0, 0}}; MatrixForm[am] > EdgeLabeling -> True] > GraphPlot3D[g] > I am getting this error message: > GraphPlot3D::grph:Graph:<11,7,Undirected> is not a valid graph. BASICALLY what I want to do is to generate a 3d graph from a given adjace= ncy matrix,with the elements of the matrix showing the weights of each edge= > === Subject: Re: A newbee to Mathematica am = {{1, 0, 1, 2, 0, 1, 2}, {0, 0, 0, 0, 1, 1, 1}, {1, 0, 0, 1, 1, 1, 1}, {0, 3, 1, 4, 1, 0, 1}, {0, 1, 1, 1, 0, 1, 0}, {1, 1, 1, 0, 1, 0, 0}, {1, 1, 5, 1, 0, 0, 0}}; GraphPlot3D[am] ?? Jens > Hi I have just started using mathematica,and therefore have a very silly question that needs an answer. > I am trying to run this: > Needs[GraphUtilities`] > Needs[Combinatorica`] > am = {{1, 0, 1, 2, 0, 1, 2}, {0, 0, 0, 0, 1, 1, 1}, {1, 0, 0, 1, 1, 1, > 1}, {0, 3, 1, 4, 1, 0, 1}, {0, 1, 1, 1, 0, 1, 0}, {1, 1, 1, 0, 1, > 0, 0}, {1, 1, 5, 1, 0, 0, 0}}; MatrixForm[am] > EdgeLabeling -> True] > GraphPlot3D[g] > I am getting this error message: > GraphPlot3D::grph:Graph:<11,7,Undirected> is not a valid graph. > === Subject: Re: A newbee to Mathematica I don't understand the line of code that begins: > Hi I have just started using mathematica,and therefore have a very silly question that needs an answer. > I am trying to run this: > Needs[GraphUtilities`] > Needs[Combinatorica`] > am = {{1, 0, 1, 2, 0, 1, 2}, {0, 0, 0, 0, 1, 1, 1}, {1, 0, 0, 1, 1, 1, > 1}, {0, 3, 1, 4, 1, 0, 1}, {0, 1, 1, 1, 0, 1, 0}, {1, 1, 1, 0, 1, > 0, 0}, {1, 1, 5, 1, 0, 0, 0}}; MatrixForm[am] > EdgeLabeling -> True] > GraphPlot3D[g] > I am getting this error message: > GraphPlot3D::grph:Graph:<11,7,Undirected> is not a valid graph. > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: String substitution system Possibly this does the job? Clear[cycle, twoStep, legalize, fixedPt, minimums] cycle[s_String] := Table[StringDrop[s, n] <> StringTake[s, n], {n, 1, StringLength@s}] twoStep[s_String] := Union@Flatten[legalize /@ cycle@s] legal = {CC -> C, DD -> D, CA -> C, AC -> C, DB -> D, BD -> D, CDC -> C, DCD -> D, CBC -> C, DAD -> D, ABC -> DC, CBA -> CD, BAD -> CD, DAB -> DC, BAB -> ABA} /. Rule[x_Symbol, y_Symbol] :> Rule[ToString@x, ToString@y]; legalize[s_String] := Union[{s}, StringReplaceList[s, legal]] fixedPt[s_List] := FixedPoint[Union@Flatten[twoStep /@ #] &, s] fixedPt[s_String] := fixedPt@{s} minimums[s_String] := Module[{f = fixedPt@s, lengths}, lengths = StringLength /@ f; Pick[f, lengths, Min@lengths] ] minimums@DAB {AD, CD, DA, DC} minimums@CBBA {BBC, BCB, CBB} Answers don't appear to be unique, as you can see. Bobby > Another question that is probably too trivial for you :-) I want to generate all words A,B,C,D,AA,AB,...,DD,AAA,... > until, eh, 6-7 letters should suffice, and put them in a list. > The following string replacements are legal: > CC->C > DD->D > CA->C > AC->C > DB->D > BD->D > CDC->C > DCD->D > CBC->C > DAD->D > ABC->DC > CBA->CD > BAD->CD > DAB->DC > BAB->ABA > Note that everything but the last one shortens the word > and thus strings containing these substrings may be simply > dropped if you generate the words ordered by length, but the last > one is a bit tricky - BABBC=ABABC=AABAC=AABC and > ABAAD=BABAD=BBABD=BBAD so you may have to use it both > ways and repeatedly. > Now I'm an old FORTRAN chap and being nearly 50 years old, > I probably won't learn the Kamasutra of recursive function > calls anymore :-) But surely you'll have a three-liner > for this problem? > P.S. Actually the strings are cyclic too - CBBA=ACBB=CBB. > P.P.S. Remember, poor University, version 5.2 ;-) -- DrMajorBob@bigfoot.com === Subject: Re: String substitution system vAlphabet = {A, B, C, D}; vWords = Map[ StringJoin, Join @@ Table[Tuples[vAlphabet, i], {i, 7}] ]; vRules = {CC -> C, DD -> D, CA -> C, AC -> C, DB -> D, BD -> D, CDC -> C, DCD -> D, CBC -> C, DAD -> D, ABC -> DC, CBA -> CD, BAD -> CD, DAB -> DC, BAB -> ABA}; FixedPoint[StringReplace[#, vRules] &, vWords] === Subject: Re: Forgets Variables? I can't get the first statement to execute (in the time I'm willing to wait). If you gave us the values of maxX, eqTime, v, lifetime27SA, et cetera, we'd waste a lot less time guessing what your problem might be. If you want help, ALWAYS start us off where you are. Don't make us flounder around where you've already been. Because, of course, why should we? That said, I'd start by simplifying until the code is understandable, at which point the error will reveal itself. For instance, this: If[v*(tsum - lifetime35S - eqTime) < 4000, v*(tsum - lifetime35S - eqTime), 4000] is equivalent to the simpler (and faster) Min[v*(tsum - lifetime35S - eqTime), 4000] Similarly, this expression: If[v*(tsum - eqTime) < 4000, Max[v*(tsum - eqTime), 0], 4000] is equivalent to Max[0, Min[v*(tsum - eqTime), 4000]] Next, it's easy to see that If[v*(tsum2 - eqTime) < 4000, Sum[Max[v*(tsum - eqTime), 0], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}], Sum[Max[0, Min[v*(tsum - eqTime), 4000]], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}]] is equivalent to Clear[q] q[ts_] := v*(ts - eqTime); If[q@tsum2 < 4000, Sum[Max[q@tsum, 0], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}], Sum[Max[0, Min[q@tsum, 4000]], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}]] and that's equivalent to (since the Sums have the same limits): Clear[q] q[ts_] := v*(ts - eqTime); Sum[If[q@tsum2 < 4000, Max[q@tsum, 0], Max[0, Min[q@tsum, 4000]]], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}] Similarly, the first If statement: If[v*(tsum2 - lifetime35S - eqTime) < 4000, Sum[Max[v*(tsum - lifetime35S - eqTime), 0], {tsum, tsum2 - lifetime27SA + 1, tsum2}], Sum[Min[v*(tsum - lifetime35S - eqTime), 4000], {tsum, tsum2 - lifetime27SA + 1, tsum2}]] is equivalent to Clear[q] q[ts_] := v*(ts - lifetime35S - eqTime); Sum[If[q@tsum2 < 4000, Max[q@tsum, 0], Min[q@tsum, 4000]], {tsum, tsum2 - lifetime27SA + 1, tsum2}] Combining both tricks into one reduces the original expression to: Clear[q] q[life_][ts_] := v (ts - life - eqTime) callNormValue = 60/maxX Sum[ Sum[If[q[lifetime35S]@tsum2 < 4000, Max[q[lifetime35S]@tsum, 0], Min[q[lifetime35S]@tsum, 4000]], {tsum, tsum2 - lifetime27SA + 1, tsum2}]*(1 - P) + Sum[If[q[0]@tsum2 < 4000, Max[q[0]@tsum, 0], Max[0, Min[q[0]@tsum, 4000]]], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}]*P, {tsum2, 60, t2, 60}]; That still won't evaluate without values for all the parameters, but you're the only one that knows those, or even knows what ranges they might lie in. One trick you MIGHT pull, however, is this: Clear[q] q[life_][ts_] := v (ts - life - eqTime) callNormValue = 60/maxX sum[ sum[If[q[lifetime35S]@tsum2 < 4000, Max[q[lifetime35S]@tsum, 0], Min[q[lifetime35S]@tsum, 4000]], {tsum, tsum2 - lifetime27SA + 1, tsum2}]*(1 - P) + sum[If[q[0]@tsum2 < 4000, Max[q[0]@tsum, 0], Max[0, Min[q[0]@tsum, 4000]]], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}]*P, {tsum2, 60, t2, 60}]; (Now the statement executes.) callNormValue /. {lifetime35S -> 17, P -> 0.7, t2 -> maxX, sum -> Sum} (The other parameters still need values, but those could be added to the rule list.) Bobby > Hi there, i have the following procedure: callNormValue = (Sum[ > If[v*(tsum2 - lifetime35S - eqTime) < 4000, > Sum[Max[v*(tsum - lifetime35S - eqTime), 0], {tsum, > tsum2 - lifetime27SA + 1, tsum2, 1}], > Sum[If[v*(tsum - lifetime35S - eqTime) < 4000, > v*(tsum - lifetime35S - eqTime), 4000], {tsum, > tsum2 - lifetime27SA + 1, tsum2, 1}]]*(1 - P) + > If[v*(tsum2 - eqTime) < 4000, > Sum[Max[v*(tsum - eqTime), 0], {tsum, > tsum2 - lifetime27SANTC + 1, tsum2, 1}], > Sum[If[v*(tsum - eqTime) < 4000, Max[v*(tsum - eqTime), 0], > 4000], {tsum, tsum2 - lifetime27SANTC + 1, tsum2, 1}]]* > P, {tsum2, 60, t2, 60}])/(maxX/60); i call it with: > callNormValue /. {lifetime35S -> 17, P -> 0.7, t2 -> maxX} it gives me a proper result, but as soon i change t2 to maxX in the > first expression (where i do the sums) it doesn't evaluate the the > procedure anymore (maxX has a global value already set). I have > actually quite a lot of trouble to hand over values to this > procedure.. and i have no idea why it doesn't work. (for except lifetime35S,P and t2 all the variables have a set value) thank you, Ktota -- DrMajorBob@bigfoot.com === Subject: Re: Forgets Variables? When t2 is defined, Mathematica is probably evaluating (and expanding) callNormValue. What you need to do is preserve the form of callNormValue (aka prevent evaluation) until you have all known values. Either, 1. Wrap callNormValue in a Hold statement. Then perform the replacement, and call ReleaseHold. held = Hold[ 3 + 9x ]; ReleaseHold[ held /. {x->2} ] 2. Make callNormValue a function. === Subject: Re: typsetting bug still present in Mathematica 7.01 On Mar 7, 9:41 am, Jens-Peer Kuska and you are sure that this is a bug ? [DifferentialD] is an > operator for the total differential and has a build-in meaning > while [CapitalDifferentialD] has no build in meaning and AFIK > the only use of this character is in a Feynman path integral > to denote differential like integration variable over the path. > Since Mathematica can't do path integrals (jet) it is an ordianry > letter like [Alpha], ... and can combined with other unicode > letters. > Actually it's not just a simple letter, it's an operator without any built-in meaning. Note that the FullForm of the output is CapitalDifferentialD[x] I'd personally expect [DifferentialD] to behave the same as [CapitalDifferentialD] when formatted in StandardForm/TraditionalForm. === Subject: Re: Wolfram/Alpha As you might expect, any who are in the know, and who tell, would have to kill or be killed. Suffice it to say that it is very interesting and will grow into something quite overarching. --David (who wants to remain alive) http://scientificarts.com/worklife > I just read the latest intriguing blog entry on the Wolfram site. > It reports the May 09 opening of the the Wolfram/Alpha site: a sort of Does anybody knows a bit more (and is willing to speak :-) ) ? What I find also amazing is that this project must have engaged a > considerable amount of WRI resources, financial time and human, yet > they managed to keep all this very quiet. Exciting isn't it? === Subject: Re: Mathematica 7.0.1.0 and some General Comments Prof. Siegman, I seriously doubt that you have ever seen a significant topic presented in a completely active and dynamic Mathematica notebook. If you had, I don't see how you could possibly confuse it with the alternatives you list below. A comparison with PowerPoint is especially outlandish! If you are going to compare two things then it is only fair to look at both of them. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Unfortunately here we have to part company. Your second sentence above makes it seem as if you've never heard of PowerPoint -- which is very possibly the dominant method of publication and communication in the technical world today -- along with QuickTime, HTML, Flash, Word, TeX, LaTeX, the entire Adobe product line, and the ever expanding set of online and multimedia journals and innumerable personal and institutional web sites, all of which, working together quite constructively in most cases, are nearly obliterating static printed documents, in the technical world and everywhere else. === Subject: Re: Mathematica 7.0.1.0 and some General Comments > There were hundreds > of responses with some threads going to great depth. As far as I could = find, > there was not a single mention of Mathematica and only one reference to > using a CAS. Everything else concerned the merits of C++, Perl, List, > Fortran etc. To me, this again was incredible. It seems to me that the alternatives listed are all Open and Free. > Mathematica has very favorable student licences, but what happen when > the student leave school/uni? The price, albeit justifiable, is very > high for a yet-to-be-employed graduate. It may be better to learn basic > tools one can afford later on. Except that none of the tools above were meant for the same purpose as CASs/Mathematica. > IMHO. Humbleness and asserting one's unsolicited opinion are pretty much contradictory. === Subject: Re: Mathematica 7.0.1.0 and some General Comments I don't Mathematica could, or should, become the de facto standard for mathematics communication. Its a bit like insisting that all written documents from now on must be done in MS Word. However I do think that the Mathematica Player is an excellent tool and is actually quite a generous gift from Wolfram Research to the mathematical community.Peter 2009/3/7 ADL thing WRI developers could do against Mathematica itself was (and is) > to hide the bug list and the list of fixes. > This overall gives the feeling of a substantially unreliable system. Generally speaking, I am fond of the basic Mathematica structure, I > use it every day to solve practical issues in my job and also develop > some rather complex programs, but admittedly would never fully rely on > a piece of software in which new bugs are introduced all the time, > also in appearently consolidated areas, and for which fixes are never > documented and established once for all. On the contrary, WRI has undertaken the introduction of thousands new > features, many of which do not appear to work exactly as expected, are > ofted superficially documented, are difficult to print and study in > detail and are sometines stubbornly affected by some suboptimal > design, which makes their application counterintuitive or error prone. > Most Mathematica books are full of astonishing one-liners (perhaps > 1000 characters long), while a lot of people are still stuck with > FindRoot, Eigenvectors, FourierTransform, etc etc. To make a simple > plot, it is often better (sometimes recommended) to quit Mathematica > and use a general-purpose spreadsheet. It is surely a strategy, it might support some cash flow, but I do not > believe it is a winning strategy. About one / two years ago, WRI proudly declared that they had reached > the millionth build of Mathematica. Now, there are surely many more. > Why they did not realize that this very bad advertisement for a sw > with 6 official versions (at that time) and strong indication of a > very bad design? This is an explicit declaration that Mathematica is > not amenable to incremental development, that is the only way towards > reliability. I do not understand why and I am sad about it, but after reading this > Group for about one year and having used Mathematica since version 3, > to me WRI appears to be strongly determined NOT to become a winner in > this arena. ADL > ... David Park djmp...@comcast.net http://home.comcast.net/~djmpark/ > -- Peter Lindsay === Subject: Re: Mathematica 7.0.1.0 and some General Comments One thing that Mathematica users could do is to set up a Wiki where they maintain their own list of known Mathematica bugs. Of course, this is really what WRI should do, not us. But, here are a few reasons why it might be an advantage for us to do so: * In this way Mathematica users would declare their position regarding the way Mathematica is being developed. * Individuals and organizations that are considering buying Mathematica would see that it actually contains lots of bugs and those bugs don't get fixed. That would discourage them from buying Mathematica and make WRI to rethink their strategy. * Mathematica users could check if their bugs are already known without wasting their time to submit the bug reports. * It would be easier to monitor which bugs get fixed and which don't. ~Maris Ozols~ === Subject: Re: Mathematica 7.0.1.0 and some General Comments On the other hand, I am also (equally sadly) not at all surprised by the > above observations. The bizarre and idiosyncratic and dysfunctional way > that Mathematica has evolved, in its structure and syntax, in its user > interface, You keep saying things like this, and I can only continue to disagree. The structure and syntax of Mathematica is completely consistent, and is not difficult to learn for anyone who is willing to put in a little time and effort. The new Classroom Assistant and Basic Math Input palettes make learning the syntax even easier. When we switched over to 7.0 this semester, I had some experienced Mathematica users in my classes, and some newbies. The newbies relied heavily on the new palettes when they were getting started, and by doing so avoided most of the syntax errors that newbies usually made in past semesters. They quickly caught up with their classmates in using Mathematica effectively, and most of the students use the palettes lightly; they find it quicker and easier -- yes, *easier*, because they understand the syntax -- to type in most Mathematica commands themselves. > in its pricing, and in its documentation, among other > factors, all contribute significantly to the dismal situation summarized > by David above. I don't understand how things can have gone so wrong > for Mathematica -- but they have. Ten years ago I was writing enthusiastic memos to my Deans and Vice > Provosts for Research, and my university's IT people, urging them to > invest university funds in Mathematica licenses and bookstore discounts; > to sponsor (or pay for) free training courses for students, faculty and > staff through the university; to promote the use of Mathematica > throughout every even mildly technical area of the university; and to > make it a kind of semi-official university standard for all areas of > research and teaching (as they had, at that time, semi-officially done > for the Mac platform). To be blunt, if a proposal like that were actually to be taken under > consideration by my university today -- not that there's any chance that > this could actually happen at this point -- I would actively oppose it, > or at least recommend that a major effort be undertaken to explore every > other possible substitute (and there are some out there) to meet the > same needs. We have a Mathematica site license at my institution that allows Mathematica to be installed on all university owned computers as well as computers personally owned by faculty, staff, and students. The students learn to use Mathematica as they go through the calculus sequence, and continue to use it as they go on in mathematics, physics, chemistry, etc. Yes, there is a learning curve, just as there is with mathematics itself, or with anything else that is worthwhile. It is 100% worth the effort. All of my students succeed in learning to use Mathematica effectively. All it takes is to provide them all with Mathematica, teach them the basics of using Mathematica at the beginning of the semester, use Mathematica routinely in class and require its use on assignments, and provide some support for the students (office hours, help sessions, e-mail, etc.) -- Helen Read University of Vermont === Subject: Re: Mathematica 7.0.1.0 and some General Comments > I was mildly disappointed that some fixes did not appear in Mathematica > 7.0.1.0. Some of these appear to be platform dependent but they were > verified on MathGroup by other users besides myself. 1) In Input cells the vertical bar or Mathematica Alternatives symbol does > not display properly. It only shows a short truncated stub. It does display > properly in Output cells and it does perform properly. This seems to occur > only with certain font sizes and magnifications. a|b 2) There is still a problem with the various types of Density plots in that > part of the plot Frame is cut off. DensityPlot[Sin[x y], {x, 0, 3}, {y, 0, 3}] 3) In many situations Copy and Paste do not work properly from the context > menu. I consider this a major problem. I was warned that this fix would not > appear in 7.0.1.0, but I would have preferred that the update be delayed > until it could be fixed. I personally am greatly relieved they did not wait any longer. In fact, I would have liked an update far sooner than this. The printing bug was a huge pain. Students would end up having to print their work two or three or four times before finally getting the pages to break correctly. Aside from the aggravation, it was a big waste of time and paper. So far it seems to be working correctly in 7.0.1. The other bug I'm very glad to have fixed is the problem of the keyboard shortcuts (Alt-7 to for a Text cell, etc.) becoming disabled any time you do a right-click (for example to copy/paste). I tried to avoid opening up any context menus, but of course I'd sometimes forget, then the shortcuts didn't work until I clicked off the notebook and back again. It was incredibly annoying. I am *much* happier now that this is fixed. > It is a bit more than a minor chore to do an update of Mathematica. Perhaps, but it's worth it to me to have what I consider the worst bugs fixed. And the 7.0.1 installation is pretty easy if you already have 7.0.0 installed. If you accept all the default options, it goes ahead and uninstalls 7.0.0, sucks up your mathpass and init.m files, and installs 7.0.1. Even in a lab setting with multiple computers, it's pretty easy. A colleague and I maintain the computers in two math classrooms (62 computers total), and we will install 7.0.1 over our spring break next week, without having to re-image the machines. We tried out a silent install yesterday on a couple of test machines, and it worked beautifully. We made up a little command file that connects a computer to a network share where we have the Mathematica installation files, and tells the computer to install Mathematica without anyone having to answer questions or click Next. All we have to do is send the ..cmd file out to all the client computers and execute it, all of which we can do remotely. -- Helen Read University of Vermont === Subject: Re: Mathematica 7.0.1.0 and some General Comments I disagree completely as to Power(less)point, at least. Like Project, Excel, Word, Windows, Money, Windows itself, and every other MS application I can think of, Powerpoint has barely improved AT ALL in 15 years. More bells and whistles, yes; significant improvement in functionality or paradigm? No. But if that's what you like, fine. Of that group, Money is WORSE than frozen in time. It degrades continually. It has no on-disk documentation now, its online docs are useless, EVERY default setting is the least convenient possible, and Vista was shipped incompatible with it due to IE security defaults. You couldn't reach banks, and you couldn't reach online documentation so that you could hope to fix the problem. A MS app, incompatible with a MS operating system. Astonishing! (I found a fix, but MS was definitely not the source.) Encarta was my favorite encyclopedia, better than anything I can find today, but they simply abandoned it. So... if you depend on Powerpoint for anything, you're very trusting. Meanwhile, Mathematica gains power in all directions at a phenomenal rate. True, it outstrips its documentation, and I'm a well-known critic of THAT... but MS applications, arguably, are worse. Anyway, I like being able to do just about ANYTHING in a single application (Mathematica). I agree on the price-point for a first-time purchase, but Premium Support, with its free upgrades, isn't a bad deal, at all. (The support has never helped me one iota, but the upgrades are worth it, anyway.) In every way, it's a long-term investment. Bobby > The 2 January 2009 issue of Science was largely devoted to 'Education >> and >> 'virtual reality', java applets and such but I could not find a single >> mention of Mathematica or even CASs in general. To me, this is >> absolutely >> incredible! I cannot see anything that can come even close to >> Mathematica >> for students who actually want to DO some mathematics or learn some >> technical subject matter. I'm thinking of actually organizing >> calculations, >> derivations or proofs, trying examples and alternative methods, and >> describing and explaining the methods. Isn't this what 'STEM' education >> should be all about? >> A year or so ago, on sci.math.symbolic a high school student stated >> that he >> was interesting in studying pure mathematics and wanted to know what >> computer language he should learn to further that goal. There were >> hundreds >> of responses with some threads going to great depth. As far as I could >> find, >> there was not a single mention of Mathematica and only one reference to >> using a CAS. Everything else concerned the merits of C++, Perl, List, >> Fortran etc. To me, this again was incredible. I am absolutely as saddened and dismayed by the above observations as I > believe David Park is -- but unfortunately also not much surprised by > them. I would especially endorse every word of the last three sentences of the > first paragraph above. I have long believed in, and personally and > extensively used Mathematica for exactly those purposes, in research, > teaching, educating, learning, publishing, lecturing, and personal > avocations, ever since the day I got my hands on Mathematica version 1 > (and, in fact, I pursued all those objectives using RealBASIC, Igor, > Excel, and other even more primitive tools well before that). On the other hand, I am also (equally sadly) not at all surprised by the > above observations. The bizarre and idiosyncratic and dysfunctional way > that Mathematica has evolved, in its structure and syntax, in its user > interface, in its pricing, and in its documentation, among other > factors, all contribute significantly to the dismal situation summarized > by David above. I don't understand how things can have gone so wrong > for Mathematica -- but they have. Ten years ago I was writing enthusiastic memos to my Deans and Vice > Provosts for Research, and my university's IT people, urging them to > invest university funds in Mathematica licenses and bookstore discounts; > to sponsor (or pay for) free training courses for students, faculty and > staff through the university; to promote the use of Mathematica > throughout every even mildly technical area of the university; and to > make it a kind of semi-official university standard for all areas of > research and teaching (as they had, at that time, semi-officially done > for the Mac platform). To be blunt, if a proposal like that were actually to be taken under > consideration by my university today -- not that there's any chance that > this could actually happen at this point -- I would actively oppose it, > or at least recommend that a major effort be undertaken to explore every > other possible substitute (and there are some out there) to meet the > same needs. >> This all leads me to believe that Mathematica is poorly positioned in >> the >> marketplace. At the present time, static printed documents are the >> dominant >> method of publication and communication in the technical world. >> Mathematica >> is primarily an ancillary tool to produce calculated results and >> starting >> graphics for these static documents. I believe that static documents >> are a >> dying technology and they will sooner or later be replaced by active and >> dynamic Mathematica notebooks - or their equivalent. Why? Because they >> are >> orders of magnitude superior for presenting and explaining mathematical >> and >> technical ideas. WRI seems to have this concept in mind but one feels >> that >> they don't take it with full seriousness, or realize the impediments in >> the >> way. Unfortunately here we have to part company. Your second sentence above > makes it seem as if you've never heard of PowerPoint -- which is very > possibly the dominant method of publication and communication in the > technical world today -- along with QuickTime, HTML, Flash, Word, TeX, > LaTeX, the entire Adobe product line, and the ever expanding set of > online and multimedia journals and innumerable personal and > institutional web sites, all of which, working together quite > constructively in most cases, are nearly obliterating static printed > documents, in the technical world and everywhere else. Mathematica is (or at least in earlier versions was, from the beginning) > absolutely an insanely great ancillary tool to produce calculated > results and starting graphics (including all kinds of animations) for > all the objectives we've both agreed upon. Adding a certain level of > interactivity to these graphics in recent versions is quite wonderful > also. But the idea that these results, along with all the underlying analysis, > will then also have to be delivered (presented, displayed, put on > screen) (and also organized, maintained, cataloged, re-purposed, > modified, edited, annotated), using (and _only_ using) Mathematica and > Mathematica notebooks, is just, in my considered opinion, an absolute > non-starter -- and a _highly_ destructive concept as well, in its impact > on the usability of Mathematica for what it's really good at (and where > it in fact really has very limited competition). I'm afraid that I'm strongly enough convinced of this point that > examining this idea further is just of no interest to me. We should be > focusing on what's needed to keep Mathematica highly _usable_ for the > particular things it's really near uniquely _useful_ for, not trying to > make it a monster tool for everything in the world. > -- DrMajorBob@bigfoot.com === Subject: Re: When a string does not match itself > This is a maybe a trivial question, but I have not found the explanation = in > help (I am using Mathematica 7.0.0): Normally a string matches itself: In[270]:= StringMatchQ[monkey, monkey] Out[270]= True But In[271]:= StringMatchQ[*, *] Out[271]= False Why? Yes, this is a bit tricky. In a pattern, * stands for any sequence of characters. So we need a way to construct a pattern that only matches the * character. This is done by escaping, i.e. preceding the * by a backslash. To make things more complicated, we also need to escape the backslash to include it into a Mathematica string. So the patter * is just an escaped *, i.e. it matches a *, and * only. To match *, we need to use *. In[3]:= StringMatchQ[*, *] Out[3]= True Escaping can get ugly. > Compare also to In[4]:= StringCases[*, *] Out[4]= {*} In[267]:= StringPosition[*, *] Out[267]= {{1, 2}} > Ingolf Dahl Sweden ingolf.d...@telia.com === Subject: Re: When a string does not match itself You have to escape both the and the * as in StringMatchQ[*, *] since both are special characters.... > This is a maybe a trivial question, but I have not found the explanation = in > help (I am using Mathematica 7.0.0): Normally a string matches itself: In[270]:= StringMatchQ[monkey, monkey] Out[270]= True But In[271]:= StringMatchQ[*, *] Out[271]= False Why? Compare also to In[4]:= StringCases[*, *] Out[4]= {*} In[267]:= StringPosition[*, *] Out[267]= {{1, 2}} > Ingolf Dahl Sweden ingolf.d...@telia.com === Subject: Re: When a string does not match itself StringMatchQ[*, Verbatim[*]] === Subject: Re: When a string does not match itself > In[271]:= StringMatchQ[*, *] ref/StringMatchQ says: StringMatchQ allows both ordinary StringExpression string patterns, as well as abbreviated string patterns containing the following metacharacters: * zero or more characters @ one or more characters, excluding uppercase letters *, etc. literal *, etc. === Subject: Re: When a string does not match itself > This is a maybe a trivial question, but I have not found the explanation = in > help (I am using Mathematica 7.0.0): Normally a string matches itself: In[270]:= StringMatchQ[monkey, monkey] Out[270]= True But In[271]:= StringMatchQ[*, *] Out[271]= False Why? Compare also to In[4]:= StringCases[*, *] Out[4]= {*} In[267]:= StringPosition[*, *] Out[267]= {{1, 2}} > Ingolf Dahl Sweden ingolf.d...@telia.com The second argument to StringMatchQ[] is a pattern and the first argument is a string, so if you wanted to you could StringMatchQ[*, *] and you would get a value of True back. Look over the documentation of StringMatchQ[] and String Patterns guide and tutorial for more info. -Bob === Subject: Re: When a string does not match itself has a special meaning in strings. n is new line, t is tab, and otherwise is a literal directive Print[This is ttab and newlinenliteral quote and literal backslash or nat the end of a line] This is tab and newline literal quote and literal backslash or at the end of a line And * is a wildcard in strings StringMatchQ[#, mon*ey] & /@ {money, monkey, monk's key} {True,True,True} Except when it is made literal StringMatchQ[#, mon*ey] & /@ {money, monkey, monk's key} {False,False,False} StringMatchQ[*, *] False I suspect that because of the multiple special characters and how and when that they are internally evaluated, that this is comparing different expressions than what you intended. StringMatchQ[, ] True StringMatchQ[*, *] True StringMatchQ[, ] True Bob Hanlon This is a maybe a trivial question, but I have not found the explanation in help (I am using Mathematica 7.0.0): Normally a string matches itself: In[270]:= StringMatchQ[monkey, monkey] Out[270]= True But In[271]:= StringMatchQ[*, *] Out[271]= False Why? Compare also to In[4]:= StringCases[*, *] Out[4]= {*} In[267]:= StringPosition[*, *] Out[267]= {{1, 2}} Ingolf Dahl Sweden ingolf.dahl@telia.com === Subject: Re: Do What I Mean - a suggestion for a bit of a ramble: The purpose of language is communication [ I think ]. There are so many modes of communication; music, mathematics, spoken/written word, etc. Within those modes there are so many levels of sophistication; Chopsticks to Brandenburg Concerto, Addition to Incompleteness Theory, Where's my coffee ? to Slouching towards Bethlehem. Language has to accommodate precision, otherwise you won't know what the other person means. Overly precise rules of language stifle creativity. But too-slack rules generate imprecision and communication breakdown. I've never tried writing poetry, but I know if I did - fortran would not be my language of choice. Similarly, if I was trying to write code for Fourier transforms - Gaelic would not be at the top of my list. In any case, the great thing about language is it can generate new ideas. My first point: But you need to be fluent in the language before that can happen. That fluency comes with practise and learning the precise rules of the language so well that they are second nature. That's when the ideas start coming. My second point: I think Mathematica is great language. I'm only an engineer, but i'm told by experts that languages like Mathematica can be used for theorum-proving as well as excelling at number-crunching. The best languages [ in any mode ] can do both low and high levels of sophistication. Peter 2009/3/7 David Park international phone calls' or 'driving a car' (say). There the task is > fairly routine and almost everybody is expected to be able to do it. With > engineering, every task is new. Mathematica is not like an HP or TI > calculator, or an older slide rule. It is, by its very nature far more > complex to learn because we are asking it to do far more. The model is more > like learning to be good at expository writing, or good at mathematics > itself, or learning to be a good poet. There is no royal road. It is not > just button-pushing. Mathematica is both very powerful and evolving. In my opinion we are still > learning how to use it. I don't think anyone knows how to fully exploit it > yet - not even the people at WRI. So it's an adventure, and a rather > exciting one. Join in. > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ I do not think it is even a good > idea to attempt to make Mathematica accessible to users with > minimal computer/mathematics experience/knowledge assuming this > is even possible. I guess we'll just have to disagree -- vehemently! -- on this one (and > also with great sadness on my part, if this should represent Wolfram's > anything like Wolfram's actual views or objectives). By sheer coincidence, a few minutes after seeing the above post I read > the following post in another newsgroup (it's a big long, but just skim > down to the end): POST FROM COMP.DCOM.TELECOM, FEB 2009: This thread reminded me of one of my favorite > published papers (because of its sheer readability) and I could not > resist bringing it to the attention of others, old and dated though it > may be. Scrounge through the stacks of your local engineering > library: Test yourself: how much do you know about international > communications? [International numbering systems] Robrock, A. (Italtel, Milan) > IEEE Communications Magazine, December 1989 > Volume: 27, Issue: 12 Abstract We like to think of international telephone communications as > `transparent', the successful outcome of 100 years of technical > progress and standards setting, but the author shows us that it is > not. The user still has to be something of an expert to understand how > to make international calls, and there are chaotically differing > numbering systems for telephony, telex, and electronic mail. We should > be reminded that usability of services, not just their usefulness, is > a critical component of communications. Simplicity, consistency, and > rationality of service features and the `human interface' that allows > users to invoke them should be a high priority for communications > engineers as they work toward the integrated services networks of the > future Besides the chaotically differing phraseology, it's the final two > sentences that catch my eye. Should Mathematica interface designers > maybe be reminded that it's the _usability_ of software, not just its _usefulness_, > that's a critical component of software interface design and even better Simplicity, consistency, and rationality of software features > ** and the `human interface' that allows users to invoke them ** > should be a high priority for software designers as they work toward > the integrated services networks -- sorry, integrated software > packages -- of the future. Interesting -- _integrated_ software packages? -- don't I recall that > that's one of the big selling points for Mathematica? (although one that > I personally believe can really only be effectively achieved -- for > software that is, not necessarily for networks -- using a much more > modular approach. > There are a great many things in mathematics that work in > specialized cases. For example, a user with little experience in > mathematics likely would expect Sqrt[x^2] to simplify to x. But > that transformation is only valid when x is real and positive. > If Mathematica were to automatically do this simplification (or > many others of a similar nature) it would not be an adequate > tool for me or many other users since it would be creating > erroneous output. Worse, even for those users where this > happened to be the correct output, the issue gets hidden and > they would learn to trust Mathematica only to lose trust when > things were more complex. The point is mathematics is complex. A tool designed to > implement mathematics can hardly be less complex. Attempts to > reduce the complexity invariably mean some aspects (typically > special cases) of the mathematics are being ignored or hidden. > Ignoring or hiding such special cases limits the usefulness of > Mathematica. Don't really disagree on the facts here -- just the operational > conclusions: 1) Are you really saying that the whole series of superb hp calculators > out of which I got so many useful scientific and engineering results in > earlier years -- and which, incidentally and painlessly, also gave me at > least an introduction to the concepts of Reverse Polish notation and > stacks as an aside -- should not have had a Sqrt[x] key? [And incidentally: Would you not like to see Mathematica be as widely > used, and useful, as were those superb tools?] 2) I'm an engineer and physicist; other potential Mathematica users > might be from innumerable other practical fields (econ, stat, business, > etc etc). We know some math; varying amounts for different fields and > levels within fields. We know there are complexities in math that we > may not understand. But we also have the protection that when we > calculate results using some, we can (and do!) look at them and apply > physically reasonable criteria (or realistic results in other > fields) as part of our criteria. We don't denigrate rigor, or fail to > take care about the possibility of unanticipated special cases. But we > have _other_ tools that mathematicians don't have, to help us cope with > the possibility of those. -- Peter Lindsay === Subject: Re: Version 7.0.1 bug with initial Palette positions I always find that a nice cup of tea helps in these situations.Peter 2009/3/7 Bob F some of the palettes correctly when starting up. I have a dual-screen > Mac setup and I put all my palettes on the left screen, and Notebooks > on the right primary screen so I have visibility of my notebook > windows at all times and not obscurred by the palettes that don't like > to cohabitate with normal windows (something I still find to be a > royal pain -- why cant they be like any other windows - yes I know you > can change their floating attributes, but the whole idea of not > behaving like any other window is so contrary IMO, you can't resize > them, you cant minimize them, etc). So in this case the WindowMargins parameter in the init.m setup file > had a negative left and top number and Auto for right and bottom. But, > for some strange reason only the ClassroomAssistant palette was > incorrectly placed on the left screen and before with 7.0 and 6.0 and > 5.2 things were fine (all the other 4 or 5 palettes came up in the > expected position which is even more bizarre actually - I can only > guess that the code that does the placement of the palettes is > individually isolated to each and every palette and not a general > purpose routine that all share, otherwise all would exhibit the > problem cause they are all on the left screen). The most bizarre > problem is that sometimes one of the other palettes would do this and > not the Classroom assistant, but not very often, and certainly not > repeatable as far as I can tell. The really ugly thing is that the ClassroomAssistant palette was > positioned so that the title bar was underneath the main Apple/ > Mathematica menu along the top of the primary screen and no matter > what I did, I could not move it. It's title bar was underneath and > totally not reachable. What I ended up doing was using the OptionInspector to change the > WindowMargins parameters so that it was lower on the primary screen so > that I could drag it where I wanted it on the left screen, or just > change it to what it should have been to begin with. But when exiting > Mathematica and then restarting, the same thing occurs all over again. > WHAT A PAIN!!!! And on top of that the init.m file is rewritten on the > fly when Mathematica starts up to change what it considers as an > invalid margin setting and changes them to what it thinks are valid, > but no message ever indicates that it just mucked with the settings in > the init.m on it's own prerogative for this ClassroomAssistant > palette, so you are forced to move it to where you really want to > every time you start up Mathematica as I described with the Option > Inspector and I spend a minute or two every time Mathematica starts up > to fix a problem it caused! I can't believe this simple user interface issue escaped the QA > process, and the beta testers. The only thing I can guess is that a > two screen setup is not common. When I called Wolfram to see about > this, the person in support was able to locate a dual-screen Mac and > verify that the problem occurs there also. So they have the ability to > test dual screen setups, but guess they either didn't do at all, or > not very extensively. Very disappointed in my first excursion into > 7.0.1 land -- but I will get over it. Now I will only have to wait 6 > months or maybe a year and the fix will be available. And I pay money > for this??? In the meantime, I know how to get around the problem - > thank goodness for the option inspector. Why oh why oh why do people put up with this kind of software > problems!! Wolfram get your act together and come up with some way to > get patches to people on a timely basis for when you create bugs and > problems and don't catch trivial bugs you create in releasing new > versions, let alone the hard ones. This is not the first time this has > happened, far from it. I am sure everyone on this list has stories > that would cause us all to shake our heads in familiar disappointment > and belief. If people feel the same, please let your Wolfram sales and > support contacts know how disappointing this kind of problem is and > encourage them to come up with a solution. That Mathematica is such a powerful tool is it's saving grace, but > Wolfram -- wake up and smell the coffee! Remember a company called > Quark, who was so world famous about not giving a rat's behind about > customers problems -- now Adobe has virtually killed them off because > better job of QA and do a better job of coming up with a way to solve > bugs, rather than wait for months and years and the next release. > THERE HAS TO BE A BETTER WAY. Solve it and you will have even more > loyal and fanatic customers. Of course, I realize that the problem is not rampant, but a relatively > rare, and certainly Wolfram is not the only one suffering from this > problem. It only becomes such a frustrating issue when it affects > things in what I am doing or try to do, and I say to myself that this > ought to work, that I get so disappointed. And I am sure that we all > have shared in this frustrating experience before. But the fact that it happens again and again and again is the part > that completely baffles me and makes me think how could they shoot me > in the foot again and think I wouldn't say ENOUGH IS ENOUGH!!!! I am > so disappointed with bad, careless, and sloppy programming - why after > about 60 or 70 years of the science of programming and all the > advancements of computer hardware, do things like this continue to > occur? It is not just Wolfram, but rampant in the entire field of > software. The complexity of code today and the difficulty in solving > trivial as well as difficult problems is hardly any better today than > decades ago. Since the overall complexity of software solutions is so > many orders of magnitude greater, the only saving grace is that the > hardware is so much faster as well. Otherwise we would be in a truly > dismal position. But I am sure there is a solution for this problem, and Wolfram does > have some of the most talented and resourceful and intelligent people > in the world. My wish is that they solve some really fundamental > problems so that customers don't have to continually have to go thru > this frustration on every release and every bug, but instead remember > and chant to themselves Just wait for the next release - the problem will be solved, or at > least moved to some other, hopefully unimportant, spot. In the meantime, just don't do it that way, no matter how much you > think that it should work or not work that way. Adapt and be happy, as > the alternative is rather miserable. -Bob -- Peter Lindsay === Subject: Maximum in a list Suppose a list mylist={{1,2},{3,4},{8,3}} I would like to extract the element {i,j} of mylist for which j is max (here, it is the second one {3,4}). Somebody could help me, please? Pacotomi === Subject: Re: Bug in Pattern Matching with Condition? Condition[_,_] as a pattern will match nothing since its test expression is _ aka Blank[] and is not equal to True. === Subject: Re: Style for function calls? I agree with some of the above statements. 1. I never use postfix in any routines. I usually only for testing and debugging code in notebook format. As said above, its useful for doing lazy transformation and works well under the analog of pipes. 2. I never use infix beyond the built in uses. 3. I prefer to use prefix for avoiding trails of end-brackets, however I never prefix to a single value. ie. f[g[h[i]]]] -> f@g@h[i] 4. I try to avoid the use of explicit parentheses. ie. f /@ ( .... ), to me, looks better as: Map[f, ...] 5. Lastly, I am free to break any rule and restructure my code if order of operation is not obvious. However, this rarely happens if you stick to the above or similar criterion. === Subject: Careless use of Scaled leads to hard crash in V7 I just saw a crash in Mathematica V 7 on Mac OS X Tiger and Leopard. The program (reproducibly) quits unexpectedly after doing the following: 1) Evaluate Graphics3D[{Arrowheads[Scaled[.05]], Arrow[Tube[{{0, 0, 0}, {1, 0, 0}}, Scaled[.05]]]}] 2) Use arrow keys to go back to previous input cell and try to delete the occurrence of Scaled[.05] in Arrowheads, replacing it with .1 or some other value. You may not even get this far, the crash sometimes happens earlier. 3) Repeat steps 1 and 2 if necessary. There briefly is an Internal Self Test Error message before the crash wipes Mathematica off the screen. This is not exactly the most pleasant way of learning that Scaled lengths can't be used inside Arrowhead. I wonder if this crash also happens on other platforms. Jens === Subject: Re: A newbee to Mathematica Mathematica has two sets of graph functions, one set natively built-in in 7 and one delivered by the Combinatorica package. The latter one is an external development and its graph structures differ from the internal ones. Mathematica can use the Combinatorica graph structurs, but not vice versa. is from Combinatorica and GraphPlot3D is a built-in function. If it were the other way around you would need to convert the graph. The built-in functions can handle adjaceny matrices, so you wouldn't need Combinatorica if the only thing you want is visualizing a graph. I believe that the adjacency matrices Mathematica uses are binary and you are using edge weights. However, the problem you have follows from typos. Instead of: EdgeLabeling -> True] GraphPlot3D[g] you probably intended to write: GraphPlot3D[g, VertexLabeling -> True, EdgeLabeling -> True] This works, but there are issues as well. Syntax coloring shows that EdgeLabeling is not an option of GraphPlot3D. It is an option of GraphPlot. However, since you haven't given any edge labels this option doesn't make sense. > Hi I have just started using mathematica,and therefore have a very silly = question that needs an answer. > I am trying to run this: > Needs[GraphUtilities`] > Needs[Combinatorica`] > am = {{1, 0, 1, 2, 0, 1, 2}, {0, 0, 0, 0, 1, 1, 1}, {1, 0, 0, 1, 1, 1, > 1}, {0, 3, 1, 4, 1, 0, 1}, {0, 1, 1, 1, 0, 1, 0}, {1, 1, 1, 0,= 1, > 0, 0}, {1, 1, 5, 1, 0, 0, 0}}; MatrixForm[am] > EdgeLabeling -> True] > GraphPlot3D[g] > I am getting this error message: > GraphPlot3D::grph:Graph:<11,7,Undirected> is not a valid graph. BASICALLY what I want to do is to generate a 3d graph from a given adjace= ncy matrix,with the elements of the matrix showing the weights of each edge= > === Subject: Re: A newbee to Mathematica am = {{1, 0, 1, 2, 0, 1, 2}, {0, 0, 0, 0, 1, 1, 1}, {1, 0, 0, 1, 1, 1, 1}, {0, 3, 1, 4, 1, 0, 1}, {0, 1, 1, 1, 0, 1, 0}, {1, 1, 1, 0, 1, 0, 0}, {1, 1, 5, 1, 0, 0, 0}}; GraphPlot3D[am] ?? Jens > Hi I have just started using mathematica,and therefore have a very silly question that needs an answer. > I am trying to run this: > Needs[GraphUtilities`] > Needs[Combinatorica`] > am = {{1, 0, 1, 2, 0, 1, 2}, {0, 0, 0, 0, 1, 1, 1}, {1, 0, 0, 1, 1, 1, > 1}, {0, 3, 1, 4, 1, 0, 1}, {0, 1, 1, 1, 0, 1, 0}, {1, 1, 1, 0, 1, > 0, 0}, {1, 1, 5, 1, 0, 0, 0}}; MatrixForm[am] > EdgeLabeling -> True] > GraphPlot3D[g] > I am getting this error message: > GraphPlot3D::grph:Graph:<11,7,Undirected> is not a valid graph. > === Subject: Re: A newbee to Mathematica I don't understand the line of code that begins: > Hi I have just started using mathematica,and therefore have a very silly question that needs an answer. > I am trying to run this: > Needs[GraphUtilities`] > Needs[Combinatorica`] > am = {{1, 0, 1, 2, 0, 1, 2}, {0, 0, 0, 0, 1, 1, 1}, {1, 0, 0, 1, 1, 1, > 1}, {0, 3, 1, 4, 1, 0, 1}, {0, 1, 1, 1, 0, 1, 0}, {1, 1, 1, 0, 1, > 0, 0}, {1, 1, 5, 1, 0, 0, 0}}; MatrixForm[am] > EdgeLabeling -> True] > GraphPlot3D[g] > I am getting this error message: > GraphPlot3D::grph:Graph:<11,7,Undirected> is not a valid graph. > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: String substitution system Possibly this does the job? Clear[cycle, twoStep, legalize, fixedPt, minimums] cycle[s_String] := Table[StringDrop[s, n] <> StringTake[s, n], {n, 1, StringLength@s}] twoStep[s_String] := Union@Flatten[legalize /@ cycle@s] legal = {CC -> C, DD -> D, CA -> C, AC -> C, DB -> D, BD -> D, CDC -> C, DCD -> D, CBC -> C, DAD -> D, ABC -> DC, CBA -> CD, BAD -> CD, DAB -> DC, BAB -> ABA} /. Rule[x_Symbol, y_Symbol] :> Rule[ToString@x, ToString@y]; legalize[s_String] := Union[{s}, StringReplaceList[s, legal]] fixedPt[s_List] := FixedPoint[Union@Flatten[twoStep /@ #] &, s] fixedPt[s_String] := fixedPt@{s} minimums[s_String] := Module[{f = fixedPt@s, lengths}, lengths = StringLength /@ f; Pick[f, lengths, Min@lengths] ] minimums@DAB {AD, CD, DA, DC} minimums@CBBA {BBC, BCB, CBB} Answers don't appear to be unique, as you can see. Bobby > Another question that is probably too trivial for you :-) I want to generate all words A,B,C,D,AA,AB,...,DD,AAA,... > until, eh, 6-7 letters should suffice, and put them in a list. > The following string replacements are legal: > CC->C > DD->D > CA->C > AC->C > DB->D > BD->D > CDC->C > DCD->D > CBC->C > DAD->D > ABC->DC > CBA->CD > BAD->CD > DAB->DC > BAB->ABA > Note that everything but the last one shortens the word > and thus strings containing these substrings may be simply > dropped if you generate the words ordered by length, but the last > one is a bit tricky - BABBC=ABABC=AABAC=AABC and > ABAAD=BABAD=BBABD=BBAD so you may have to use it both > ways and repeatedly. > Now I'm an old FORTRAN chap and being nearly 50 years old, > I probably won't learn the Kamasutra of recursive function > calls anymore :-) But surely you'll have a three-liner > for this problem? > P.S. Actually the strings are cyclic too - CBBA=ACBB=CBB. > P.P.S. Remember, poor University, version 5.2 ;-) -- DrMajorBob@bigfoot.com === Subject: Re: String substitution system vAlphabet = {A, B, C, D}; vWords = Map[ StringJoin, Join @@ Table[Tuples[vAlphabet, i], {i, 7}] ]; vRules = {CC -> C, DD -> D, CA -> C, AC -> C, DB -> D, BD -> D, CDC -> C, DCD -> D, CBC -> C, DAD -> D, ABC -> DC, CBA -> CD, BAD -> CD, DAB -> DC, BAB -> ABA}; FixedPoint[StringReplace[#, vRules] &, vWords] === Subject: Re: Forgets Variables? I can't get the first statement to execute (in the time I'm willing to wait). If you gave us the values of maxX, eqTime, v, lifetime27SA, et cetera, we'd waste a lot less time guessing what your problem might be. If you want help, ALWAYS start us off where you are. Don't make us flounder around where you've already been. Because, of course, why should we? That said, I'd start by simplifying until the code is understandable, at which point the error will reveal itself. For instance, this: If[v*(tsum - lifetime35S - eqTime) < 4000, v*(tsum - lifetime35S - eqTime), 4000] is equivalent to the simpler (and faster) Min[v*(tsum - lifetime35S - eqTime), 4000] Similarly, this expression: If[v*(tsum - eqTime) < 4000, Max[v*(tsum - eqTime), 0], 4000] is equivalent to Max[0, Min[v*(tsum - eqTime), 4000]] Next, it's easy to see that If[v*(tsum2 - eqTime) < 4000, Sum[Max[v*(tsum - eqTime), 0], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}], Sum[Max[0, Min[v*(tsum - eqTime), 4000]], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}]] is equivalent to Clear[q] q[ts_] := v*(ts - eqTime); If[q@tsum2 < 4000, Sum[Max[q@tsum, 0], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}], Sum[Max[0, Min[q@tsum, 4000]], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}]] and that's equivalent to (since the Sums have the same limits): Clear[q] q[ts_] := v*(ts - eqTime); Sum[If[q@tsum2 < 4000, Max[q@tsum, 0], Max[0, Min[q@tsum, 4000]]], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}] Similarly, the first If statement: If[v*(tsum2 - lifetime35S - eqTime) < 4000, Sum[Max[v*(tsum - lifetime35S - eqTime), 0], {tsum, tsum2 - lifetime27SA + 1, tsum2}], Sum[Min[v*(tsum - lifetime35S - eqTime), 4000], {tsum, tsum2 - lifetime27SA + 1, tsum2}]] is equivalent to Clear[q] q[ts_] := v*(ts - lifetime35S - eqTime); Sum[If[q@tsum2 < 4000, Max[q@tsum, 0], Min[q@tsum, 4000]], {tsum, tsum2 - lifetime27SA + 1, tsum2}] Combining both tricks into one reduces the original expression to: Clear[q] q[life_][ts_] := v (ts - life - eqTime) callNormValue = 60/maxX Sum[ Sum[If[q[lifetime35S]@tsum2 < 4000, Max[q[lifetime35S]@tsum, 0], Min[q[lifetime35S]@tsum, 4000]], {tsum, tsum2 - lifetime27SA + 1, tsum2}]*(1 - P) + Sum[If[q[0]@tsum2 < 4000, Max[q[0]@tsum, 0], Max[0, Min[q[0]@tsum, 4000]]], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}]*P, {tsum2, 60, t2, 60}]; That still won't evaluate without values for all the parameters, but you're the only one that knows those, or even knows what ranges they might lie in. One trick you MIGHT pull, however, is this: Clear[q] q[life_][ts_] := v (ts - life - eqTime) callNormValue = 60/maxX sum[ sum[If[q[lifetime35S]@tsum2 < 4000, Max[q[lifetime35S]@tsum, 0], Min[q[lifetime35S]@tsum, 4000]], {tsum, tsum2 - lifetime27SA + 1, tsum2}]*(1 - P) + sum[If[q[0]@tsum2 < 4000, Max[q[0]@tsum, 0], Max[0, Min[q[0]@tsum, 4000]]], {tsum, tsum2 - lifetime27SANTC + 1, tsum2}]*P, {tsum2, 60, t2, 60}]; (Now the statement executes.) callNormValue /. {lifetime35S -> 17, P -> 0.7, t2 -> maxX, sum -> Sum} (The other parameters still need values, but those could be added to the rule list.) Bobby > Hi there, i have the following procedure: callNormValue = (Sum[ > If[v*(tsum2 - lifetime35S - eqTime) < 4000, > Sum[Max[v*(tsum - lifetime35S - eqTime), 0], {tsum, > tsum2 - lifetime27SA + 1, tsum2, 1}], > Sum[If[v*(tsum - lifetime35S - eqTime) < 4000, > v*(tsum - lifetime35S - eqTime), 4000], {tsum, > tsum2 - lifetime27SA + 1, tsum2, 1}]]*(1 - P) + > If[v*(tsum2 - eqTime) < 4000, > Sum[Max[v*(tsum - eqTime), 0], {tsum, > tsum2 - lifetime27SANTC + 1, tsum2, 1}], > Sum[If[v*(tsum - eqTime) < 4000, Max[v*(tsum - eqTime), 0], > 4000], {tsum, tsum2 - lifetime27SANTC + 1, tsum2, 1}]]* > P, {tsum2, 60, t2, 60}])/(maxX/60); i call it with: > callNormValue /. {lifetime35S -> 17, P -> 0.7, t2 -> maxX} it gives me a proper result, but as soon i change t2 to maxX in the > first expression (where i do the sums) it doesn't evaluate the the > procedure anymore (maxX has a global value already set). I have > actually quite a lot of trouble to hand over values to this > procedure.. and i have no idea why it doesn't work. (for except lifetime35S,P and t2 all the variables have a set value) thank you, Ktota -- DrMajorBob@bigfoot.com === Subject: Re: Forgets Variables? When t2 is defined, Mathematica is probably evaluating (and expanding) callNormValue. What you need to do is preserve the form of callNormValue (aka prevent evaluation) until you have all known values. Either, 1. Wrap callNormValue in a Hold statement. Then perform the replacement, and call ReleaseHold. held = Hold[ 3 + 9x ]; ReleaseHold[ held /. {x->2} ] 2. Make callNormValue a function. === Subject: Re: typsetting bug still present in Mathematica 7.01 On Mar 7, 9:41 am, Jens-Peer Kuska and you are sure that this is a bug ? [DifferentialD] is an > operator for the total differential and has a build-in meaning > while [CapitalDifferentialD] has no build in meaning and AFIK > the only use of this character is in a Feynman path integral > to denote differential like integration variable over the path. > Since Mathematica can't do path integrals (jet) it is an ordianry > letter like [Alpha], ... and can combined with other unicode > letters. > Actually it's not just a simple letter, it's an operator without any built-in meaning. Note that the FullForm of the output is CapitalDifferentialD[x] I'd personally expect [DifferentialD] to behave the same as [CapitalDifferentialD] when formatted in StandardForm/TraditionalForm. === Subject: Re: Wolfram/Alpha As you might expect, any who are in the know, and who tell, would have to kill or be killed. Suffice it to say that it is very interesting and will grow into something quite overarching. --David (who wants to remain alive) http://scientificarts.com/worklife > I just read the latest intriguing blog entry on the Wolfram site. > It reports the May 09 opening of the the Wolfram/Alpha site: a sort of Does anybody knows a bit more (and is willing to speak :-) ) ? What I find also amazing is that this project must have engaged a > considerable amount of WRI resources, financial time and human, yet > they managed to keep all this very quiet. Exciting isn't it? === Subject: Re: Mathematica 7.0.1.0 and some General Comments Prof. Siegman, I seriously doubt that you have ever seen a significant topic presented in a completely active and dynamic Mathematica notebook. If you had, I don't see how you could possibly confuse it with the alternatives you list below. A comparison with PowerPoint is especially outlandish! If you are going to compare two things then it is only fair to look at both of them. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Unfortunately here we have to part company. Your second sentence above makes it seem as if you've never heard of PowerPoint -- which is very possibly the dominant method of publication and communication in the technical world today -- along with QuickTime, HTML, Flash, Word, TeX, LaTeX, the entire Adobe product line, and the ever expanding set of online and multimedia journals and innumerable personal and institutional web sites, all of which, working together quite constructively in most cases, are nearly obliterating static printed documents, in the technical world and everywhere else. === Subject: Re: Mathematica 7.0.1.0 and some General Comments > There were hundreds > of responses with some threads going to great depth. As far as I could = find, > there was not a single mention of Mathematica and only one reference to > using a CAS. Everything else concerned the merits of C++, Perl, List, > Fortran etc. To me, this again was incredible. It seems to me that the alternatives listed are all Open and Free. > Mathematica has very favorable student licences, but what happen when > the student leave school/uni? The price, albeit justifiable, is very > high for a yet-to-be-employed graduate. It may be better to learn basic > tools one can afford later on. Except that none of the tools above were meant for the same purpose as CASs/Mathematica. > IMHO. Humbleness and asserting one's unsolicited opinion are pretty much contradictory. === Subject: Re: Mathematica 7.0.1.0 and some General Comments I don't Mathematica could, or should, become the de facto standard for mathematics communication. Its a bit like insisting that all written documents from now on must be done in MS Word. However I do think that the Mathematica Player is an excellent tool and is actually quite a generous gift from Wolfram Research to the mathematical community.Peter 2009/3/7 ADL thing WRI developers could do against Mathematica itself was (and is) > to hide the bug list and the list of fixes. > This overall gives the feeling of a substantially unreliable system. Generally speaking, I am fond of the basic Mathematica structure, I > use it every day to solve practical issues in my job and also develop > some rather complex programs, but admittedly would never fully rely on > a piece of software in which new bugs are introduced all the time, > also in appearently consolidated areas, and for which fixes are never > documented and established once for all. On the contrary, WRI has undertaken the introduction of thousands new > features, many of which do not appear to work exactly as expected, are > ofted superficially documented, are difficult to print and study in > detail and are sometines stubbornly affected by some suboptimal > design, which makes their application counterintuitive or error prone. > Most Mathematica books are full of astonishing one-liners (perhaps > 1000 characters long), while a lot of people are still stuck with > FindRoot, Eigenvectors, FourierTransform, etc etc. To make a simple > plot, it is often better (sometimes recommended) to quit Mathematica > and use a general-purpose spreadsheet. It is surely a strategy, it might support some cash flow, but I do not > believe it is a winning strategy. About one / two years ago, WRI proudly declared that they had reached > the millionth build of Mathematica. Now, there are surely many more. > Why they did not realize that this very bad advertisement for a sw > with 6 official versions (at that time) and strong indication of a > very bad design? This is an explicit declaration that Mathematica is > not amenable to incremental development, that is the only way towards > reliability. I do not understand why and I am sad about it, but after reading this > Group for about one year and having used Mathematica since version 3, > to me WRI appears to be strongly determined NOT to become a winner in > this arena. ADL > ... David Park djmp...@comcast.net http://home.comcast.net/~djmpark/ > -- Peter Lindsay === Subject: Re: Mathematica 7.0.1.0 and some General Comments One thing that Mathematica users could do is to set up a Wiki where they maintain their own list of known Mathematica bugs. Of course, this is really what WRI should do, not us. But, here are a few reasons why it might be an advantage for us to do so: * In this way Mathematica users would declare their position regarding the way Mathematica is being developed. * Individuals and organizations that are considering buying Mathematica would see that it actually contains lots of bugs and those bugs don't get fixed. That would discourage them from buying Mathematica and make WRI to rethink their strategy. * Mathematica users could check if their bugs are already known without wasting their time to submit the bug reports. * It would be easier to monitor which bugs get fixed and which don't. ~Maris Ozols~ === Subject: Re: Mathematica 7.0.1.0 and some General Comments On the other hand, I am also (equally sadly) not at all surprised by the > above observations. The bizarre and idiosyncratic and dysfunctional way > that Mathematica has evolved, in its structure and syntax, in its user > interface, You keep saying things like this, and I can only continue to disagree. The structure and syntax of Mathematica is completely consistent, and is not difficult to learn for anyone who is willing to put in a little time and effort. The new Classroom Assistant and Basic Math Input palettes make learning the syntax even easier. When we switched over to 7.0 this semester, I had some experienced Mathematica users in my classes, and some newbies. The newbies relied heavily on the new palettes when they were getting started, and by doing so avoided most of the syntax errors that newbies usually made in past semesters. They quickly caught up with their classmates in using Mathematica effectively, and most of the students use the palettes lightly; they find it quicker and easier -- yes, *easier*, because they understand the syntax -- to type in most Mathematica commands themselves. > in its pricing, and in its documentation, among other > factors, all contribute significantly to the dismal situation summarized > by David above. I don't understand how things can have gone so wrong > for Mathematica -- but they have. Ten years ago I was writing enthusiastic memos to my Deans and Vice > Provosts for Research, and my university's IT people, urging them to > invest university funds in Mathematica licenses and bookstore discounts; > to sponsor (or pay for) free training courses for students, faculty and > staff through the university; to promote the use of Mathematica > throughout every even mildly technical area of the university; and to > make it a kind of semi-official university standard for all areas of > research and teaching (as they had, at that time, semi-officially done > for the Mac platform). To be blunt, if a proposal like that were actually to be taken under > consideration by my university today -- not that there's any chance that > this could actually happen at this point -- I would actively oppose it, > or at least recommend that a major effort be undertaken to explore every > other possible substitute (and there are some out there) to meet the > same needs. We have a Mathematica site license at my institution that allows Mathematica to be installed on all university owned computers as well as computers personally owned by faculty, staff, and students. The students learn to use Mathematica as they go through the calculus sequence, and continue to use it as they go on in mathematics, physics, chemistry, etc. Yes, there is a learning curve, just as there is with mathematics itself, or with anything else that is worthwhile. It is 100% worth the effort. All of my students succeed in learning to use Mathematica effectively. All it takes is to provide them all with Mathematica, teach them the basics of using Mathematica at the beginning of the semester, use Mathematica routinely in class and require its use on assignments, and provide some support for the students (office hours, help sessions, e-mail, etc.) -- Helen Read University of Vermont === Subject: Re: Mathematica 7.0.1.0 and some General Comments > I was mildly disappointed that some fixes did not appear in Mathematica > 7.0.1.0. Some of these appear to be platform dependent but they were > verified on MathGroup by other users besides myself. 1) In Input cells the vertical bar or Mathematica Alternatives symbol does > not display properly. It only shows a short truncated stub. It does display > properly in Output cells and it does perform properly. This seems to occur > only with certain font sizes and magnifications. a|b 2) There is still a problem with the various types of Density plots in that > part of the plot Frame is cut off. DensityPlot[Sin[x y], {x, 0, 3}, {y, 0, 3}] 3) In many situations Copy and Paste do not work properly from the context > menu. I consider this a major problem. I was warned that this fix would not > appear in 7.0.1.0, but I would have preferred that the update be delayed > until it could be fixed. I personally am greatly relieved they did not wait any longer. In fact, I would have liked an update far sooner than this. The printing bug was a huge pain. Students would end up having to print their work two or three or four times before finally getting the pages to break correctly. Aside from the aggravation, it was a big waste of time and paper. So far it seems to be working correctly in 7.0.1. The other bug I'm very glad to have fixed is the problem of the keyboard shortcuts (Alt-7 to for a Text cell, etc.) becoming disabled any time you do a right-click (for example to copy/paste). I tried to avoid opening up any context menus, but of course I'd sometimes forget, then the shortcuts didn't work until I clicked off the notebook and back again. It was incredibly annoying. I am *much* happier now that this is fixed. > It is a bit more than a minor chore to do an update of Mathematica. Perhaps, but it's worth it to me to have what I consider the worst bugs fixed. And the 7.0.1 installation is pretty easy if you already have 7.0.0 installed. If you accept all the default options, it goes ahead and uninstalls 7.0.0, sucks up your mathpass and init.m files, and installs 7.0.1. Even in a lab setting with multiple computers, it's pretty easy. A colleague and I maintain the computers in two math classrooms (62 computers total), and we will install 7.0.1 over our spring break next week, without having to re-image the machines. We tried out a silent install yesterday on a couple of test machines, and it worked beautifully. We made up a little command file that connects a computer to a network share where we have the Mathematica installation files, and tells the computer to install Mathematica without anyone having to answer questions or click Next. All we have to do is send the ..cmd file out to all the client computers and execute it, all of which we can do remotely. -- Helen Read University of Vermont === Subject: Re: Mathematica 7.0.1.0 and some General Comments I disagree completely as to Power(less)point, at least. Like Project, Excel, Word, Windows, Money, Windows itself, and every other MS application I can think of, Powerpoint has barely improved AT ALL in 15 years. More bells and whistles, yes; significant improvement in functionality or paradigm? No. But if that's what you like, fine. Of that group, Money is WORSE than frozen in time. It degrades continually. It has no on-disk documentation now, its online docs are useless, EVERY default setting is the least convenient possible, and Vista was shipped incompatible with it due to IE security defaults. You couldn't reach banks, and you couldn't reach online documentation so that you could hope to fix the problem. A MS app, incompatible with a MS operating system. Astonishing! (I found a fix, but MS was definitely not the source.) Encarta was my favorite encyclopedia, better than anything I can find today, but they simply abandoned it. So... if you depend on Powerpoint for anything, you're very trusting. Meanwhile, Mathematica gains power in all directions at a phenomenal rate. True, it outstrips its documentation, and I'm a well-known critic of THAT... but MS applications, arguably, are worse. Anyway, I like being able to do just about ANYTHING in a single application (Mathematica). I agree on the price-point for a first-time purchase, but Premium Support, with its free upgrades, isn't a bad deal, at all. (The support has never helped me one iota, but the upgrades are worth it, anyway.) In every way, it's a long-term investment. Bobby > The 2 January 2009 issue of Science was largely devoted to 'Education >> and >> 'virtual reality', java applets and such but I could not find a single >> mention of Mathematica or even CASs in general. To me, this is >> absolutely >> incredible! I cannot see anything that can come even close to >> Mathematica >> for students who actually want to DO some mathematics or learn some >> technical subject matter. I'm thinking of actually organizing >> calculations, >> derivations or proofs, trying examples and alternative methods, and >> describing and explaining the methods. Isn't this what 'STEM' education >> should be all about? >> A year or so ago, on sci.math.symbolic a high school student stated >> that he >> was interesting in studying pure mathematics and wanted to know what >> computer language he should learn to further that goal. There were >> hundreds >> of responses with some threads going to great depth. As far as I could >> find, >> there was not a single mention of Mathematica and only one reference to >> using a CAS. Everything else concerned the merits of C++, Perl, List, >> Fortran etc. To me, this again was incredible. I am absolutely as saddened and dismayed by the above observations as I > believe David Park is -- but unfortunately also not much surprised by > them. I would especially endorse every word of the last three sentences of the > first paragraph above. I have long believed in, and personally and > extensively used Mathematica for exactly those purposes, in research, > teaching, educating, learning, publishing, lecturing, and personal > avocations, ever since the day I got my hands on Mathematica version 1 > (and, in fact, I pursued all those objectives using RealBASIC, Igor, > Excel, and other even more primitive tools well before that). On the other hand, I am also (equally sadly) not at all surprised by the > above observations. The bizarre and idiosyncratic and dysfunctional way > that Mathematica has evolved, in its structure and syntax, in its user > interface, in its pricing, and in its documentation, among other > factors, all contribute significantly to the dismal situation summarized > by David above. I don't understand how things can have gone so wrong > for Mathematica -- but they have. Ten years ago I was writing enthusiastic memos to my Deans and Vice > Provosts for Research, and my university's IT people, urging them to > invest university funds in Mathematica licenses and bookstore discounts; > to sponsor (or pay for) free training courses for students, faculty and > staff through the university; to promote the use of Mathematica > throughout every even mildly technical area of the university; and to > make it a kind of semi-official university standard for all areas of > research and teaching (as they had, at that time, semi-officially done > for the Mac platform). To be blunt, if a proposal like that were actually to be taken under > consideration by my university today -- not that there's any chance that > this could actually happen at this point -- I would actively oppose it, > or at least recommend that a major effort be undertaken to explore every > other possible substitute (and there are some out there) to meet the > same needs. >> This all leads me to believe that Mathematica is poorly positioned in >> the >> marketplace. At the present time, static printed documents are the >> dominant >> method of publication and communication in the technical world. >> Mathematica >> is primarily an ancillary tool to produce calculated results and >> starting >> graphics for these static documents. I believe that static documents >> are a >> dying technology and they will sooner or later be replaced by active and >> dynamic Mathematica notebooks - or their equivalent. Why? Because they >> are >> orders of magnitude superior for presenting and explaining mathematical >> and >> technical ideas. WRI seems to have this concept in mind but one feels >> that >> they don't take it with full seriousness, or realize the impediments in >> the >> way. Unfortunately here we have to part company. Your second sentence above > makes it seem as if you've never heard of PowerPoint -- which is very > possibly the dominant method of publication and communication in the > technical world today -- along with QuickTime, HTML, Flash, Word, TeX, > LaTeX, the entire Adobe product line, and the ever expanding set of > online and multimedia journals and innumerable personal and > institutional web sites, all of which, working together quite > constructively in most cases, are nearly obliterating static printed > documents, in the technical world and everywhere else. Mathematica is (or at least in earlier versions was, from the beginning) > absolutely an insanely great ancillary tool to produce calculated > results and starting graphics (including all kinds of animations) for > all the objectives we've both agreed upon. Adding a certain level of > interactivity to these graphics in recent versions is quite wonderful > also. But the idea that these results, along with all the underlying analysis, > will then also have to be delivered (presented, displayed, put on > screen) (and also organized, maintained, cataloged, re-purposed, > modified, edited, annotated), using (and _only_ using) Mathematica and > Mathematica notebooks, is just, in my considered opinion, an absolute > non-starter -- and a _highly_ destructive concept as well, in its impact > on the usability of Mathematica for what it's really good at (and where > it in fact really has very limited competition). I'm afraid that I'm strongly enough convinced of this point that > examining this idea further is just of no interest to me. We should be > focusing on what's needed to keep Mathematica highly _usable_ for the > particular things it's really near uniquely _useful_ for, not trying to > make it a monster tool for everything in the world. > -- DrMajorBob@bigfoot.com === Subject: Re: When a string does not match itself > This is a maybe a trivial question, but I have not found the explanation = in > help (I am using Mathematica 7.0.0): Normally a string matches itself: In[270]:= StringMatchQ[monkey, monkey] Out[270]= True But In[271]:= StringMatchQ[*, *] Out[271]= False Why? Yes, this is a bit tricky. In a pattern, * stands for any sequence of characters. So we need a way to construct a pattern that only matches the * character. This is done by escaping, i.e. preceding the * by a backslash. To make things more complicated, we also need to escape the backslash to include it into a Mathematica string. So the patter * is just an escaped *, i.e. it matches a *, and * only. To match *, we need to use *. In[3]:= StringMatchQ[*, *] Out[3]= True Escaping can get ugly. > Compare also to In[4]:= StringCases[*, *] Out[4]= {*} In[267]:= StringPosition[*, *] Out[267]= {{1, 2}} > Ingolf Dahl Sweden ingolf.d...@telia.com === Subject: Re: When a string does not match itself You have to escape both the and the * as in StringMatchQ[*, *] since both are special characters.... > This is a maybe a trivial question, but I have not found the explanation = in > help (I am using Mathematica 7.0.0): Normally a string matches itself: In[270]:= StringMatchQ[monkey, monkey] Out[270]= True But In[271]:= StringMatchQ[*, *] Out[271]= False Why? Compare also to In[4]:= StringCases[*, *] Out[4]= {*} In[267]:= StringPosition[*, *] Out[267]= {{1, 2}} > Ingolf Dahl Sweden ingolf.d...@telia.com === Subject: Re: When a string does not match itself StringMatchQ[*, Verbatim[*]] === Subject: Re: When a string does not match itself > In[271]:= StringMatchQ[*, *] ref/StringMatchQ says: StringMatchQ allows both ordinary StringExpression string patterns, as well as abbreviated string patterns containing the following metacharacters: * zero or more characters @ one or more characters, excluding uppercase letters *, etc. literal *, etc. === Subject: Re: When a string does not match itself > This is a maybe a trivial question, but I have not found the explanation = in > help (I am using Mathematica 7.0.0): Normally a string matches itself: In[270]:= StringMatchQ[monkey, monkey] Out[270]= True But In[271]:= StringMatchQ[*, *] Out[271]= False Why? Compare also to In[4]:= StringCases[*, *] Out[4]= {*} In[267]:= StringPosition[*, *] Out[267]= {{1, 2}} > Ingolf Dahl Sweden ingolf.d...@telia.com The second argument to StringMatchQ[] is a pattern and the first argument is a string, so if you wanted to you could StringMatchQ[*, *] and you would get a value of True back. Look over the documentation of StringMatchQ[] and String Patterns guide and tutorial for more info. -Bob === Subject: Re: When a string does not match itself has a special meaning in strings. n is new line, t is tab, and otherwise is a literal directive Print[This is ttab and newlinenliteral quote and literal backslash or nat the end of a line] This is tab and newline literal quote and literal backslash or at the end of a line And * is a wildcard in strings StringMatchQ[#, mon*ey] & /@ {money, monkey, monk's key} {True,True,True} Except when it is made literal StringMatchQ[#, mon*ey] & /@ {money, monkey, monk's key} {False,False,False} StringMatchQ[*, *] False I suspect that because of the multiple special characters and how and when that they are internally evaluated, that this is comparing different expressions than what you intended. StringMatchQ[, ] True StringMatchQ[*, *] True StringMatchQ[, ] True Bob Hanlon This is a maybe a trivial question, but I have not found the explanation in help (I am using Mathematica 7.0.0): Normally a string matches itself: In[270]:= StringMatchQ[monkey, monkey] Out[270]= True But In[271]:= StringMatchQ[*, *] Out[271]= False Why? Compare also to In[4]:= StringCases[*, *] Out[4]= {*} In[267]:= StringPosition[*, *] Out[267]= {{1, 2}} Ingolf Dahl Sweden ingolf.dahl@telia.com === Subject: Re: Need some help with monitoring evaluation > This has caused me some consternation in the past. By this I mean that > I make some coding error that causes Mathematica to loop. I would check out: ref/TimeConstrained > ref/Reap > ref/StepMonitor HTH. Roger Williams > Franklin Laboratory > I'm trying to convolve a Rayleigh distribution with a circular > distribution along the x dimension. It simplifies into a Gaussian > convolved with an expression of the form 1/(pi*Sqrt[q^2-x^2]). > * I have looked at StepMonitor, but it only applies to numerical evaluations and is not an option for a symbolic function like InverseFourierTransform. * Since I can't use StepMonitor, I can't see how to take advantage of Sow and Reap * I have also tried to useTimeConstrained, but the function simply returns $Aborted when the time limit is exhausted. * TracePrint and Trace dump too much output; I've tried to specify forms like _Simplify to reduce the output but Simplify isn't used until the end so it doesn't provide intermediate information. * Unless I can up with a meaningful pattern to use with TraceDialog, it's insane how many stops are involved. When I interrupt an evaluation, what can I examine? === Subject: ACA 2009 session call for talks All, I am organizing a session at the 2009 Applications of Computer Algebra conference (ACA 2009). It will take place in Montreal (at Ecole de technologie superieure) during June 25-28. Conference web site: http://aca2009.etsmtl.ca/ Click on Sessions in column on left, and mine will appear as 6. Applications of Math Software to Mathematical Research (Lichtblau) Click on the title and you will see the full session description. The purpose is to highlight various ways in which mathematical software is put to use in the realm of math research. Possibilities include experiment/conjecture, automated and/or assisted proof, development and analysis of algorithms, novel usage for presentation of ones work, etc. Typical sessions at ACA have talks of around 25 minutes. I am soliciting talk proposals for this session. Also please pass this invitation along to colleagues and students who might be interested. Daniel Lichtblau Wolfram Research danl at wolfram dot com === Subject: Re: Eigensystem sometimes returns Out of interest, does anyone know WHY Eigensystem can returns non-orthonormal eigenvectors? The eigenvectors of a matrix are generally NOT orthogonal (since that's what you meant, rather than orthonormal). The eigenvectors ARE usually independent (if the matrix is full rank), so you can transform all of space until they are orthogonal... but that has little to do with the original matrix and its eigensystem. Bobby > h = [a certain 3x3 hermitian matrix] > {u, d} = Eigensystem[h]; d=DiagonalMatrix[d] The eigenvalue equation is satisfied, as per the specifications: > h.Transpose[u] - Transpose[u].d == 0. > The eigenvectors are normalized, but not orthonormal: > u.ConjugateTranspose[u] != IdentityMatrix[3]. > If we compute the q part of the QRDecomposition, q = First@QRDecomposition[u] , then q.ConjugateTranspose[q] == IdentityMatrix[3], but h.Transpose[q] - > Transpose[q].d ==0, > so the eigenvalue equation is no longer satisfied. q =Transpose@First > @QRDecomposition[Transpose@u] doesn't work either. I haven't analysed things in detail, but since the task at hand is to > orthogonalize only the sets of eigenvectors u corresponding to > degenerate > eigenvalues, it may not be safe to use an approach > (Orthogonalize/QRDecomposition) that doesn't know about the pattern of > eigenvalues. Of course one can write a program beginning with > degenEigvalIndices=Split[Sort[d]] > and then calling Orthogonalize within each set, but this is kinda messy. > I'm wondering if it is actually easier to do the calculation in > Fortran/C++ > and use MathLink, somehow. Does Wolfram have any plans to add support > for > orthonormal eigenvectors? Out of interest, does anyone know WHY Eigensystem can returns > non-orthonormal eigenvectors? I was under the impression that > Eigensystem[] > first checks to see if the matrix is Hermitian, and if it is, it uses > LAPACK-based algorithms for Hermitian matrices. I thought LAPACK's > algorithms involved tridiagonalization followed by some form of QR > factorization/divide-and-conquer Givens rotations, in which the > eigenvector > matrix started off as the identity matrix and accumulated successive > unitary > transformations, thus remaining unitary at every stage; I'm curious how > Eigensystem[] even manages to break orthonormality at all. > already normalized --- the problem is that they're not mutually > orthogonal, > which seems to be trickier to fix. > p.p.s. Sorry this post is rather badly written. Maybe when the final > solution appears I will summarize things properly for the benefit of > future > readers. > In Mathematica 7.0.0 (for Linux), calling Eigenvectors[H] or > Eigensystem[H] > for a numerical Hermitian matrix H sometimes returns eigenvectors that > are > not orthonormal. > This happens when some eigenvalues are degenerate. (I can supply > example > code that illustrates the problem, if necessary.) This is not really a bug -- the documentation for Eigensystem[] doesn't > make > any guarantees of orthonormality -- but nevertheless it is an annoying > part > of Mathematica's design. > This issue has been raised 11 years ago ( > http://forums.wolfram.com/mathgroup/archive/1998/Mar/msg00418.html ), > but > that post is corrupted! (Surely Wolfram isn't resorting to > censorship?) > A non-corrupted version is located at the URL below. >> http://forums.wolfram.com/mathgroup/archive/1998/Mar/msg00425.html >> Note that the behavior in that report was of a more serious nature than >> that which you describe (eigenvectors sometimes had complex values). >> I > was hoping that in Mathematica 7 I would be able to write something > like Eigensystem[H, Method->LAPACK-ZHEEVR] or Eigensystem[H, OrthonormalizeEigenvectors->True] but no such options seem to exist. One workaround is to apply > Orthogonalize[] to the matrix of eigenvectors, but the documentation > for > Orthogonalize[] doesn't guarantee that the orthonormalization will only > occur within the degenerate subspace. So one has to resort to > complicated > fixes (e.g., http://arxiv.org/pdf/hep-ph/9607313 ). > Does anyone have a simpler solution? (For example, is there an easy > way > to > call LAPACK'S ZHEEVR routine, which guarantees orthornormal > eigenvectors, > from Mathematica?) Yen Lee Loh > If you apply QRDecomposition to the eigenvectors, then I believe the Q >> part >> will provide what you are looking for. >> Daniel Lichtblau >> Wolfram Research > > -- DrMajorBob@bigfoot.com === Subject: Re: Exporting data into a file, OpenWrite I use either ToFileName or a variant of the following, when I want to capture/create file or directory names: {FileNameSetter[Dynamic@ts, Directory], Dynamic@ts} I never, ever type in the file name by hand, so I never, ever get Windows and Mac conventions confused. Bobby >> no double-slashes for me thank you very much - I've got a Mac. >> 2009/2/24 Sjoerd C. de Vries : > When you use Export, the file will be created in the current >> working directory. > I might add ...unless you include the full path to the file in the > filename (using double slashes to separate directories and files, as a > slash is used as an escape character in strings) > I think correctly you would call the character that you need to use on > Windows a backslash () and that's the one you need to escape, because > it is the escape character in Mathematica. On other systems you will > need other characters for separating directories in pathes, which one is > held in the variable $PathnameSeparator. AFAIK on Windows in many > places within Mathematica a single slash (/) will also work as a > pathname separator in filenames. Probably you shouldn't rely on that but > it's more convenient than the double backslash sometimes. An even better approach is to construct the filename with the function > ToFileName, starting with one of the predefined directory variables you > can find with Information[$*Directory*] > hth, albert > -- DrMajorBob@bigfoot.com === Subject: Re: DiscretePlot > Additionally, you could use ListPlot @ Table[ s[k], {k,1,150} ] or > ListPlot @ Array[s,150]. As I said in my original post, we used ListPlot before v. 7. My point is that DiscretePlot is (or should be) more convenient, since it does not require first making a table. Someone from Wolfram e-mailed me about the Joined->Automatic in DiscretePlot, and perhaps they will change the way it behaves. -- Helen Read University of Vermont === Subject: Re: Galois resolvent So you need these roots? Solve[t^3 + 2 B t^2 + (B^2 - 4 D) t - C^2 == 0, t] {{t -> -((2 B)/3) - (2^(1/3) (-B^2 - 12 D))/( 3 (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) + (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3)/( 3 2^(1/3))}, {t -> -((2 B)/3) + ((1 + I Sqrt[3]) (-B^2 - 12 D))/( 3 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) - ((1 - I Sqrt[3]) (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3))/( 6 2^(1/3))}, {t -> -((2 B)/3) + ((1 - I Sqrt[3]) (-B^2 - 12 D))/( 3 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) - ((1 + I Sqrt[3]) (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3))/( 6 2^(1/3))}} or these? Solve[x^4 + B x^2 + C x + D == 0, x] // Simplify {{x -> (1/( 2 Sqrt[6]))([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) - [Sqrt](-8 B - ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - (12 Sqrt[6] C)/([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3) + 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3)))))}, {x -> (1/( 2 Sqrt[6]))([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) + [Sqrt](-8 B - ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - (12 Sqrt[6] C)/([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3) + 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3)))))}, {x -> -(1/( 2 Sqrt[6]))([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) + [Sqrt](-8 B - ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + (12 Sqrt[6] C)/([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3) + 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3)))))}, {x -> (1/( 2 Sqrt[6]))(-[Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) + [Sqrt](-8 B - ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + (12 Sqrt[6] C)/([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3) + 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3)))))}} Bobby > R(t) = t^3 + 2B t^2 + (B^2 - 4D)t - C^2 = 0. > -----Original Message----- === > Subject: Re: Galois resolvent The link includes illegible items such as the question marks in R(t) = t^3 + 2B t^2 + (B^2 ? 4D)t ? C^2 = 0. Hence, I have no idea what you're asking. Bobby >> Forthe quartic (*) x^4 + Bx^2 + Cx + D = 0 for integers B, C and D, >> assume that as for the case C = 0 that all its roots are classically >> contructible also for the case C /= 0. >> We can then show that the equation (*) is cyclic (i.e. its Galois >> group = Z4) iff the splitting field of its Descartes resolvent is E = >> Q[Sqrt[t0] /= Q for t0 the one and only integer roots t0 of the >> resolvent. For details, see >> http://mathforum.org/kb/thread.jspa?threadID=1903146. >> If the quartic (*) is cyclic, it should be possible using the above to > explicitly construct the so-called Galois resolvents of (*): The roots > x1, x2, x3 and x4 of the quartic (*) can be given by polynomials of r >> with degree less or equal to 3 with rational coefficients for r an >> arbitrarily root of the quartic. (I.e. the splitting field of the >> quartic (*) when cyclic is Q[r] for r a root.) >> Can somebody, using Mathematica, explicitly determine these polynomial > representations of the roots of the quartic (*). The case C = 0 is > easy. >> But the case C /= 0 is indeed messy. >> Kent Holing, >> NORWAY > > -- > DrMajorBob@bigfoot.com > ------------------------------------------------------------------- > The information contained in this message may be CONFIDENTIAL and is > intended for the addressee only. Any unauthorised use, dissemination of > the > information or copying of this message is prohibited. If you are not the > addressee, please notify the sender immediately by return e-mail and > delete > this message. -- DrMajorBob@bigfoot.com === Subject: Re: Galois resolvent The link includes illegible items such as the question marks in R(t) = t^3 + 2B t^2 + (B^2 ? 4D)t ? C^2 = 0. Hence, I have no idea what you're asking. Bobby > Forthe quartic (*) x^4 + Bx^2 + Cx + D = 0 for integers B, C and D, > assume that as for the case C = 0 that all its roots are classically > contructible also for the case C /= 0. We can then show that the equation (*) is cyclic (i.e. its Galois group > = Z4) iff the splitting field of its Descartes resolvent is E = > Q[Sqrt[t0] /= Q for t0 the one and only integer roots t0 of the > resolvent. For details, see > http://mathforum.org/kb/thread.jspa?threadID=1903146. If the quartic (*) is cyclic, it should be possible using the above to > explicitly construct the so-called Galois resolvents of (*): The roots > x1, x2, x3 and x4 of the quartic (*) can be given by polynomials of r > with degree less or equal to 3 with rational coefficients for r an > arbitrarily root of the quartic. (I.e. the splitting field of the > quartic (*) when cyclic is Q[r] for r a root.) Can somebody, using Mathematica, explicitly determine these polynomial > representations of the roots of the quartic (*). The case C = 0 is easy. > But the case C /= 0 is indeed messy. Kent Holing, > NORWAY > -- DrMajorBob@bigfoot.com === Subject: Re: Galois resolvent R(t) = t^3 + 2B t^2 + (B^2 - 4D)t - C^2 = 0. -----Original Message----- === Subject: Re: Galois resolvent The link includes illegible items such as the question marks in R(t) = t^3 + 2B t^2 + (B^2 ? 4D)t ? C^2 = 0. Hence, I have no idea what you're asking. Bobby > Forthe quartic (*) x^4 + Bx^2 + Cx + D = 0 for integers B, C and D, > assume that as for the case C = 0 that all its roots are classically = > contructible also for the case C /= 0. We can then show that the equation (*) is cyclic (i.e. its Galois > group = Z4) iff the splitting field of its Descartes resolvent is E = = > Q[Sqrt[t0] /= Q for t0 the one and only integer roots t0 of the > resolvent. For details, see > http://mathforum.org/kb/thread.jspa?threadID=1903146. If the quartic (*) is cyclic, it should be possible using the above to > explicitly construct the so-called Galois resolvents of (*): The roots > x1, x2, x3 and x4 of the quartic (*) can be given by polynomials of r > with degree less or equal to 3 with rational coefficients for r an > arbitrarily root of the quartic. (I.e. the splitting field of the > quartic (*) when cyclic is Q[r] for r a root.) Can somebody, using Mathematica, explicitly determine these polynomial > representations of the roots of the quartic (*). The case C = 0 is easy. > But the case C /= 0 is indeed messy. Kent Holing, > NORWAY > -- DrMajorBob@bigfoot.com ------------------------------------------------------------------- The information contained in this message may be CONFIDENTIAL and is intended for the addressee only. Any unauthorised use, dissemination of = the information or copying of this message is prohibited. If you are not the addressee, please notify the sender immediately by return e-mail and = delete this message. === Subject: Re: Setting global Plot font options Plot[Sin[x], {x, 0, 2 Pi}, Frame -> True, FrameLabel -> {x, Sin[x]}, BaseStyle -> {FontFamily -> Helvetica, FontSize -> 16}] or SetOptions[ #, BaseStyle -> {FontFamily -> Helvetica, FontSize -> 16}] & /@ {Plot,ListPlot}; Jens > Hi - > Where can I set the global default font for plot objects? I'd like > AxesLabel, FrameLabel, PlotLegend, and the Ticks to all be the same > font without having to specify it in the Plot call every time. > TIA, > Matt > === Subject: Re: lock image size in a cell Alessandro, > often evaluating functions that output images as a result, I re- > evaluate an input cell many times, fine tuning its parameters. > Since the images I process are large, I manually resize the image > output to visually inspect it. Re-evaluating the input, the output > doesnt remember my manually-set size. > > There is a way to lock this cell size - just for display (I dont want > to effectively resize the image) ? > > > alessandro magni Would the ImageSize option work for your case? Instead of: outputimage = F[input] Try: outputimage = Image[F[input], ImageSize -> 400] You can always reset the option later: outputimage = Image[outputimage, ImageSize -> Automatic] Matthias Odisio Wolfram Research === Subject: Re: newbie: programmatic sequence of plots? > Loops themselves only have a null return value. Doh! I was assuming ListPlot would have a side effect. > return a list of these plots additionaly or instead of just > printing them, so that you can use ListAnimation or TabView or > whatever you like for displaying them. And the way to do that is > Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; > a = 3.5; > nRecurr = 50; > yinit = 0.1; > yinc = 0.01; > yfinal = 0.2; > out = {}; (* modification here *) > For[y0 = yinit, y0 <= yfinal, y0 += yinc, > AppendTo[out, (* modification here *) > ListPlot[ > RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, > y, {n, 1, nRecurr}]]]; > ]; > out (* modification here *) So I modified that to do For[y0 = yinit, y0 <= yfinal, y0 += yinc, AppendTo[out, ListPlot[ RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, y, {n, 1, nRecurr}], Joined -> True ] ]; ]; ListAnimate[out] which is even better than printing a list of static plots. === Subject: Re: newbie: how to define, typeset a multi-rule function? Tom Roche Feb 24, 5:46 am (rearranged) >> For an example in a math layout, I can almost typeset the function >> in OpenOffice Math like f_x(%chi) = left lbrace stack {k if %chi in >> [0,1] # 0 otherwise} right rbrace (except that I don't want the >> closing brace, but that's another problem). I tried to create this >> using the palettes, but I didn't see one that did multiline >> brackets. or Piecewise brackets. Gotta learn the terminology! > Formatting/entry goes like this: Use Esc pw Esc to enter { i.e. that brings up the piecewise bracket > and Ctrl+Comma i.e. having typed the return value of the first case (e.g. k), type C-, to type the conditions for the first case (e.g. 0 <= [Chi] <= 1) > and then Ctrl+Enter for each additional piecewise case === Subject: Re: Bug in Export to HTML in v7? It works for me. It might be the final slash in your filename. On your platform I guess this makes the file name a directory name? > The following very handy code to save a notebook as HTML and to follow > closed links used to work in v6 no longer works in v7. Was wondering > if there is a workaround: Export[~/tmp/, EvaluationNotebook[], HTML, > ConvertClosed -> LinkedPage]; (I put this code is in the notebook I am saving itself so it appears > in the HTML output, which is OK). === Subject: Show problem: combining ListPlot and Plot The following extract exemplifies a plot technique I used to combine ListPlot and a Plot under v 2.2. It worked fine under 3.0, 4.1,4.2 and 5.1. But students using this under 6.0 and 7.0 for a HW report the plot frame squished, and that line colors disagree with the title. Question: can this be fixed in DisplayChannel=$DisplayFunction; If [$VersionNumber>=6.0, DisplayChannel=Print]; (* fix for Mathematica 6 & later *) Off[General::spell1]; Off[General::spell]; ClearAll[r]; vFEM={{4., 0.054}, {7., 0.0395}, {10., 0.037}}; vexact=0.1905*(1/r + r/100); rbeg=4.; rend=10.; pFEM=ListPlot[vFEM,PlotJoined->True,PlotStyle->{RGBColor[1,0,0]}, DisplayFunction->Identity]; pexact=Plot[vexact,{r,rbeg,rend},PlotStyle->{RGBColor[0,0,0]}, DisplayFunction->Identity]; Show[Graphics[AbsoluteThickness[2]],pexact, pFEM,TextStyle->{FontFamily->Times,FontSize->12}, GridLines->Automatic,Axes->True,PlotRange->All, PlotLabel->Radial displacement (black=exact,red=FEM), Frame->True, DisplayFunction->DisplayChannel]; === Subject: Re: Licenses for Sharing Notebooks Hi Hans, what is wrong with public software. I think it hinders development if everybody tries to conceal their work. I got the impression that the less qualified people are, the more energy they spend on licensing and encryption. Daniel > I was wondering what kind of licenses are commonly used to distribute > and share Mathematica notebooks, such as tutorials and interactive > lecture notes, without completely setting them into public domain. > focus on compiled binaries do not really seem to be appropriate. Maybe > the different variations of Creative Commons Licenses [http:// > creativecommons.org/license/] are a better fit? Could people in this > group share if and why they selected a specific license in a similar > siutation? Hans-Martin > === Subject: Re: About Reduce and Mod Mathematica calculates by default with complex number. You must tell it that you are looking for real numbers by e.g. specifying a domain: Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Reals, Backsubstitution -> True] hope this helps, Daniel > Hi Mathematica community, > I have this input: Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, > {xP}, Backsubstitution -> True] > Mathematicas gives me this output:0 <= Re[Mod[x, 5]] < 5 && Im[Mod[x, > 5]] == 0 && xP == Mod[x, 5] > 1)but why there is 0 <= Re[Mod[x, 5]] < 5 && Im[Mod[x, 5]] == 0 as > part of the output ? > 2) and how could I eliminate it (by adding something in reduce for > example) because all that I want is only this output xP == Mod[x, 5]? thank you very much. > === Subject: Re: About Reduce and Mod FullSimplify[ Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Backsubstitution -> True], Element[x, Reals]] ?? Jens > Hi Mathematica community, > I have this input: Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, > {xP}, Backsubstitution -> True] > Mathematicas gives me this output:0 <= Re[Mod[x, 5]] < 5 && Im[Mod[x, > 5]] == 0 && xP == Mod[x, 5] > 1)but why there is 0 <= Re[Mod[x, 5]] < 5 && Im[Mod[x, 5]] == 0 as > part of the output ? > 2) and how could I eliminate it (by adding something in reduce for > example) because all that I want is only this output xP == Mod[x, 5]? thank you very much. > === Subject: Re: newbie: diff equation Hi Mike, obviously f==0 is the correct generic solution. What you are looking for is a singular case for m== Integer. Therefore, you must give m explicitly. But then the problem is not fully specified, we may e.g. aditionally specify f'[0]: DSolve[{f''[x] == -9 f[x], f[0] == 0, f[Pi] == 0, f'[0] == 1}, f[x],x] hope this helps, Daniel I want to solve f''[x]= - m^2 f[x] with f[0] = 0 and f[Pi] = 0 this is obviously only solvable with the condition on m being integer but if I do DSolve on the above with the boundary conditions I just get f=0. How can I get mathematica to solve this and give me the conditions on m? I need to solve much more general problems of this type. I hope someone can help. > === Subject: Re: newbie: diff equation you can't, because this is a eigenvalue problem and *not* a differential equation. An eigenvalue problem has either none or an infinite number of solutions and Mathematica gives you the none solution, especial because it would take to long to print out the infinite number of solutions. In QM you take one of the infinite solutions and normalize it. And you have to do it manual in Mathematica. Jens I want to solve f''[x]= - m^2 f[x] with f[0] = 0 and f[Pi] = 0 this is obviously only solvable with the condition on m being integer but if I do DSolve on the above with the boundary conditions I just get f=0. How can I get mathematica to solve this and give me the conditions on m? I need to solve much more general problems of this type. I hope someone can help. > === Subject: Re: newbie: diff equation You have to use two equals signs instead of one when inputting a differential equation. -----Original Message----- === Subject: newbie: diff equation My problem is very simple, I'm sure someone can help me out quickly. I am in a box (QM) so I started with this basic problem which I know how to solve just to make sure I am entering everything ok, but I can't even get it to work. I want to solve f''[x]= - m^2 f[x] with f[0] = 0 and f[Pi] = 0 this is obviously only solvable with the condition on m being integer but if I do DSolve on the above with the boundary conditions I just get f=0. How can I get mathematica to solve this and give me the conditions on m? I need to solve much more general problems of this type. I hope someone can help. === Subject: Re: newbie: diff equation You're asking DSolve to do its own work and the work of Solve, at the same time. Try it with fewer conditions: DSolve[f''[x] == -m^2 f[x], f, x] {{f -> Function[{x}, C[1] Cos[m x] + C[2] Sin[m x]]}} or Clear[f] f[x_] = f[x] /. Last@DSolve[f''[x] == -m^2 f[x], f, x]; Reduce[{f[0] == 0, f[Pi] == 0}, {C[0], C[1], m}] (C[3] [Element] Integers && ((C[2] != 0 && C[1] == 0 && m == 2 C[3]) || (C[1] == 0 && m == 1 + 2 C[3]))) || ((-[Pi] + m [Pi])/(2 [Pi]) [NotElement] Integers && C[2] == 0 && C[1] == 0) or Clear[f] f[x_] = f[x] /. Last@DSolve[{f''[x] == -m^2 f[x], f[0] == 0}, f[x], x] Reduce[f[Pi] == 0, {m}] // Simplify C[2] Sin[m x] (C[1] [Element] Integers && (m == 2 C[1] || m == 1 + 2 C[1])) || C[2] == 0 Unless C[2] == 0, that works out to mean m is an integer, but... as you can see... Mathematica somehow isn't able to straightforwardly say so. Bobby > My problem is very simple, I'm sure someone can help me out quickly. I > am trying to solve some systems of differential equations a bit like a > how to solve just to make sure I am entering everything ok, but I can't > even get it to work. I want to solve f''[x]= - m^2 f[x] with f[0] = 0 and f[Pi] = 0 this is obviously only solvable with the condition on m being integer > but if I do DSolve on the above with the boundary conditions I just get > f=0. How can I get mathematica to solve this and give me the conditions > on m? I need to solve much more general problems of this type. I hope > someone can help. > -- DrMajorBob@bigfoot.com === Subject: Re: Experimental Mathematica debugger Hi David, another great addition from you, thank's a lot. There is a samll bug with the conditional break point window. It is not possible to input any text because it does not take the focus. I have Mathematica version 7 on Vista. thank's again, Daniel > I have been fairly dissatisfied with the built-in debugger available in > versions 6 and 7, and I would like people to try an experimental new > debugger for an earlier version of Mathematica - called M-Debug. That > debugger was based on TraceScan, and was unable to locate Mathematica > expressions within the original source code. It was also very slow when > code was executing to a breakpoint. DebugTrace works in a new way, identifying program locations using line > numbers which double as breakpoint toggle buttons! I work as a consultant, and in my experience, projects often start with > a very large notebook, full of unstructured code, which it is necessary > to understand. Beginners typically write programs in this style - often > without a single user-defined function - and DebugTrace can operate well > on this kind of code, as well as more elegant code and also packages. DebugTrace is a Mathematica program like any other - i.e. it operates > without any kernel hacks, but this means that it is fairly easy to add > support for particular pieces of software. For example the debugger > knows about my Super Widget Package, and when appropriate, it displays > an extra button that enables the debugger to gain control while a modal > Java window is being displayed (without closing the window). I imagine > that this flexibility may be useful in other contexts. Another revolutionary feature of DebugTrace, is that it comes with > actual documentation, illustrated with a small example program! DebugTrace version 0.95 is available free from my website. It will > remain free even after it is polished. If you find specific problems, it > might be best to e-mail me directly with a simple example. As I say, this project is experimental, and its future development - if > any - depends on the feedback I receive. > David Bailey > http://www.dbaileyconsultancy.co.uk === Subject: Re: Eigensystem[hermitianMatrix]sometimes returns Hi Bob, perhaps you may mean: Orthogonalization. Normalization does not make vectors orthogonal. But then one has to make sure that eigenvectors belonging to different eigenvalues get not mixed up. The default method Gram-Schmidt should work in this case, but I did not try this out. hope this helps, Daniel Daniel > I suppose the simplest thing is Normalize/@Eigenvalues[m] or {First@#,Normalize/@Last@#}&@Eigensystem[m] Bobby >> In Mathematica 7.0.0 (for Linux), calling Eigenvectors[H] or >> Eigensystem[H] >> for a numerical Hermitian matrix H sometimes returns eigenvectors that >> are >> not orthonormal. >> This happens when some eigenvalues are degenerate. (I can supply example >> code that illustrates the problem, if necessary.) >> This is not really a bug -- the documentation for Eigensystem[] doesn't >> make >> any guarantees of orthonormality -- but nevertheless it is an annoying >> part >> of Mathematica's design. >> This issue has been raised 11 years ago ( >> http://forums.wolfram.com/mathgroup/archive/1998/Mar/msg00418.html ), but >> that post is corrupted! (Surely Wolfram isn't resorting to >> censorship?) I >> was hoping that in Mathematica 7 I would be able to write something like >> Eigensystem[H, Method->LAPACK-ZHEEVR] >> or >> Eigensystem[H, OrthonormalizeEigenvectors->True] >> but no such options seem to exist. One workaround is to apply >> Orthogonalize[] to the matrix of eigenvectors, but the documentation for >> Orthogonalize[] doesn't guarantee that the orthonormalization will only >> occur within the degenerate subspace. So one has to resort to >> complicated >> fixes (e.g., http://arxiv.org/pdf/hep-ph/9607313 ). >> Does anyone have a simpler solution? (For example, is there an easy way >> to >> call LAPACK'S ZHEEVR routine, which guarantees orthornormal eigenvectors, >> from Mathematica?) >> Yen Lee Loh > === Subject: Re: Eigensystem[hermitianMatrix]sometimes returns you want to Normalize/@Eigenvalues[m] and not the eigenvectors ?? Jens BTW: What helps the normalization when the vectors are not orthogonal ? > I suppose the simplest thing is Normalize/@Eigenvalues[m] or {First@#,Normalize/@Last@#}&@Eigensystem[m] Bobby >> In Mathematica 7.0.0 (for Linux), calling Eigenvectors[H] or >> Eigensystem[H] >> for a numerical Hermitian matrix H sometimes returns eigenvectors that >> are >> not orthonormal. >> This happens when some eigenvalues are degenerate. (I can supply example >> code that illustrates the problem, if necessary.) >> This is not really a bug -- the documentation for Eigensystem[] doesn't >> make >> any guarantees of orthonormality -- but nevertheless it is an annoying >> part >> of Mathematica's design. >> This issue has been raised 11 years ago ( >> http://forums.wolfram.com/mathgroup/archive/1998/Mar/msg00418.html ), but >> that post is corrupted! (Surely Wolfram isn't resorting to >> censorship?) I >> was hoping that in Mathematica 7 I would be able to write something like >> Eigensystem[H, Method->LAPACK-ZHEEVR] >> or >> Eigensystem[H, OrthonormalizeEigenvectors->True] >> but no such options seem to exist. One workaround is to apply >> Orthogonalize[] to the matrix of eigenvectors, but the documentation for >> Orthogonalize[] doesn't guarantee that the orthonormalization will only >> occur within the degenerate subspace. So one has to resort to >> complicated >> fixes (e.g., http://arxiv.org/pdf/hep-ph/9607313 ). >> Does anyone have a simpler solution? (For example, is there an easy way >> to >> call LAPACK'S ZHEEVR routine, which guarantees orthornormal eigenvectors, >> from Mathematica?) >> Yen Lee Loh > === Subject: how to solve 2-variable recurrence equation for a[m.n] a[m,n] = a[m-1,n] + a[m-1,n-1] + a[m,n-1] , m<=n a[0,0] =1, a[0,n]=1,a[1,1]=2 how to solve? === Subject: Re: Map and functional constructs to replace iterative statements > I have begun to replace Table, Do, While, or For, but in my thinking with= Map, Inner, Outer and other functional programming constructs as I learn m= ore about Mathematica. But, I'm stuck. I need to figure out how to use Map (or some related a= pproach) when a function needs both a current value and a previous value in= a time series, such as a percentage change function (or perhaps more gener= ally stated, when I need to refer to previous values in a series or even pr= evious calculations). But first a simple case: percentChange[currentValue_, previousValue_] := 100 * ( currentValue - = previousValue) / previousValue I know how to apply this iteratively, but how can I do it with Map or som= e other functional construct? Say I have a list: timeSeries I thought to try something like this: Map[percentChange[?,?], timeSeries] but I don't know how what to put in for ?. Any help much appreciated. Thx. Daniel's solution is probably the best in terms of simplicity but this seems to be slightly faster: 100*Differences[d]/Most[d] I had initially thought of ListCorrelate which also gives a fast reply with large data sets: 100*ListCorrelate[{-1, 1}, d]/Most[d]; Trying to get it all to happen within a single function only slowed things down: gg[x_, y_] := y/x - 1 100*ListCorrelate[{1, 1}, ls, {1, -1}, 0, Times, gg] (far too much happening to slow things down) Mike === Subject: Dificulty on Integrate function! I got a problem in integrating the expression (given below in input form) on Mathematica. Please give me some hints or a way around to get the solutions. . I want to integrate the equation with respect to b, c, and d. So that I get an equation only in terms of t and a. I tried to use Integrate function in Mathematica both in the form of definite and indefinite integral but it could not turn out the result. If the indefinite integral is not working the ranges of integration for definite integral shall be the following {b, 0, 170}, {c, 0, 400} and {d, 0,170}. (5.985857026794833*^-14*(14 + c)^2.37*E^(-0.0003630681026445808* (-50.29 + b)^2 - c/41 - 0.0003125*(-43.7 + d)^2 - b/d + t/d - 1.1985780806058064*^-6*(-3535.42 + c + ((a - c)*E^((-b + t)/d))/(t/b)^ (b/d))^2))/(t/b)^(b/d) Please please help me. If I could not get this solution I have to discard so many things I spent considerable time on! Negede === Subject: Re: AbsoluteOptions and ViewMatrix The docs page on ViewMatrix states: With the setting ViewMatrix->Automatic, explicit forms for the matrix m can be found using AbsoluteOptions[g,ViewMatrix]. However, as you mentioned this does not work and the docs are evidently wrong here. I tried everything I could think of, but this is a hard nut to crack. > When viewing any graphics such as: s=PolyhedronData[Dodecahedron]; AbsoluteOption works as advertised with PlotRange, but not ViewMatrix: AbsoluteOptions[s,PlotRange] (* give you the actual plot range, no= t > All *) AbsoluteOptions[s,ViewMatrix] (* give you Automatic, not the > actual value *) I understand that the actual PlotRange value is known to the kernel, > but not the ViewMatrix, which is handled in the notebook. Does anybody know how to get the ViewMatrix value out of the Notebook? Sebastien === Subject: Re: Transparent background with PNG > how can I save an image to PNG format (eg. a simple plot), with the > (white) background being transparent? I understand that PNG export > supports alpha channel, but have no clue how to instruct Mathematica > to exploit it. g = Plot[Sin[x], {x, 0, 2 Pi}] Export[~/Desktop/plot.png, g, Background -> None] -Rob === Subject: Re: Transparent background with PNG how can I save an image to PNG format (eg. a simple plot), with the > (white) background being transparent? I understand that PNG export > supports alpha channel, but have no clue how to instruct Mathematica > to exploit it. > Istvan Zachar Export[/1.png, Plot[x, {x, 0, 1}], Background -> None] Maxim Rytin m.r@inbox.ru === Subject: Re: Transparent background with PNG Try gr = Rasterize[expr, Background->None] (documented) Export[file.png, gr] Your expr needs to be something that can rasterized, such as a Graphics expression. Rasterizing something that's already a raster (Graphics[Raster[...]]) or Image expression is not going to work. An undocumented shortcut: Export[file.png, expr, Background->None] will do the same thing. Igor how can I save an image toPNGformat (eg. a simple plot), with the > (white) background being transparent? I understand thatPNGexport > supports alpha channel, but have no clue how to instruct Mathematica > to exploit it. > Istvan Zachar === Subject: Re: Transparent background with PNG how can I save an image to PNG format (eg. a simple plot), with the > (white) background being transparent? I understand that PNG export > supports alpha channel, but have no clue how to instruct Mathematica > to exploit it. This seems to be excessively obscure, but I got a png with a transparent background this way (in V7): plotImage = Plot[x^2, {x, 0, 2}] bkgImage = Image[ConstantArray[{0., 0., 0., 0.}, Reverse[ImageDimensions[plotImage]]], ColorSpace -> RGB] compImage = ImageCompose[bkgImage, plotImage] Export[~/Desktop/compImage.png, compImage] It seems that composing the graphic against a transparent image gives it an alpha channel. === Subject: Re: Transparent background with PNG img = Rasterize[Plot[Sin[x], {x, 0, 2 Pi}], Image]; and timg = ImageApply[ If[Sqrt[#.#] &[# - {1, 1, 1}] < $MachineEpsilon, Append[#, 0], Append[#, 1]] &, img] has an alpha channel. Jens > No idea? > === Subject: Re: Transparent background with PNG > No idea? In Mathematica 7, use something like Export[picture.png, %, ImageSize -> 600, Background -> None] I keep forgetting this syntax too (it's different between versions and http://www.uoregon.edu/~noeckel/MathematicaGraphics.html#ExportOpacity Jens === Subject: procedures Simple question: how can I in mathematica write a complex function? What I need to do is (pseudocode) FunctionToCode[x,n] { D[x_,n]:= something symbolic Do[ D[x,s]=D[x,s], {s,0,n} ]; return D[x,s] Clear[D] } Davide === Subject: How to Export the Manipulate Hi ,all i usually use Export[*.gif,Table[Graphics[]]] to generate a GIF figure, but dont know how to Export the Manipulate produced animations,can someone here drop me a hint ? Wayne. === Subject: question about simplify function This seems like a basic question, but I can't see the answer: Why doesn't either the Simplify or FullSimplify function transform the expression x/(xy) into 1/y? When I substitute a specific value in for x, the simplification occurs as expected, e.g., 4/(4y) transforms to 1/ y. Puzzling. Jack === Subject: Re: Map and functional constructs to replace iterative statements Many many thx for a host of interesting solutions and approaches to the problem. The feedback on my question has really helped me think about ways to use Mathematica in a more and more elegant way. I can now rewrite tons of code and have better, clearer, and much faster solutions. For the question I originally posed, I've settled on a combination of the offered solutions: timeSeries = {100., 102., 103., 104., 105.}; 100 Differences[timeSeries]/Most[timeSeries] Simple,clear, and works like a charm. P.S. I'm sure to have more questions (lots more questions)for the forum, stay tuned. === Subject: Re: About Reduce and Mod >I have this input: Reduce[{Mod[x, 5] == >Mod[xP, 5], 0 <= xP < 5}, {xP}, Backsubstitution -> True] >Mathematicas gives me this output:0 <= Re[Mod[x, 5]] < 5 && >Im[Mod[x, 5]] == 0 && xP == Mod[x, 5] 1)but why there is 0 <= >Re[Mod[x, 5]] < 5 && Im[Mod[x, 5]] == 0 as part of the output ? Mathematica by default assumes all variables can take on complex values. The output is specifying the conditions on a complex variable needed to make the equality hold. >2) and how could I eliminate it (by adding something in reduce for >example) because all that I want is only this output xP == Mod[x, 5]? In[4]:= Assuming[Element[{x, xP}, Reals], Refine[ Reduce[{Mod[x, 5] == Mod[xP, 5], Mod[xP, 5], 0 <= xP < 5}, {xP}, Backsubstitution -> True]]] Out[4]= xP == x mod 5 === Subject: Re: Graphics export for high quality documents > In the past, I have been using exports to EPS with an embedded preview > so that you have something to look at in Word. Just to reminisce about an old, old glitch relating to exported graphics and embedded previews that I vaguely remember encountering in one of the earliest releases of Mathematica. If I'm recalling it correctly, you could write a graphic, including a preview, from Mathematica to a file. Then you could write a new, changed or updated graphic to the same file name -- and the old embedded preview was left unchanged. You could end up with an graphic file in which the graphic itself and the preview were totally different. But this was a long time ago . . . === Subject: Re: how to specify sheet names in xls export? > is there a way to specify the sheet names when exporting excel xls > spreadsheets? i couldn't find much details in the documentation. my > best attempt so far is: Export[test_sheet_name.xls, Table[100 i + 10 j + k, {i,= 2}, {j, 3}, > {k, 4}], Sheets -> {a, b}] but that doesn't work... any help/suggestions please? Mitch There is an example in the Mathematica documentation that shows how to do this. Look up about export a spreadsheet or look at http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html -- basically you could do m = Table[i - j, {i, 5}, {j, 6}] n = Table[i - j, {i, 3}, {j, 7}] Export[mfile2.xls, {m Data -> m, n Data -> n}] and then the sheets are named m Data and n Data. HTH -Bob === Subject: Re: how to specify sheet names in xls export? Mitch: Mathematica v7 Clear[data]; data = Table[100 i + 10 j + k, {i, 2}, {j, 3}, {k, 4}]; Export[C:test_sheet_name.xls, {sheet1 name here -> data[[1]], sheet2 name here -> data[[2]]}] Please note that there is a tutorial in document center serach howto/ExportASpreadsheet or !(* TagBox[ ButtonBox[ PaneSelectorBox[{ False->, True-> StyleBox[, HyperlinkActive]}, Dynamic[ CurrentValue[MouseOver]], BaseStyle->{Hyperlink}, BaselinePosition->Baseline, FrameMargins->0, ImageSize->Automatic], BaseStyle->Hyperlink, ButtonData->{ URL[http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html ], None}, ButtonNote-> http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html], Annotation[#, http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html, Hyperlink]& ]) simply http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html is there a way to specify the sheet names when exporting excel xls > spreadsheets? i couldn't find much details in the documentation. my > best attempt so far is: Export[test_sheet_name.xls, Table[100 i + 10 j + k, {i, 2}, {j, 3}, > {k, 4}], Sheets -> {a, b}] but that doesn't work... any help/suggestions please? Mitch === Subject: Can't quite figure out tensors I'm trying to write code that will produce Christoffel symbols for various coordinate systems. I would like to use the definition that yields Gamma_ij^k as the partial of the covariant basis e_i with respect to variables x^j dotted with the contravariant vector e^k. So far I have z[r_, theta_] := {r Cos[theta], r Sin[theta]} ei[r_, theta_] := {Derivative[1, 0][z][r, theta], Derivative[0, 1][z][r, theta]} gij[r_, theta_] := ei[r, theta].Transpose[ei[r, theta]] gIJ[r_, theta_] := Inverse[gij[r, theta]] deidxj[r_, theta_] := {Derivative[1, 0][zi][r, theta], Derivative[0, 1][zi][r, theta]} and now i need to form the tensor product deidxj * gIJ * ei and it has proven to be a bit to intense for me to pull off. Could someone show me how to do that? Aaron === Subject: Re: Need some help with monitoring evaluation > This has caused me some consternation in the past. By this I mean that > I make some coding error that causes Mathematica to loop. I would check out: ref/TimeConstrained > ref/Reap > ref/StepMonitor HTH. Roger Williams > Franklin Laboratory > I'm trying to convolve a Rayleigh distribution with a circular > distribution along the x dimension. It simplifies into a Gaussian > convolved with an expression of the form 1/(pi*Sqrt[q^2-x^2]). > * I have looked at StepMonitor, but it only applies to numerical evaluations and is not an option for a symbolic function like InverseFourierTransform. * Since I can't use StepMonitor, I can't see how to take advantage of Sow and Reap * I have also tried to useTimeConstrained, but the function simply returns $Aborted when the time limit is exhausted. * TracePrint and Trace dump too much output; I've tried to specify forms like _Simplify to reduce the output but Simplify isn't used until the end so it doesn't provide intermediate information. * Unless I can up with a meaningful pattern to use with TraceDialog, it's insane how many stops are involved. When I interrupt an evaluation, what can I examine? === Subject: ACA 2009 session call for talks All, I am organizing a session at the 2009 Applications of Computer Algebra conference (ACA 2009). It will take place in Montreal (at Ecole de technologie superieure) during June 25-28. Conference web site: http://aca2009.etsmtl.ca/ Click on Sessions in column on left, and mine will appear as 6. Applications of Math Software to Mathematical Research (Lichtblau) Click on the title and you will see the full session description. The purpose is to highlight various ways in which mathematical software is put to use in the realm of math research. Possibilities include experiment/conjecture, automated and/or assisted proof, development and analysis of algorithms, novel usage for presentation of ones work, etc. Typical sessions at ACA have talks of around 25 minutes. I am soliciting talk proposals for this session. Also please pass this invitation along to colleagues and students who might be interested. Daniel Lichtblau Wolfram Research danl at wolfram dot com === Subject: Re: Eigensystem sometimes returns Out of interest, does anyone know WHY Eigensystem can returns non-orthonormal eigenvectors? The eigenvectors of a matrix are generally NOT orthogonal (since that's what you meant, rather than orthonormal). The eigenvectors ARE usually independent (if the matrix is full rank), so you can transform all of space until they are orthogonal... but that has little to do with the original matrix and its eigensystem. Bobby > h = [a certain 3x3 hermitian matrix] > {u, d} = Eigensystem[h]; d=DiagonalMatrix[d] The eigenvalue equation is satisfied, as per the specifications: > h.Transpose[u] - Transpose[u].d == 0. > The eigenvectors are normalized, but not orthonormal: > u.ConjugateTranspose[u] != IdentityMatrix[3]. > If we compute the q part of the QRDecomposition, q = First@QRDecomposition[u] , then q.ConjugateTranspose[q] == IdentityMatrix[3], but h.Transpose[q] - > Transpose[q].d ==0, > so the eigenvalue equation is no longer satisfied. q =Transpose@First > @QRDecomposition[Transpose@u] doesn't work either. I haven't analysed things in detail, but since the task at hand is to > orthogonalize only the sets of eigenvectors u corresponding to > degenerate > eigenvalues, it may not be safe to use an approach > (Orthogonalize/QRDecomposition) that doesn't know about the pattern of > eigenvalues. Of course one can write a program beginning with > degenEigvalIndices=Split[Sort[d]] > and then calling Orthogonalize within each set, but this is kinda messy. > I'm wondering if it is actually easier to do the calculation in > Fortran/C++ > and use MathLink, somehow. Does Wolfram have any plans to add support > for > orthonormal eigenvectors? Out of interest, does anyone know WHY Eigensystem can returns > non-orthonormal eigenvectors? I was under the impression that > Eigensystem[] > first checks to see if the matrix is Hermitian, and if it is, it uses > LAPACK-based algorithms for Hermitian matrices. I thought LAPACK's > algorithms involved tridiagonalization followed by some form of QR > factorization/divide-and-conquer Givens rotations, in which the > eigenvector > matrix started off as the identity matrix and accumulated successive > unitary > transformations, thus remaining unitary at every stage; I'm curious how > Eigensystem[] even manages to break orthonormality at all. > already normalized --- the problem is that they're not mutually > orthogonal, > which seems to be trickier to fix. > p.p.s. Sorry this post is rather badly written. Maybe when the final > solution appears I will summarize things properly for the benefit of > future > readers. > In Mathematica 7.0.0 (for Linux), calling Eigenvectors[H] or > Eigensystem[H] > for a numerical Hermitian matrix H sometimes returns eigenvectors that > are > not orthonormal. > This happens when some eigenvalues are degenerate. (I can supply > example > code that illustrates the problem, if necessary.) This is not really a bug -- the documentation for Eigensystem[] doesn't > make > any guarantees of orthonormality -- but nevertheless it is an annoying > part > of Mathematica's design. > This issue has been raised 11 years ago ( > http://forums.wolfram.com/mathgroup/archive/1998/Mar/msg00418.html ), > but > that post is corrupted! (Surely Wolfram isn't resorting to > censorship?) > A non-corrupted version is located at the URL below. >> http://forums.wolfram.com/mathgroup/archive/1998/Mar/msg00425.html >> Note that the behavior in that report was of a more serious nature than >> that which you describe (eigenvectors sometimes had complex values). >> I > was hoping that in Mathematica 7 I would be able to write something > like Eigensystem[H, Method->LAPACK-ZHEEVR] or Eigensystem[H, OrthonormalizeEigenvectors->True] but no such options seem to exist. One workaround is to apply > Orthogonalize[] to the matrix of eigenvectors, but the documentation > for > Orthogonalize[] doesn't guarantee that the orthonormalization will only > occur within the degenerate subspace. So one has to resort to > complicated > fixes (e.g., http://arxiv.org/pdf/hep-ph/9607313 ). > Does anyone have a simpler solution? (For example, is there an easy > way > to > call LAPACK'S ZHEEVR routine, which guarantees orthornormal > eigenvectors, > from Mathematica?) Yen Lee Loh > If you apply QRDecomposition to the eigenvectors, then I believe the Q >> part >> will provide what you are looking for. >> Daniel Lichtblau >> Wolfram Research > > -- DrMajorBob@bigfoot.com === Subject: Re: Exporting data into a file, OpenWrite I use either ToFileName or a variant of the following, when I want to capture/create file or directory names: {FileNameSetter[Dynamic@ts, Directory], Dynamic@ts} I never, ever type in the file name by hand, so I never, ever get Windows and Mac conventions confused. Bobby >> no double-slashes for me thank you very much - I've got a Mac. >> 2009/2/24 Sjoerd C. de Vries : > When you use Export, the file will be created in the current >> working directory. > I might add ...unless you include the full path to the file in the > filename (using double slashes to separate directories and files, as a > slash is used as an escape character in strings) > I think correctly you would call the character that you need to use on > Windows a backslash () and that's the one you need to escape, because > it is the escape character in Mathematica. On other systems you will > need other characters for separating directories in pathes, which one is > held in the variable $PathnameSeparator. AFAIK on Windows in many > places within Mathematica a single slash (/) will also work as a > pathname separator in filenames. Probably you shouldn't rely on that but > it's more convenient than the double backslash sometimes. An even better approach is to construct the filename with the function > ToFileName, starting with one of the predefined directory variables you > can find with Information[$*Directory*] > hth, albert > -- DrMajorBob@bigfoot.com === Subject: Re: DiscretePlot > Additionally, you could use ListPlot @ Table[ s[k], {k,1,150} ] or > ListPlot @ Array[s,150]. As I said in my original post, we used ListPlot before v. 7. My point is that DiscretePlot is (or should be) more convenient, since it does not require first making a table. Someone from Wolfram e-mailed me about the Joined->Automatic in DiscretePlot, and perhaps they will change the way it behaves. -- Helen Read University of Vermont === Subject: Re: Galois resolvent So you need these roots? Solve[t^3 + 2 B t^2 + (B^2 - 4 D) t - C^2 == 0, t] {{t -> -((2 B)/3) - (2^(1/3) (-B^2 - 12 D))/( 3 (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) + (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3)/( 3 2^(1/3))}, {t -> -((2 B)/3) + ((1 + I Sqrt[3]) (-B^2 - 12 D))/( 3 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) - ((1 - I Sqrt[3]) (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3))/( 6 2^(1/3))}, {t -> -((2 B)/3) + ((1 - I Sqrt[3]) (-B^2 - 12 D))/( 3 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) - ((1 + I Sqrt[3]) (2 B^3 + 27 C^2 - 72 B D + Sqrt[ 4 (-B^2 - 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3))/( 6 2^(1/3))}} or these? Solve[x^4 + B x^2 + C x + D == 0, x] // Simplify {{x -> (1/( 2 Sqrt[6]))([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) - [Sqrt](-8 B - ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - (12 Sqrt[6] C)/([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3) + 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3)))))}, {x -> (1/( 2 Sqrt[6]))([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) + [Sqrt](-8 B - ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - (12 Sqrt[6] C)/([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3) + 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3)))))}, {x -> -(1/( 2 Sqrt[6]))([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) + [Sqrt](-8 B - ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + (12 Sqrt[6] C)/([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3) + 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3)))))}, {x -> (1/( 2 Sqrt[6]))(-[Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3)) + [Sqrt](-8 B - ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) - 2^( 2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^( 1/3) + (12 Sqrt[6] C)/([Sqrt](-4 B + ( 2 2^(1/3) (B^2 + 12 D))/(2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3) + 2^(2/3) (2 B^3 + 27 C^2 - 72 B D + Sqrt[-4 (B^2 + 12 D)^3 + (2 B^3 + 27 C^2 - 72 B D)^2])^(1/3)))))}} Bobby > R(t) = t^3 + 2B t^2 + (B^2 - 4D)t - C^2 = 0. > -----Original Message----- === > Subject: Re: Galois resolvent The link includes illegible items such as the question marks in R(t) = t^3 + 2B t^2 + (B^2 ? 4D)t ? C^2 = 0. Hence, I have no idea what you're asking. Bobby >> Forthe quartic (*) x^4 + Bx^2 + Cx + D = 0 for integers B, C and D, >> assume that as for the case C = 0 that all its roots are classically >> contructible also for the case C /= 0. >> We can then show that the equation (*) is cyclic (i.e. its Galois >> group = Z4) iff the splitting field of its Descartes resolvent is E = >> Q[Sqrt[t0] /= Q for t0 the one and only integer roots t0 of the >> resolvent. For details, see >> http://mathforum.org/kb/thread.jspa?threadID=1903146. >> If the quartic (*) is cyclic, it should be possible using the above to > explicitly construct the so-called Galois resolvents of (*): The roots > x1, x2, x3 and x4 of the quartic (*) can be given by polynomials of r >> with degree less or equal to 3 with rational coefficients for r an >> arbitrarily root of the quartic. (I.e. the splitting field of the >> quartic (*) when cyclic is Q[r] for r a root.) >> Can somebody, using Mathematica, explicitly determine these polynomial > representations of the roots of the quartic (*). The case C = 0 is > easy. >> But the case C /= 0 is indeed messy. >> Kent Holing, >> NORWAY > > -- > DrMajorBob@bigfoot.com > ------------------------------------------------------------------- > The information contained in this message may be CONFIDENTIAL and is > intended for the addressee only. Any unauthorised use, dissemination of > the > information or copying of this message is prohibited. If you are not the > addressee, please notify the sender immediately by return e-mail and > delete > this message. -- DrMajorBob@bigfoot.com === Subject: Re: Galois resolvent The link includes illegible items such as the question marks in R(t) = t^3 + 2B t^2 + (B^2 ? 4D)t ? C^2 = 0. Hence, I have no idea what you're asking. Bobby > Forthe quartic (*) x^4 + Bx^2 + Cx + D = 0 for integers B, C and D, > assume that as for the case C = 0 that all its roots are classically > contructible also for the case C /= 0. We can then show that the equation (*) is cyclic (i.e. its Galois group > = Z4) iff the splitting field of its Descartes resolvent is E = > Q[Sqrt[t0] /= Q for t0 the one and only integer roots t0 of the > resolvent. For details, see > http://mathforum.org/kb/thread.jspa?threadID=1903146. If the quartic (*) is cyclic, it should be possible using the above to > explicitly construct the so-called Galois resolvents of (*): The roots > x1, x2, x3 and x4 of the quartic (*) can be given by polynomials of r > with degree less or equal to 3 with rational coefficients for r an > arbitrarily root of the quartic. (I.e. the splitting field of the > quartic (*) when cyclic is Q[r] for r a root.) Can somebody, using Mathematica, explicitly determine these polynomial > representations of the roots of the quartic (*). The case C = 0 is easy. > But the case C /= 0 is indeed messy. Kent Holing, > NORWAY > -- DrMajorBob@bigfoot.com === Subject: Re: Galois resolvent R(t) = t^3 + 2B t^2 + (B^2 - 4D)t - C^2 = 0. -----Original Message----- === Subject: Re: Galois resolvent The link includes illegible items such as the question marks in R(t) = t^3 + 2B t^2 + (B^2 ? 4D)t ? C^2 = 0. Hence, I have no idea what you're asking. Bobby > Forthe quartic (*) x^4 + Bx^2 + Cx + D = 0 for integers B, C and D, > assume that as for the case C = 0 that all its roots are classically = > contructible also for the case C /= 0. We can then show that the equation (*) is cyclic (i.e. its Galois > group = Z4) iff the splitting field of its Descartes resolvent is E = = > Q[Sqrt[t0] /= Q for t0 the one and only integer roots t0 of the > resolvent. For details, see > http://mathforum.org/kb/thread.jspa?threadID=1903146. If the quartic (*) is cyclic, it should be possible using the above to > explicitly construct the so-called Galois resolvents of (*): The roots > x1, x2, x3 and x4 of the quartic (*) can be given by polynomials of r > with degree less or equal to 3 with rational coefficients for r an > arbitrarily root of the quartic. (I.e. the splitting field of the > quartic (*) when cyclic is Q[r] for r a root.) Can somebody, using Mathematica, explicitly determine these polynomial > representations of the roots of the quartic (*). The case C = 0 is easy. > But the case C /= 0 is indeed messy. Kent Holing, > NORWAY > -- DrMajorBob@bigfoot.com ------------------------------------------------------------------- The information contained in this message may be CONFIDENTIAL and is intended for the addressee only. Any unauthorised use, dissemination of = the information or copying of this message is prohibited. If you are not the addressee, please notify the sender immediately by return e-mail and = delete this message. === Subject: Re: Setting global Plot font options Plot[Sin[x], {x, 0, 2 Pi}, Frame -> True, FrameLabel -> {x, Sin[x]}, BaseStyle -> {FontFamily -> Helvetica, FontSize -> 16}] or SetOptions[ #, BaseStyle -> {FontFamily -> Helvetica, FontSize -> 16}] & /@ {Plot,ListPlot}; Jens > Hi - > Where can I set the global default font for plot objects? I'd like > AxesLabel, FrameLabel, PlotLegend, and the Ticks to all be the same > font without having to specify it in the Plot call every time. > TIA, > Matt > === Subject: Re: lock image size in a cell Alessandro, > often evaluating functions that output images as a result, I re- > evaluate an input cell many times, fine tuning its parameters. > Since the images I process are large, I manually resize the image > output to visually inspect it. Re-evaluating the input, the output > doesnt remember my manually-set size. > > There is a way to lock this cell size - just for display (I dont want > to effectively resize the image) ? > > > alessandro magni Would the ImageSize option work for your case? Instead of: outputimage = F[input] Try: outputimage = Image[F[input], ImageSize -> 400] You can always reset the option later: outputimage = Image[outputimage, ImageSize -> Automatic] Matthias Odisio Wolfram Research === Subject: Re: newbie: programmatic sequence of plots? > Loops themselves only have a null return value. Doh! I was assuming ListPlot would have a side effect. > return a list of these plots additionaly or instead of just > printing them, so that you can use ListAnimation or TabView or > whatever you like for displaying them. And the way to do that is > Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; > a = 3.5; > nRecurr = 50; > yinit = 0.1; > yinc = 0.01; > yfinal = 0.2; > out = {}; (* modification here *) > For[y0 = yinit, y0 <= yfinal, y0 += yinc, > AppendTo[out, (* modification here *) > ListPlot[ > RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, > y, {n, 1, nRecurr}]]]; > ]; > out (* modification here *) So I modified that to do For[y0 = yinit, y0 <= yfinal, y0 += yinc, AppendTo[out, ListPlot[ RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, y, {n, 1, nRecurr}], Joined -> True ] ]; ]; ListAnimate[out] which is even better than printing a list of static plots. === Subject: Re: newbie: how to define, typeset a multi-rule function? Tom Roche Feb 24, 5:46 am (rearranged) >> For an example in a math layout, I can almost typeset the function >> in OpenOffice Math like f_x(%chi) = left lbrace stack {k if %chi in >> [0,1] # 0 otherwise} right rbrace (except that I don't want the >> closing brace, but that's another problem). I tried to create this >> using the palettes, but I didn't see one that did multiline >> brackets. or Piecewise brackets. Gotta learn the terminology! > Formatting/entry goes like this: Use Esc pw Esc to enter { i.e. that brings up the piecewise bracket > and Ctrl+Comma i.e. having typed the return value of the first case (e.g. k), type C-, to type the conditions for the first case (e.g. 0 <= [Chi] <= 1) > and then Ctrl+Enter for each additional piecewise case === Subject: Re: Bug in Export to HTML in v7? It works for me. It might be the final slash in your filename. On your platform I guess this makes the file name a directory name? > The following very handy code to save a notebook as HTML and to follow > closed links used to work in v6 no longer works in v7. Was wondering > if there is a workaround: Export[~/tmp/, EvaluationNotebook[], HTML, > ConvertClosed -> LinkedPage]; (I put this code is in the notebook I am saving itself so it appears > in the HTML output, which is OK). === Subject: Show problem: combining ListPlot and Plot The following extract exemplifies a plot technique I used to combine ListPlot and a Plot under v 2.2. It worked fine under 3.0, 4.1,4.2 and 5.1. But students using this under 6.0 and 7.0 for a HW report the plot frame squished, and that line colors disagree with the title. Question: can this be fixed in DisplayChannel=$DisplayFunction; If [$VersionNumber>=6.0, DisplayChannel=Print]; (* fix for Mathematica 6 & later *) Off[General::spell1]; Off[General::spell]; ClearAll[r]; vFEM={{4., 0.054}, {7., 0.0395}, {10., 0.037}}; vexact=0.1905*(1/r + r/100); rbeg=4.; rend=10.; pFEM=ListPlot[vFEM,PlotJoined->True,PlotStyle->{RGBColor[1,0,0]}, DisplayFunction->Identity]; pexact=Plot[vexact,{r,rbeg,rend},PlotStyle->{RGBColor[0,0,0]}, DisplayFunction->Identity]; Show[Graphics[AbsoluteThickness[2]],pexact, pFEM,TextStyle->{FontFamily->Times,FontSize->12}, GridLines->Automatic,Axes->True,PlotRange->All, PlotLabel->Radial displacement (black=exact,red=FEM), Frame->True, DisplayFunction->DisplayChannel]; === Subject: Re: Licenses for Sharing Notebooks Hi Hans, what is wrong with public software. I think it hinders development if everybody tries to conceal their work. I got the impression that the less qualified people are, the more energy they spend on licensing and encryption. Daniel > I was wondering what kind of licenses are commonly used to distribute > and share Mathematica notebooks, such as tutorials and interactive > lecture notes, without completely setting them into public domain. > focus on compiled binaries do not really seem to be appropriate. Maybe > the different variations of Creative Commons Licenses [http:// > creativecommons.org/license/] are a better fit? Could people in this > group share if and why they selected a specific license in a similar > siutation? Hans-Martin > === Subject: Re: About Reduce and Mod Mathematica calculates by default with complex number. You must tell it that you are looking for real numbers by e.g. specifying a domain: Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Reals, Backsubstitution -> True] hope this helps, Daniel > Hi Mathematica community, > I have this input: Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, > {xP}, Backsubstitution -> True] > Mathematicas gives me this output:0 <= Re[Mod[x, 5]] < 5 && Im[Mod[x, > 5]] == 0 && xP == Mod[x, 5] > 1)but why there is 0 <= Re[Mod[x, 5]] < 5 && Im[Mod[x, 5]] == 0 as > part of the output ? > 2) and how could I eliminate it (by adding something in reduce for > example) because all that I want is only this output xP == Mod[x, 5]? thank you very much. > === Subject: Re: About Reduce and Mod FullSimplify[ Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, {xP}, Backsubstitution -> True], Element[x, Reals]] ?? Jens > Hi Mathematica community, > I have this input: Reduce[{Mod[x, 5] == Mod[xP, 5], 0 <= xP < 5}, > {xP}, Backsubstitution -> True] > Mathematicas gives me this output:0 <= Re[Mod[x, 5]] < 5 && Im[Mod[x, > 5]] == 0 && xP == Mod[x, 5] > 1)but why there is 0 <= Re[Mod[x, 5]] < 5 && Im[Mod[x, 5]] == 0 as > part of the output ? > 2) and how could I eliminate it (by adding something in reduce for > example) because all that I want is only this output xP == Mod[x, 5]? thank you very much. > === Subject: Re: newbie: diff equation Hi Mike, obviously f==0 is the correct generic solution. What you are looking for is a singular case for m== Integer. Therefore, you must give m explicitly. But then the problem is not fully specified, we may e.g. aditionally specify f'[0]: DSolve[{f''[x] == -9 f[x], f[0] == 0, f[Pi] == 0, f'[0] == 1}, f[x],x] hope this helps, Daniel I want to solve f''[x]= - m^2 f[x] with f[0] = 0 and f[Pi] = 0 this is obviously only solvable with the condition on m being integer but if I do DSolve on the above with the boundary conditions I just get f=0. How can I get mathematica to solve this and give me the conditions on m? I need to solve much more general problems of this type. I hope someone can help. > === Subject: Re: newbie: diff equation you can't, because this is a eigenvalue problem and *not* a differential equation. An eigenvalue problem has either none or an infinite number of solutions and Mathematica gives you the none solution, especial because it would take to long to print out the infinite number of solutions. In QM you take one of the infinite solutions and normalize it. And you have to do it manual in Mathematica. Jens I want to solve f''[x]= - m^2 f[x] with f[0] = 0 and f[Pi] = 0 this is obviously only solvable with the condition on m being integer but if I do DSolve on the above with the boundary conditions I just get f=0. How can I get mathematica to solve this and give me the conditions on m? I need to solve much more general problems of this type. I hope someone can help. > === Subject: Re: newbie: diff equation You have to use two equals signs instead of one when inputting a differential equation. -----Original Message----- === Subject: newbie: diff equation My problem is very simple, I'm sure someone can help me out quickly. I am in a box (QM) so I started with this basic problem which I know how to solve just to make sure I am entering everything ok, but I can't even get it to work. I want to solve f''[x]= - m^2 f[x] with f[0] = 0 and f[Pi] = 0 this is obviously only solvable with the condition on m being integer but if I do DSolve on the above with the boundary conditions I just get f=0. How can I get mathematica to solve this and give me the conditions on m? I need to solve much more general problems of this type. I hope someone can help. === Subject: Re: newbie: diff equation You're asking DSolve to do its own work and the work of Solve, at the same time. Try it with fewer conditions: DSolve[f''[x] == -m^2 f[x], f, x] {{f -> Function[{x}, C[1] Cos[m x] + C[2] Sin[m x]]}} or Clear[f] f[x_] = f[x] /. Last@DSolve[f''[x] == -m^2 f[x], f, x]; Reduce[{f[0] == 0, f[Pi] == 0}, {C[0], C[1], m}] (C[3] [Element] Integers && ((C[2] != 0 && C[1] == 0 && m == 2 C[3]) || (C[1] == 0 && m == 1 + 2 C[3]))) || ((-[Pi] + m [Pi])/(2 [Pi]) [NotElement] Integers && C[2] == 0 && C[1] == 0) or Clear[f] f[x_] = f[x] /. Last@DSolve[{f''[x] == -m^2 f[x], f[0] == 0}, f[x], x] Reduce[f[Pi] == 0, {m}] // Simplify C[2] Sin[m x] (C[1] [Element] Integers && (m == 2 C[1] || m == 1 + 2 C[1])) || C[2] == 0 Unless C[2] == 0, that works out to mean m is an integer, but... as you can see... Mathematica somehow isn't able to straightforwardly say so. Bobby > My problem is very simple, I'm sure someone can help me out quickly. I > am trying to solve some systems of differential equations a bit like a > how to solve just to make sure I am entering everything ok, but I can't > even get it to work. I want to solve f''[x]= - m^2 f[x] with f[0] = 0 and f[Pi] = 0 this is obviously only solvable with the condition on m being integer > but if I do DSolve on the above with the boundary conditions I just get > f=0. How can I get mathematica to solve this and give me the conditions > on m? I need to solve much more general problems of this type. I hope > someone can help. > -- DrMajorBob@bigfoot.com === Subject: Re: Experimental Mathematica debugger Hi David, another great addition from you, thank's a lot. There is a samll bug with the conditional break point window. It is not possible to input any text because it does not take the focus. I have Mathematica version 7 on Vista. thank's again, Daniel > I have been fairly dissatisfied with the built-in debugger available in > versions 6 and 7, and I would like people to try an experimental new > debugger for an earlier version of Mathematica - called M-Debug. That > debugger was based on TraceScan, and was unable to locate Mathematica > expressions within the original source code. It was also very slow when > code was executing to a breakpoint. DebugTrace works in a new way, identifying program locations using line > numbers which double as breakpoint toggle buttons! I work as a consultant, and in my experience, projects often start with > a very large notebook, full of unstructured code, which it is necessary > to understand. Beginners typically write programs in this style - often > without a single user-defined function - and DebugTrace can operate well > on this kind of code, as well as more elegant code and also packages. DebugTrace is a Mathematica program like any other - i.e. it operates > without any kernel hacks, but this means that it is fairly easy to add > support for particular pieces of software. For example the debugger > knows about my Super Widget Package, and when appropriate, it displays > an extra button that enables the debugger to gain control while a modal > Java window is being displayed (without closing the window). I imagine > that this flexibility may be useful in other contexts. Another revolutionary feature of DebugTrace, is that it comes with > actual documentation, illustrated with a small example program! DebugTrace version 0.95 is available free from my website. It will > remain free even after it is polished. If you find specific problems, it > might be best to e-mail me directly with a simple example. As I say, this project is experimental, and its future development - if > any - depends on the feedback I receive. > David Bailey > http://www.dbaileyconsultancy.co.uk === Subject: Re: Eigensystem[hermitianMatrix]sometimes returns Hi Bob, perhaps you may mean: Orthogonalization. Normalization does not make vectors orthogonal. But then one has to make sure that eigenvectors belonging to different eigenvalues get not mixed up. The default method Gram-Schmidt should work in this case, but I did not try this out. hope this helps, Daniel Daniel > I suppose the simplest thing is Normalize/@Eigenvalues[m] or {First@#,Normalize/@Last@#}&@Eigensystem[m] Bobby >> In Mathematica 7.0.0 (for Linux), calling Eigenvectors[H] or >> Eigensystem[H] >> for a numerical Hermitian matrix H sometimes returns eigenvectors that >> are >> not orthonormal. >> This happens when some eigenvalues are degenerate. (I can supply example >> code that illustrates the problem, if necessary.) >> This is not really a bug -- the documentation for Eigensystem[] doesn't >> make >> any guarantees of orthonormality -- but nevertheless it is an annoying >> part >> of Mathematica's design. >> This issue has been raised 11 years ago ( >> http://forums.wolfram.com/mathgroup/archive/1998/Mar/msg00418.html ), but >> that post is corrupted! (Surely Wolfram isn't resorting to >> censorship?) I >> was hoping that in Mathematica 7 I would be able to write something like >> Eigensystem[H, Method->LAPACK-ZHEEVR] >> or >> Eigensystem[H, OrthonormalizeEigenvectors->True] >> but no such options seem to exist. One workaround is to apply >> Orthogonalize[] to the matrix of eigenvectors, but the documentation for >> Orthogonalize[] doesn't guarantee that the orthonormalization will only >> occur within the degenerate subspace. So one has to resort to >> complicated >> fixes (e.g., http://arxiv.org/pdf/hep-ph/9607313 ). >> Does anyone have a simpler solution? (For example, is there an easy way >> to >> call LAPACK'S ZHEEVR routine, which guarantees orthornormal eigenvectors, >> from Mathematica?) >> Yen Lee Loh > === Subject: Re: Eigensystem[hermitianMatrix]sometimes returns you want to Normalize/@Eigenvalues[m] and not the eigenvectors ?? Jens BTW: What helps the normalization when the vectors are not orthogonal ? > I suppose the simplest thing is Normalize/@Eigenvalues[m] or {First@#,Normalize/@Last@#}&@Eigensystem[m] Bobby >> In Mathematica 7.0.0 (for Linux), calling Eigenvectors[H] or >> Eigensystem[H] >> for a numerical Hermitian matrix H sometimes returns eigenvectors that >> are >> not orthonormal. >> This happens when some eigenvalues are degenerate. (I can supply example >> code that illustrates the problem, if necessary.) >> This is not really a bug -- the documentation for Eigensystem[] doesn't >> make >> any guarantees of orthonormality -- but nevertheless it is an annoying >> part >> of Mathematica's design. >> This issue has been raised 11 years ago ( >> http://forums.wolfram.com/mathgroup/archive/1998/Mar/msg00418.html ), but >> that post is corrupted! (Surely Wolfram isn't resorting to >> censorship?) I >> was hoping that in Mathematica 7 I would be able to write something like >> Eigensystem[H, Method->LAPACK-ZHEEVR] >> or >> Eigensystem[H, OrthonormalizeEigenvectors->True] >> but no such options seem to exist. One workaround is to apply >> Orthogonalize[] to the matrix of eigenvectors, but the documentation for >> Orthogonalize[] doesn't guarantee that the orthonormalization will only >> occur within the degenerate subspace. So one has to resort to >> complicated >> fixes (e.g., http://arxiv.org/pdf/hep-ph/9607313 ). >> Does anyone have a simpler solution? (For example, is there an easy way >> to >> call LAPACK'S ZHEEVR routine, which guarantees orthornormal eigenvectors, >> from Mathematica?) >> Yen Lee Loh > === Subject: how to solve 2-variable recurrence equation for a[m.n] a[m,n] = a[m-1,n] + a[m-1,n-1] + a[m,n-1] , m<=n a[0,0] =1, a[0,n]=1,a[1,1]=2 how to solve? === Subject: Re: Map and functional constructs to replace iterative statements > I have begun to replace Table, Do, While, or For, but in my thinking with= Map, Inner, Outer and other functional programming constructs as I learn m= ore about Mathematica. But, I'm stuck. I need to figure out how to use Map (or some related a= pproach) when a function needs both a current value and a previous value in= a time series, such as a percentage change function (or perhaps more gener= ally stated, when I need to refer to previous values in a series or even pr= evious calculations). But first a simple case: percentChange[currentValue_, previousValue_] := 100 * ( currentValue - = previousValue) / previousValue I know how to apply this iteratively, but how can I do it with Map or som= e other functional construct? Say I have a list: timeSeries I thought to try something like this: Map[percentChange[?,?], timeSeries] but I don't know how what to put in for ?. Any help much appreciated. Thx. Daniel's solution is probably the best in terms of simplicity but this seems to be slightly faster: 100*Differences[d]/Most[d] I had initially thought of ListCorrelate which also gives a fast reply with large data sets: 100*ListCorrelate[{-1, 1}, d]/Most[d]; Trying to get it all to happen within a single function only slowed things down: gg[x_, y_] := y/x - 1 100*ListCorrelate[{1, 1}, ls, {1, -1}, 0, Times, gg] (far too much happening to slow things down) Mike === Subject: Dificulty on Integrate function! I got a problem in integrating the expression (given below in input form) on Mathematica. Please give me some hints or a way around to get the solutions. . I want to integrate the equation with respect to b, c, and d. So that I get an equation only in terms of t and a. I tried to use Integrate function in Mathematica both in the form of definite and indefinite integral but it could not turn out the result. If the indefinite integral is not working the ranges of integration for definite integral shall be the following {b, 0, 170}, {c, 0, 400} and {d, 0,170}. (5.985857026794833*^-14*(14 + c)^2.37*E^(-0.0003630681026445808* (-50.29 + b)^2 - c/41 - 0.0003125*(-43.7 + d)^2 - b/d + t/d - 1.1985780806058064*^-6*(-3535.42 + c + ((a - c)*E^((-b + t)/d))/(t/b)^ (b/d))^2))/(t/b)^(b/d) Please please help me. If I could not get this solution I have to discard so many things I spent considerable time on! Negede === Subject: Re: AbsoluteOptions and ViewMatrix The docs page on ViewMatrix states: With the setting ViewMatrix->Automatic, explicit forms for the matrix m can be found using AbsoluteOptions[g,ViewMatrix]. However, as you mentioned this does not work and the docs are evidently wrong here. I tried everything I could think of, but this is a hard nut to crack. > When viewing any graphics such as: s=PolyhedronData[Dodecahedron]; AbsoluteOption works as advertised with PlotRange, but not ViewMatrix: AbsoluteOptions[s,PlotRange] (* give you the actual plot range, no= t > All *) AbsoluteOptions[s,ViewMatrix] (* give you Automatic, not the > actual value *) I understand that the actual PlotRange value is known to the kernel, > but not the ViewMatrix, which is handled in the notebook. Does anybody know how to get the ViewMatrix value out of the Notebook? Sebastien === Subject: Re: Transparent background with PNG > how can I save an image to PNG format (eg. a simple plot), with the > (white) background being transparent? I understand that PNG export > supports alpha channel, but have no clue how to instruct Mathematica > to exploit it. g = Plot[Sin[x], {x, 0, 2 Pi}] Export[~/Desktop/plot.png, g, Background -> None] -Rob === Subject: Re: Transparent background with PNG how can I save an image to PNG format (eg. a simple plot), with the > (white) background being transparent? I understand that PNG export > supports alpha channel, but have no clue how to instruct Mathematica > to exploit it. > Istvan Zachar Export[/1.png, Plot[x, {x, 0, 1}], Background -> None] Maxim Rytin m.r@inbox.ru === Subject: Re: Transparent background with PNG Try gr = Rasterize[expr, Background->None] (documented) Export[file.png, gr] Your expr needs to be something that can rasterized, such as a Graphics expression. Rasterizing something that's already a raster (Graphics[Raster[...]]) or Image expression is not going to work. An undocumented shortcut: Export[file.png, expr, Background->None] will do the same thing. Igor how can I save an image toPNGformat (eg. a simple plot), with the > (white) background being transparent? I understand thatPNGexport > supports alpha channel, but have no clue how to instruct Mathematica > to exploit it. > Istvan Zachar === Subject: Re: Transparent background with PNG how can I save an image to PNG format (eg. a simple plot), with the > (white) background being transparent? I understand that PNG export > supports alpha channel, but have no clue how to instruct Mathematica > to exploit it. This seems to be excessively obscure, but I got a png with a transparent background this way (in V7): plotImage = Plot[x^2, {x, 0, 2}] bkgImage = Image[ConstantArray[{0., 0., 0., 0.}, Reverse[ImageDimensions[plotImage]]], ColorSpace -> RGB] compImage = ImageCompose[bkgImage, plotImage] Export[~/Desktop/compImage.png, compImage] It seems that composing the graphic against a transparent image gives it an alpha channel. === Subject: Re: Transparent background with PNG img = Rasterize[Plot[Sin[x], {x, 0, 2 Pi}], Image]; and timg = ImageApply[ If[Sqrt[#.#] &[# - {1, 1, 1}] < $MachineEpsilon, Append[#, 0], Append[#, 1]] &, img] has an alpha channel. Jens > No idea? > === Subject: Re: Transparent background with PNG > No idea? In Mathematica 7, use something like Export[picture.png, %, ImageSize -> 600, Background -> None] I keep forgetting this syntax too (it's different between versions and http://www.uoregon.edu/~noeckel/MathematicaGraphics.html#ExportOpacity Jens === Subject: procedures Simple question: how can I in mathematica write a complex function? What I need to do is (pseudocode) FunctionToCode[x,n] { D[x_,n]:= something symbolic Do[ D[x,s]=D[x,s], {s,0,n} ]; return D[x,s] Clear[D] } Davide === Subject: How to Export the Manipulate Hi ,all i usually use Export[*.gif,Table[Graphics[]]] to generate a GIF figure, but dont know how to Export the Manipulate produced animations,can someone here drop me a hint ? Wayne. === Subject: question about simplify function This seems like a basic question, but I can't see the answer: Why doesn't either the Simplify or FullSimplify function transform the expression x/(xy) into 1/y? When I substitute a specific value in for x, the simplification occurs as expected, e.g., 4/(4y) transforms to 1/ y. Puzzling. Jack === Subject: Re: Map and functional constructs to replace iterative statements Many many thx for a host of interesting solutions and approaches to the problem. The feedback on my question has really helped me think about ways to use Mathematica in a more and more elegant way. I can now rewrite tons of code and have better, clearer, and much faster solutions. For the question I originally posed, I've settled on a combination of the offered solutions: timeSeries = {100., 102., 103., 104., 105.}; 100 Differences[timeSeries]/Most[timeSeries] Simple,clear, and works like a charm. P.S. I'm sure to have more questions (lots more questions)for the forum, stay tuned. === Subject: Re: About Reduce and Mod >I have this input: Reduce[{Mod[x, 5] == >Mod[xP, 5], 0 <= xP < 5}, {xP}, Backsubstitution -> True] >Mathematicas gives me this output:0 <= Re[Mod[x, 5]] < 5 && >Im[Mod[x, 5]] == 0 && xP == Mod[x, 5] 1)but why there is 0 <= >Re[Mod[x, 5]] < 5 && Im[Mod[x, 5]] == 0 as part of the output ? Mathematica by default assumes all variables can take on complex values. The output is specifying the conditions on a complex variable needed to make the equality hold. >2) and how could I eliminate it (by adding something in reduce for >example) because all that I want is only this output xP == Mod[x, 5]? In[4]:= Assuming[Element[{x, xP}, Reals], Refine[ Reduce[{Mod[x, 5] == Mod[xP, 5], Mod[xP, 5], 0 <= xP < 5}, {xP}, Backsubstitution -> True]]] Out[4]= xP == x mod 5 === Subject: Re: Graphics export for high quality documents > In the past, I have been using exports to EPS with an embedded preview > so that you have something to look at in Word. Just to reminisce about an old, old glitch relating to exported graphics and embedded previews that I vaguely remember encountering in one of the earliest releases of Mathematica. If I'm recalling it correctly, you could write a graphic, including a preview, from Mathematica to a file. Then you could write a new, changed or updated graphic to the same file name -- and the old embedded preview was left unchanged. You could end up with an graphic file in which the graphic itself and the preview were totally different. But this was a long time ago . . . === Subject: Re: how to specify sheet names in xls export? > is there a way to specify the sheet names when exporting excel xls > spreadsheets? i couldn't find much details in the documentation. my > best attempt so far is: Export[test_sheet_name.xls, Table[100 i + 10 j + k, {i,= 2}, {j, 3}, > {k, 4}], Sheets -> {a, b}] but that doesn't work... any help/suggestions please? Mitch There is an example in the Mathematica documentation that shows how to do this. Look up about export a spreadsheet or look at http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html -- basically you could do m = Table[i - j, {i, 5}, {j, 6}] n = Table[i - j, {i, 3}, {j, 7}] Export[mfile2.xls, {m Data -> m, n Data -> n}] and then the sheets are named m Data and n Data. HTH -Bob === Subject: Re: how to specify sheet names in xls export? Mitch: Mathematica v7 Clear[data]; data = Table[100 i + 10 j + k, {i, 2}, {j, 3}, {k, 4}]; Export[C:test_sheet_name.xls, {sheet1 name here -> data[[1]], sheet2 name here -> data[[2]]}] Please note that there is a tutorial in document center serach howto/ExportASpreadsheet or !(* TagBox[ ButtonBox[ PaneSelectorBox[{ False->, True-> StyleBox[, HyperlinkActive]}, Dynamic[ CurrentValue[MouseOver]], BaseStyle->{Hyperlink}, BaselinePosition->Baseline, FrameMargins->0, ImageSize->Automatic], BaseStyle->Hyperlink, ButtonData->{ URL[http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html ], None}, ButtonNote-> http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html], Annotation[#, http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html, Hyperlink]& ]) simply http://reference.wolfram.com/mathematica/howto/ExportASpreadsheet.html is there a way to specify the sheet names when exporting excel xls > spreadsheets? i couldn't find much details in the documentation. my > best attempt so far is: Export[test_sheet_name.xls, Table[100 i + 10 j + k, {i, 2}, {j, 3}, > {k, 4}], Sheets -> {a, b}] but that doesn't work... any help/suggestions please? Mitch === Subject: Can't quite figure out tensors I'm trying to write code that will produce Christoffel symbols for various coordinate systems. I would like to use the definition that yields Gamma_ij^k as the partial of the covariant basis e_i with respect to variables x^j dotted with the contravariant vector e^k. So far I have z[r_, theta_] := {r Cos[theta], r Sin[theta]} ei[r_, theta_] := {Derivative[1, 0][z][r, theta], Derivative[0, 1][z][r, theta]} gij[r_, theta_] := ei[r, theta].Transpose[ei[r, theta]] gIJ[r_, theta_] := Inverse[gij[r, theta]] deidxj[r_, theta_] := {Derivative[1, 0][zi][r, theta], Derivative[0, 1][zi][r, theta]} and now i need to form the tensor product deidxj * gIJ * ei and it has proven to be a bit to intense for me to pull off. Could someone show me how to do that? Aaron === Subject: Re: Maintaining a Mathematica bug list > I think this is the case of the perfect being the enemy of the useful. It is > not so important that every single bug be in a maintained bug list for > users. It is more important that major new bugs that affect a large number > of users be on a list. I could see a useful bug list being less than a few > dozen items. If some relatively savvy Mathematica user wanted to maintain > such a list they might publish it on MathGroup once a week, say. They might > pick up the bugs from MathGroup, or once they became known, users might send > bugs to them directly. But if it is something obscure and difficult to > verify the list maintainer shouldn't be expected to spend a lot of time > checking it, or put it on the list. Sometimes he might just say that > so-and-so reported trouble with such-and-such a function. Sometimes WRI > might even send him bugs, or comment or correct the list. A short list of high impact bugs would be useful. Agreed David However, these high impact bugs are likely to be well publicised already. A Google search will probably find many of these. College lecturers are likely to know of them. I would expect them to be on the WRI support pages too. > A long exhaustive list > with deep analysis and verification would be too much work. It's clear that any attempt to thoroughly analyse a long list of obscure bugs would need a lot of time dedicated by experts, and nobody other than WRI are going to be able to do that. I think it is equally obvious that WRI are not likely to make such a list public. However, there would in my opinion be a use for a collection of 'reported/unverified bugs'. User 'A' just lists what they thinks is a bug, and user 'B' can believe or disbelieve as they see fit. User 'C' could add a comment like this is a usage error, you should use Sin[x] not sin(x) or similar. With a bit of luck, someone from WRI might comment, but it could not be expected. I've stuck a few Solaris-specific Mathematica bugs I've come across over the years at http://www.g8wrb.org/mathematica/ Ignoring the first few, which are only telling you what is already in the documentation, I believe 5 of those: 1) Mathematica 5.x using excessive CPU time on Solaris 10. 2) Mathematica uses excessive CPU time on multi-processor machines 3) Mathematica 6.0.1 or 6.0.2 has some characters unreadable 4) Mathematica fails to determine the number of CPUs correctly on SPARC 5) Mathematica crashes on Solaris x86 with an Intel CPU are listed with sufficient detail to enable someone to decide if they believe them or not. The 3rd of these affects Linux too, the 5th is not a bug, but a workaround of how to get Mathematica working on a Solaris made them aware how to solve the Intel issue). In my opinion, bug reports in that form are useful. The problem is that to make best use, they would need being in a searchable database. This would probably be software like Bugzilla with a mySQL backend. I think it is fair to say a typical Mathematica user is likely to be of above average intelligence, so hopefully would be able to write a bug report in a reasonably useful manner. You also need to consider that students working on college licenses don't (officially at least) have direct access to WRI support, but need to go via a university contact. Home use licenses in the US will have limited technical support (no option for premier service). A searchable public list might be particularly useful to that group. If anyone did set up a decent bug database, they would need to consider * You can be sure someone is going to post an attachment which is a PHP script which attempts to hack your web server. * Someone will try to upload a root-kit (or whatever the Windows equivalent is). * A hacker will attempt to exploit security issues in the bug database software (Bugzilla or similar). So effort would be needed to keep that up to date. * Someone will attempt to exploit bugs in web server software (Apache etc) * Someone will attempt to upload porn. * Someone will attempt to upload viruses. I think setting up the database and subsequent security maintenance would be the time-consuming things - not verifying the bugs, which I believe would be impractical and unnecessary. One final issue, WRI might object to a public bug list. I personally don't feel they should, but they might do, claiming it is hurting their product to have reports of bugs that are not bugs, but user errors. They could threaten legal action if someone did not take it down. I *very* doubt that would happen, as I suspect it would do them more harm than good and give their competitors something to shout about, but it just possibly could happen. Dave === Subject: Re: Reading in an ASCII file written by a FORTRAN program > Hello All: I didn't want to hijack another's thread about reading in fixed format > files into Mathematica and I was wondering if there is a way to read > FORTRAN written data. For my thesis used FORTRAN code for my number > crunching, and used function calls to DISLIN to visualize that data. > Now I have Mathematica, whose graphics capabilities are well beyond > anything I could previously do, I would like to recreate and improve > those graphs. The way I created the files of data (which I always used > a .d extension, but it doesn't matter what that would be called) is > demonstrated below. Please note, this is NOT binary data, but text > output with no FORMAT. For example: > open(unit=30,name=fnout,status='old') write(30,'(a20)') fnmod > write(30,'(a20)') fnstr > write(30,*) nfault,hpl,vplx,vply,taua,tauf,amuu, > & tminn,tstepp,itime,TBIS,bulkms,ntm,ncycle,pdcy > write(30,*) ptrad > write(30,'(a1)') respfb > write(30,*) (timi(n), n=1,nfault) > write(30,*) (taub(n), n=1,nfault) > write(30,*) (delts(n), n=1,nf) > write(30,*) (cfr(n), n=1,nfault) > write(30,*) (dfr(n), n=1,nfault) > write(30,*) (slpdf(n), n=1,nf2) > write(30,*) (slpv(n), n=1,nfault) > write(30,*) (rhofcc(n), n=1,nfault) > write(30,*) (islip(n), n=1,nfault) (NOTE: not all variables are the same length, some are strings, some > doubles, etc.) I subsequently read back the data into FORTRAN as: open(unit=30,name=fnin,status='old') read(30,'(a20)') fnmod > read(30,'(a20)') fnstr > read(30,*) nfault,hpl,vplx,vply,taua,tauf,amuu, > & tminn,tstepp,ntime,TBIS,bulkms,ntm,ncycle,pdcy > read(30,*) ptrad > read(30,'(a1)') respfb > read(30,*) (timi(n), n=1,nfault) > read(30,*) (taub(n), n=1,nfault) > read(30,*) (delts(n), n=1,nf) > read(30,*) (cfr(n), n=1,nfault) > read(30,*) (dfr(n), n=1,nfault) > read(30,*) (slpdf(n), n=1,nf2) > read(30,*) (slpv(n), n=1,nfault) > read(30,*) (rhofcc(n), n=1,nfault) > read(30,*) (islip(n), n=1,nfault) So, the big question then is: How would I go about reading in the > above unformatted Fortran file within Mathematica? t. > Yes, any text data can be read into Mathematica. As a last resort, one can always read such a file as a List of strings and manipulate the strings to extract the data you require. However, this is always a last resort, and not necessary here. First open the file: str=OpenRead[c:myfile]; Now read the two character variables: fnmod=Read[str,Record]; tnstr=Read[str,Record]; (You may need to remove trailing spaces in these variables using StringTrim). Note that if you print out FullForm[fnmod] you will see exactly what characters are in the string. It may be easiest to read the rest one number at a time: x=Read[str,Number]; Note that all numbers will end up as Double Precision inside Mathematica. Since you didn't include any declarations in your code, it is not possible to determine if any of those arrays are CHARACTER variables, but hopefully you have the general idea by now. Remember that you can always read tricky bits as strings, and then pull the strings apart in Mathematica. The ToExpression function may be useful to convert a string into a number (say). Don't for get to close the stream when you are done: Close[str]; David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Reading in an ASCII file written by a FORTRAN program OpenRead is exactly what I'm looking for. And yes I do know which are strings, doubles, integers, etc. Perhaps I'm dating myself here, but FORTRAN 77 uses implicit declaration of names with i-n being integers so I can figure it out (this was relaxed in FORTRAN 90 but I find I still use many of the same naming conventions). The real problem was I couldn't figure out how to get Import to know where it was when reading in the file and was treating it as a one-shot lump Read. Of course, it seems now that is why Mathematica has things like OpenRead! t. > Hello All: I didn't want to hijack another's thread about reading in fixed format > files into Mathematica and I was wondering if there is a way to read > FORTRAN written data. For my thesis used FORTRAN code for my number > crunching, and used function calls to DISLIN to visualize that data. > Now I have Mathematica, whose graphics capabilities are well beyond > anything I could previously do, I would like to recreate and improve > those graphs. The way I created the files of data (which I always used > a .d extension, but it doesn't matter what that would be called) is > demonstrated below. Please note, this is NOT binary data, but text > output with no FORMAT. For example: > open(unit=30,name=fnout,status='old') write(30,'(a20)') fnmod > write(30,'(a20)') fnstr > write(30,*) nfault,hpl,vplx,vply,taua,tauf,amuu, > & tminn,tstepp,itime,TBIS,bulkms,ntm,ncycle,pdcy > write(30,*) ptrad > write(30,'(a1)') respfb > write(30,*) (timi(n), n=1,nfault) > write(30,*) (taub(n), n=1,nfault) > write(30,*) (delts(n), n=1,nf) > write(30,*) (cfr(n), n=1,nfault) > write(30,*) (dfr(n), n=1,nfault) > write(30,*) (slpdf(n), n=1,nf2) > write(30,*) (slpv(n), n=1,nfault) > write(30,*) (rhofcc(n), n=1,nfault) > write(30,*) (islip(n), n=1,nfault) (NOTE: not all variables are the same length, some are strings, some > doubles, etc.) I subsequently read back the data into FORTRAN as: open(unit=30,name=fnin,status='old') read(30,'(a20)') fnmod > read(30,'(a20)') fnstr > read(30,*) nfault,hpl,vplx,vply,taua,tauf,amuu, > & tminn,tstepp,ntime,TBIS,bulkms,ntm,ncycle,pdcy > read(30,*) ptrad > read(30,'(a1)') respfb > read(30,*) (timi(n), n=1,nfault) > read(30,*) (taub(n), n=1,nfault) > read(30,*) (delts(n), n=1,nf) > read(30,*) (cfr(n), n=1,nfault) > read(30,*) (dfr(n), n=1,nfault) > read(30,*) (slpdf(n), n=1,nf2) > read(30,*) (slpv(n), n=1,nfault) > read(30,*) (rhofcc(n), n=1,nfault) > read(30,*) (islip(n), n=1,nfault) So, the big question then is: How would I go about reading in the > above unformatted Fortran file within Mathematica? t. Yes, any text data can be read into Mathematica. As a last resort, one > can always read such a file as a List of strings and manipulate the > strings to extract the data you require. However, this is always a last > resort, and not necessary here. First open the file: str=OpenRead[c:myfile]; Now read the two character variables: fnmod=Read[str,Record]; > tnstr=Read[str,Record]; (You may need to remove trailing spaces in these variables using > StringTrim). Note that if you print out FullForm[fnmod] you will see > exactly what characters are in the string. It may be easiest to read the rest one number at a time: x=Read[str,Number]; Note that all numbers will end up as Double Precision inside Mathematica. Since you didn't include any declarations in your code, it is not > possible to determine if any of those arrays are CHARACTER variables, > but hopefully you have the general idea by now. Remember that you can > always read tricky bits as strings, and then pull the strings apart in > Mathematica. The ToExpression function may be useful to convert a string > into a number (say). Don't for get to close the stream when you are done: Close[str]; David Baileyhttp://www.dbaileyconsultancy.co.uk === Subject: Re: Expiry warning breaks Workbench > The only coincidental factor that I can think of is that I've just > downloaded Mathematica 7.01. It turns out that my problem was the version of Java that I was using. I was using Java SE 6 (mac) and Workbench 1.1 requires J2SE 5.0 . === Subject: Re: Weird NMinimize behaviour Uhm.. we all get slightly different results.. I think that i'll tweak the options of the various methods of nminimize/nmaximize and see what happens. different results can occour. I was worried that it could be a bug..! Filippo >> woops sorry i didn't see that! >> F2[n1_,k1_,n2_,k2_]:=(-1)^(n1+k1+n2+k2)/(360 [Pi]^4) (8 [Pi]^4-60 >> [Pi]^2 Mod[-Subscript[z, k1]+Subscript[z, n1]-Subscript[z, >> k2]+Subscript[z, n2],2 [Pi]]^2+60 [Pi] Mod[-Subscript[z, >> k1]+Subscript[z, n1]-Subscript[z, k2]+Subscript[z, n2],2 [Pi]]^3-15 >> Mod[-Subscript[z, k1]+Subscript[z, n1]-Subscript[z, k2]+Subscript[z, >> n2],2 [Pi]]^4) >> R2[s_]:=(1-1/[Pi] Sum[(-1)^(n1+1) Subscript[z, n1],{n1,1,2s-1}])^4 >> j[s_]:=Sum[F2[n1,k1,n2,k2],{n1,0,2s-1},{k1,0,2s-1},{n2,0,2s-1}, >> {k