2760 === Subject: export to ps, transparency issue We want to overlay to contourplots, so we do ContourPlot[{x^2/4 + y^2/16}, {x, -6, 6}, {y, -5, 5}, Contours -> {1.}, ContourShading -> {{Red, Opacity[0.4]}, Opacity[0.]}, ContourStyle -> Opacity[0.2]] ContourPlot[{x^2/25 + y^2/9}, {x, -6, 6}, {y, -5, 5}, Contours -> {1.}, ContourShading -> {{Blue, Opacity[0.4]}, Opacity[0.]}] Show[%,%%] The question is that when we do Export[contours.ps,%] the resulting image has a black area in the non-coloured region, which appears white on the screen. No problem when exporting to pdf. Is there some replacement rule which will do the trick? Ruth Lazkoz === Subject: Re: Debugging Mathematica Code (Mathematica 7) I have never had such a problem but you should open the debugger controls always before you send a code piece to the kernel. I really suggest the Wolfram Workbench debugger ! It works more like one would expect it if one use a compiled language like C++. Have a look at http://www.wolfram.com/broadcast/screencasts/workbench/debugging/ BTW We have stopped to make bugs in out not to be useful at all ;-) Jens > On 20 Jan., 12:57, Jens-Peer Kuska the Wolfram Workbench has an excellent debugger >> and there are situations where you need it. >> BTW: What is so complicated ? >> - go to the Evaluation Menu and open the Debugger >> - now type into a notebook >> foo[0] = 1 >> foo[n_Integer] /; n > 0 := n*foo[n - 1] >> use the mouse and mark in >> foo[n_Integer] /; n > 0 := n*foo[n - 1] >> the foo[n - 1] expression. >> Go to the debugger window and use >> Break at selection Now the foo[n - 1] >> has a red frame. >> Finally go to the notebook window and enter >> foo[4] >> as an input. And ... ta ta ta >> The Stack window show the stack >> and all is as it should. Now press Continue >> ind the debugger menu to see the next >> step in the recursion ... >> Jens > No, there isn't a decent explanation. > You can check prior posts by me and others on debugging, but this is > the conclusion, basically. > Anyway, the general feeling among knowledgeable users is that you do > not really need a debugger. > These users just sprinkle print statements here and there to see > intermediate results. > I additionally also use On[] and Off[] which help me see clearly the > code flow. > You don't really need much more. > hth >> Hello Experts, >> I made my fist steps with the Mathematica (so called) debugger and= > st= > umbled >> immediately. Is there anywhrere a documentation of this tool that is >> worth it's name (a criterion which the Mathematica 7 documentatin on d= > ebu= > g >> surely fails). I've tried a lot, but I'm still at the stage trial an >> error. >> Mike Hi Jens, but: Sometimes it works, sometimes not. I used step and step in, > to see waht the code does, but it seems that frequent swithceing > breakpoint on and of irritates the debugger and it's behavior gets a > bit, say, probabilisitc, and therefore I was looking for documentation > (for it could be my fault in missusing the tool without knowing there > is a missuse). So I returned to the insertion of Print-Statements. But I would like more to have a debugger which works well - it's more > easy and comfortable like the print-statement workaround. === Subject: Re: Map onto one column of a matrix As David Park noted, the All spec in MapAt would be the most elegant solution, but MapAt uses the Extract notation instead of the Part notation. After working with this problem myself for a while, I decided that MapAt would do the trick if you could specify the level at which to do the mapping. Hence: MapAtLevel::usage = MapAtLevel[!(* StyleBox[f, TI]),!(* StyleBox[expr, TI]),!(* StyleBox[n, TI]),!(* StyleBox[levelspec, TI])] applies !(* StyleBox[f, TI]) to the element at position !(* StyleBox[n, TI]) at level !(* StyleBox[levelspec, TI]) in !(* StyleBox[expr, TI]). MapAtLevel[f_, expr_, n_, levelspec_: {1}] := Map[MapAt[f, #, n] &, expr, levelspec - 1] Daniel W === Subject: Re: Problem in generating a IF cycle which Mathematica 6.0 Valeria, I see you don't have used much of the advise given you on the occasion of your last post. The line >Import[nome, ImageSize]; is still superfluous >row = ToExpression[Import[nome, ImageSize]][[1]]; >col = ToExpression[Import[nome, ImageSize]][[2]]; have a superfouous ToExpression and can be combined: {row,col} = Import[nome, ImageSize]; > gl = Take[Import[nome, GrayLevels]]; Take is nonsense here as it does nothing unless you provide a second argument. > Do[Do[ i=i + 1; gv[[i]] = gl[[j, k]], {k, 1, col}], {j, 1, row}]; The nested Do is really not the preferred Mathematica style. You can program in Fortran style if you want to, but it is soooo 1950ish. You don't want to look oldfashioned, do you? gv = Flatten[gl]; is all you need instead. And now to your 0. question: If you don't mind that all numbers smaller than 0.0000000001 are mapped to zero I'd suggest you use to Chop[ ] on your array. You could also try gv=gv/.0.->0; another question just to finish my release.... This is the actual list I have: Quit[]; > SetDirectory[C:UsersproprietarioDesktopDesktopTESID atiBit= mapPaziente > 1]; > nome = p6.bmp; > Import[nome, ImageSize]; > row = ToExpression[Import[nome, ImageSize]][[1]]; > col = ToExpression[Import[nome, ImageSize]][[2]]; > vmax = row*col; > gv = Array[f, vmax]; > gl = Take[Import[nome, GrayLevels]]; > i= 0; > Do[Do[ i=i + 1; gv[[i]] = gl[[j, k]], {k, 1, col}], {j, 1, row}]; It returns me an array which have these values... 0. > 0. > 0. > 0. > 0. > 0. > 0. > 0. > 0.1764705882352941 > 0.1764705882352941 > 0.1764705882352941 > 0.8941176470588235 > 0. > 0. > 0. > 0. (this is just a part of the array) Now I have to wite a if cycle which, when it reads 0. (in the array) = it > gives back just 0 (without . to be clear) i.e., i need a new array : 0 > 0 > 0 > 0 > 0 > 0 > 0 > 0 > 0.1764705882352941 > 0.1764705882352941 > 0.1764705882352941 > 0.8941176470588235 > 0 > 0 > 0 > Valeria === Subject: Re: Problem in generating a IF cycle which Mathematica 6.0 > This is the actual list I have: Quit[]; > SetDirectory[C:UsersproprietarioDesktopDesktopTESID atiBitmap > Paziente > 1]; > nome = p6.bmp; > Import[nome, ImageSize]; > row = ToExpression[Import[nome, ImageSize]][[1]]; > col = ToExpression[Import[nome, ImageSize]][[2]]; > vmax = row*col; > gv = Array[f, vmax]; > gl = Take[Import[nome, GrayLevels]]; > i= 0; > Do[Do[ i=i + 1; gv[[i]] = gl[[j, k]], {k, 1, col}], {j, 1, row}]; It returns me an array which have these values... 0. > 0. > 0.1764705882352941 > 0.1764705882352941 > 0.1764705882352941 > 0.8941176470588235 > 0. (this is just a part of the array) Now I have to wite a if cycle which, when it reads 0. (in the array) it > gives back just 0 (without . to be clear) > i.e., i need a new array : 0 > 0 > 0.1764705882352941 > 0.1764705882352941 > 0.1764705882352941 > 0.8941176470588235 > 0 > 0 Several remarks: ..1 The whole code after the first two lines can be written as gv = Flatten[Import[nome, GrayLevels]] ..2 You mismatched rows and columns for ImageSize returns a pair {width, height}, i.e. {number_of_columns, number_of_rows}. ..3 You can replace the inexact zeros 0. (floating-point number) by their replacement rule such as /. (0. -> 0) ..4 Are you sure you really want to do so? Mixing floating-point and exact representations yields a structure that cannot be optimized in memory (packed array technology), resulting in more memory consumption than necessary and less computational efficiency. In[1]:= nome = ExampleData/spikey3.bmp; gv = Flatten[Import[nome, GrayLevels]] /. 0. -> 0; In[3]:= v = {0., 0., 0., 0.17, 0.18, 0., 0., 0.} Out[3]= {0., 0., 0., 0.17, 0.18, 0., 0., 0.} In[4]:= v = v /. 0. -> 0 Out[4]= {0, 0, 0, 0.17, 0.18, 0, 0, 0} In[5]:= nome = ExampleData/spikey3.bmp; size = Import[nome, ImageSize]; col = ToExpression[Import[nome, ImageSize]][[1]]; row = ToExpression[Import[nome, ImageSize]][[2]]; vmax = row*col; gv = Array[f, vmax]; gl = Import[nome, GrayLevels]; i = 0; Do[Do[i = i + 1; gv[[i]] = gl[[j, k]], {k, 1, col}], {j, 1, row}]; In[14]:= gl // Dimensions Out[14]= {204, 226} In[15]:= size Out[15]= {226, 204} Out[16]= True --Jean[Marc === Subject: Re: Problem in generating a IF cycle which Mathematica 6.0 you had posted the code before and you have ignored all of our suggestions, that gave me the hope that you will ignore the next answers too SetDirectory[C:UsersproprietarioDesktopDesktopTESI DatiBitmapPaziente 1]; nome = p6.bmp; gv=Import[nome]/. {img_Image:> Flatten[ImageData[img]], img:Graphics[Raster[__],___]:> Flatten[img[[1,1]]]; gv=Chop[gv] will do it with out a loop or other stupid things and should work with Mathematica 6 and 7 Jens another question just to finish my release.... This is the actual list I have: > Quit[]; > SetDirectory[C:UsersproprietarioDesktopDesktopTESID atiBitmapPaziente > 1]; > nome = p6.bmp; > Import[nome, ImageSize]; > row = ToExpression[Import[nome, ImageSize]][[1]]; > col = ToExpression[Import[nome, ImageSize]][[2]]; > vmax = row*col; > gv = Array[f, vmax]; > gl = Take[Import[nome, GrayLevels]]; > i= 0; > Do[Do[ i=i + 1; gv[[i]] = gl[[j, k]], {k, 1, col}], {j, 1, row}]; It returns me an array which have these values... > 0. > 0. > 0. > 0. > 0. > 0. > 0. > 0. > 0.1764705882352941 > 0.1764705882352941 > 0.1764705882352941 > 0.8941176470588235 > 0. > 0. > 0. > 0. > (this is just a part of the array) Now I have to wite a if cycle which, when it reads 0. (in the array) it > gives back just 0 (without . to be clear) > i.e., i need a new array : 0 > 0 > 0 > 0 > 0 > 0 > 0 > 0 > 0.1764705882352941 > 0.1764705882352941 > 0.1764705882352941 > 0.8941176470588235 > 0 > 0 > 0 > Valeria === Subject: Re: Basic questions on list manipulation in the For instance, ct = {{sym1 -> {val1 -> 20, val2 -> 300, val3 -> 1000}}, {sym2 -> {val1 -> 50, val2 -> 500, val3 -> 20000}}}; changeVal[ct_, who_, class_, amt_] := ct /. Rule[who, {a___, Rule[class, _], b___}] :> Rule[who, {a, Rule[class, amt], b}] ct = changeVal[ct, sym2, val1, hello] {{sym1 -> {val1 -> 20, val2 -> 300, val3 -> 1000}}, {sym2 -> {val1 -> hello, val2 -> 500, val3 -> 20000}}} If you don't like the assignment construct ct = changeVal[..], an alternative is ct = {{sym1 -> {val1 -> 20, val2 -> 300, val3 -> 1000}}, {sym2 -> {val1 -> 50, val2 -> 500, val3 -> 20000}}}; Clear[changeVal] SetAttributes[changeVal, HoldFirst] changeVal[ct_, who_, class_, amt_] := ct = ct /. Rule[who, {a___, Rule[class, _], b___}] :> Rule[who, {a, Rule[class, amt], b}] changeVal[ct, sym2, val1, hello]; ct {{sym1 -> {val1 -> 20, val2 -> 300, val3 -> 1000}}, {sym2 -> {val1 -> hello, val2 -> 500, val3 -> 20000}}} If you want changeVal to treat ct as a global, not an argument (never recommended), then: ct = {{sym1 -> {val1 -> 20, val2 -> 300, val3 -> 1000}}, {sym2 -> {val1 -> 50, val2 -> 500, val3 -> 20000}}}; Clear[changeVal] changeVal[who_, class_, amt_] := ct = ct /. Rule[who, {a___, Rule[class, _], b___}] :> Rule[who, {a, Rule[class, amt], b}] changeVal[sym2, val1, hello]; ct {{sym1 -> {val1 -> 20, val2 -> 300, val3 -> 1000}}, {sym2 -> {val1 -> hello, val2 -> 500, val3 -> 20000}}} Bobby I have some basic questions about using lists in Mathematica. > Specifically I have a table that serves as sort of a database with the > following structure: ct = { > { sym1 -> {val1->20, val2->300, val3->1000, ... }, > { sym2 -> {val1->50, val2->500, val3->20000,...}, > ... > } sym1, sym2, ... are people and val1, val2 ... represent attributes of > each person. Now I'm trying to go in and modify values. I can do it, but I think > not well and I think with a programming language mindset instead of > a Mathematica mindset. Here is my specific question. In order to change a specific value in > the list above (valxxx) for a given individual (symxxx), I created > this function: changeVal[ who_, class_, amnt_ ] := ( > ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]] = > ReplacePart[ ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]], > Position[ ct[[ Position[ ct, who ][[ 1, 1 ]] ]], class ][[ 1, > 2 ]] -> (class -> amnt) ] > ); Now I know there is a better way than that using list manipulation and > patterns. Can some of you experienced pros help me out? I call this > write only code because I don't know that I could explain it once > it's written. Perhaps a more fundamental question: is this the right way to store > data in lists? Or would it be better to just have the values and > reference them by index number? > -- DrMajorBob@longhorns.com === Subject: Re: Fitting problem i have the following situation: 5 mathematical models describing the formation of different species. > The models (so the species) are interdependent, means.. they all have > the same parameters but some of the have also other additional > parameter. Example: Model 1 has a parameter lifetime1... model 2 > will include this parameter liftime1 and a new parameter > lifetime2. My trouble is now to find best fit values for the parameters in all > the models at the same time. I don't want to find a best fit for model > 1 and then find out when doing best fit for model 2 that model 2 won't > work with the parameter values found in the first run with model 1. So > the fitting must consider all the models to find best fit values for > the parameter. I wonder if this achievable with mathematica or if i would be better > of with other software thank you for your help Ktota It can't always be done. It depends on both the models and the experimental design under which the data were collected. This is an orthogonal design problem. === Subject: Re: slots with 2 indexed array? mathematica is clever enough to figure which slot belongs to which function: If[# >= 2, # - 2, # + 2] & /@ # & /@ sig hope this helps, Daniel > First I produce some dummy data, 4000 of what I call signals, 1024 samples each. sigs = Table[10 i + j, {i, 4000}, {j, 1024}]; > len = Length[sigs]; I'd like to modify these signals. The For statement below works. I can use a slot function on each of the sigs specified by i. For[i = 1, i < len + 1, i++, > sigs[[i]] = If[# >= 2048, # - 2048, # + 2048] & /@ sigs[[i]] ] Surely there's a way to use slots on a double indexed array but I haven't found it yet. If I try to let # represent every entry in sigs, the If statement isn't processed: sigs = If[# >= 2048, # - 2048, # + 2048] & /@ sigs; I tried Which that Help says uses HoldAll but that doesn't work either; Which[] still isn't evaluated. I tried using #2 and ## instead of # but that doesn't work. In reading about slot functions I haven't seen any examples using multi indexed arrays. === Subject: Re: slots with 2 indexed array? Map[If[# >= 2048, # - 2048, # + 2048] &,sigs,{2}] ?? Jens > First I produce some dummy data, 4000 of what I call signals, 1024 samples each. sigs = Table[10 i + j, {i, 4000}, {j, 1024}]; > len = Length[sigs]; I'd like to modify these signals. The For statement below works. I can use a slot function on each of the sigs specified by i. For[i = 1, i < len + 1, i++, > sigs[[i]] = If[# >= 2048, # - 2048, # + 2048] & /@ sigs[[i]] ] Surely there's a way to use slots on a double indexed array but I haven't found it yet. If I try to let # represent every entry in sigs, the If statement isn't processed: sigs = If[# >= 2048, # - 2048, # + 2048] & /@ sigs; I tried Which that Help says uses HoldAll but that doesn't work either; Which[] still isn't evaluated. I tried using #2 and ## instead of # but that doesn't work. In reading about slot functions I haven't seen any examples using multi indexed arrays. === Subject: Re: slots with 2 indexed array? > First I produce some dummy data, 4000 of what I call signals, 1024 samples > each. sigs = Table[10 i + j, {i, 4000}, {j, 1024}]; > len = Length[sigs]; I'd like to modify these signals. The For statement below works. I can use a > slot function on each of the sigs specified by i. For[i = 1, i < len + 1, i++, > sigs[[i]] = If[# >= 2048, # - 2048, # + 2048] & /@ sigs[[i]] ] Surely there's a way to use slots on a double indexed array but I haven't > found it yet. If I try to let # represent every entry in sigs, the If statement isn't > processed: sigs = If[# >= 2048, # - 2048, # + 2048] & /@ sigs; I tried Which that Help says uses HoldAll but that doesn't work either; > Which[] still isn't evaluated. I tried using #2 and ## instead of # but that doesn't work. In reading about > slot functions I haven't seen any examples using multi indexed arrays. Could someone please give me a hint on how to pull this off? -- if this can What you need is to *Map* at the second level only of the structure, e.g. sigs = Map[If[# >= 2048, # - 2048, # + 2048] &, sigs, {2}] The default level specification to Map (and its shortcut /@) is one. The structure you are working on is a regular two dimensional list (a list of list). That is, the entries of the top level list, say sigs, are themselves lists of numbers (that can be interpreted as row vectors, in this case). Now, the For loop you have written takes each row vector in turn and applies the function on the components of this vector, which is a one-dimensional list. In other words, at every step of the loop, the map function is feed by a one-dimensional list only. To achieve the same thing directly with the Map function, just increases the level specification from one (the default) to two. I hope this makes sense. Here is a example showing that the results are the same, as expected. In[1]:= sigs = Table[10 i + j, {i, 4}, {j, 10}]; len = Length[sigs]; {len, sigs // Dimensions} sigs sigs = Map[If[# >= 31, # - 31, # + 31] &, sigs, {2}] Out[3]= {4, {4, 10}} Out[4]= {{11, 12, 13, 14, 15, 16, 17, 18, 19, 20}, {21, 22, 23, 24, 25, 26, 27, 28, 29, 30}, {31, 32, 33, 34, 35, 36, 37, 38, 39, 40}, {41, 42, 43, 44, 45, 46, 47, 48, 49, 50}} Out[5]= {{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}, {52, 53, 54, 55, 56, 57, 58, 59, 60, 61}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {10, 11, 12, 13, 14, 15, 16, 17, 18, 19}} In[6]:= sigs = Table[10 i + j, {i, 4}, {j, 10}]; len = Length[sigs]; {len, sigs // Dimensions} sigs Out[8]= {4, {4, 10}} Out[9]= {{11, 12, 13, 14, 15, 16, 17, 18, 19, 20}, {21, 22, 23, 24, 25, 26, 27, 28, 29, 30}, {31, 32, 33, 34, 35, 36, 37, 38, 39, 40}, {41, 42, 43, 44, 45, 46, 47, 48, 49, 50}} In[10]:= For[i = 1, i < len + 1, i++, sigs[[i]] = If[# >= 31, # - 31, # + 31] & /@ sigs[[i]]] sigs Out[11]= {{42, 43, 44, 45, 46, 47, 48, 49, 50, 51}, {52, 53, 54, 55, 56, 57, 58, 59, 60, 61}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, {10, 11, 12, 13, 14, 15, 16, 17, 18, 19}} --Jean-Marc === Subject: Re: slots with 2 indexed array? I guess you must have missed the details on level specifications in the documentation. You should look that up. Both Map and Apply have examples on this. A tutorial can be found on tutorial/ ApplyingFunctionsToPartsOfExpressions in the Help centre. Here is a simplified version of your example with level specification: In[3]:= sigs = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; In[7]:= Map[If[# > 6, # - 6, # + 6] &, sigs, {2}] Out[7]= {{7, 8, 9, 10}, {11, 12, 1, 2}, {3, 4, 5, 6}} > First I produce some dummy data, 4000 of what I call signals, 1024 sample= s each. sigs = Table[10 i + j, {i, 4000}, {j, 1024}]; > len = Length[sigs]; I'd like to modify these signals. The For statement below works. I can us= e a slot function on each of the sigs specified by i. For[i = 1, i < len + 1, i++, > sigs[[i]] = If[# >= 2048, # - 2048, # + 2048] & /@ sigs[[i]] ] Surely there's a way to use slots on a double indexed array but I haven't= found it yet. If I try to let # represent every entry in sigs, the If statement isn't p= rocessed: sigs = If[# >= 2048, # - 2048, # + 2048] & /@ sigs; I tried Which that Help says uses HoldAll but that doesn't work either; W= hich[] still isn't evaluated. I tried using #2 and ## instead of # but that doesn't work. In reading= about slot functions I haven't seen any examples using multi indexed array= s. Could someone please give me a hint on how to pull this off? -- if this c= === Subject: message-driven function: more explanation In the book Programming Paradigms with Mathematica http://library.wolfram.com/infocenter/MathSource/1847/ in the notebook Hw21.nb there is following function: Clear[makeCounter]; makeCounter::usage=makeCounter[] returns a message-driven function which manipulates a hidden counter variable. The initial value of the counter variable may be set via an optional argument to makeCounter (default is 0). Valid messages for the function are ++ (increment), -- (decrement), value, and reset. For example, ctr = makeCounter[100]; ctr[value] returns 100.; makeCounter[ defaultValue_Integer:0 ] := Module[ { counter = defaultValue, changeCounter }, changeCounter[msg_String:++] := Switch[msg, ++, counter = counter + 1; counter, --, counter = counter - 1; counter, value, counter, reset, counter = defaultValue; counter, _, Print[Unknown message to counter:, msg]; counter ]; changeCounter ]; ctr = makeCounter[100] ctr[value] ctr[++] gives as output changeCounter$723 100 101 Where can I find more explanation of this type of message-driven function? === Subject: Mathematica Animation Drives Me Crazy! I have never ending problems with Mathematica animation since Version 6. This takes the forms: 1) Sometimes (maybe about 10% if the time) an animation will 'stick' without finishing or repeating. 2) It does not seem possible to control the actual number of points or evaluations in the animation. 3) The documentation for the control of timing and precise steps is quite poor and this may be a reflection of actual buggy animation routines. Here is an example using Trigger, which is a kind of once-through animation. I am using an integer range, 0 to 10 in steps of 1. I would therefore like to have exactly 11 evaluations. But I always get an extra evaluation at the end, and even worse I often obtain repeat evaluations for some intermediate value. The following displays the value of n, the number of evaluations, and the actual list of n values for the evaluations. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] The following uses DisplayAllSteps -> True but seems to have the same problem. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}, DisplayAllSteps -> True], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] Do other users see these kind of problems, especially repeat evaluations for some values of n? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Bizarre Histogram behavior I can't tell you anything about the Optica package as I don't own it, but did you try loading ht Histogram package on a clean kernal before loading the Optica package? Perhaps there is some shadowing going on. As to the behaviour in the help page: Some help pages appear to be set up so that its parts have separate environments that don't share each others variables and definitions. It seems to be connected to the dotted lines on those pages. If you copy the examples in the same cell, you'll see that they all do work. If you'd copy & execute the Needs instruction to each part that would work as well. > I have Mathematica versions 6 and 7 installed on my Intel MacBookPro. > I am also using the Optica package that currently runs only under > version 6. So I am running a notebook with Optica code with Version 6. > I load the Histogram package with Needs[Histograms`] when I start > the notebook. Then when I attempt to execute the Histogram function, I > get the error message that says it can't find the Histogram symbol. > Now, if I go to Help for the Histogram function, the first thing in > the Examples section is Needs[Histograms`], which I execute in the > Help notebook. Then the first example in this notebook works > correctly, giving a histogram plot of the specified data. But what is > bizarre is that the second example fails to plot. When I execute this > cell Histogram[RandomReal[{0, 1}, {1000}]], the result is a long list > of numbers with Histogram at the head. In the Help notebook, if I > do ??Histogram, I get the result: Cell$$4753`Histogram. Why does my notebook not recognize Histogram[] after I load the > package? Why does the Help example fail to plot the second example? Is > there some interaction between the installation of Mathematica 6 and > Mathematica 7 that now prevents Mathematica 6 from recognizing the > Histogram package? This behavior is really bizarre. === Subject: Re: 0^0 = 1? >Mathematica says 0^0 = Indeterminate This is the only reasonable choice to use. While there are some problems where it is convenient to define 0^0 as 1, doing so will definitely cause inconsistencies in other problems. Any choice other than Indeterminate will lead to inconsistencies for some problems. === Subject: Re: Which editor do you use for math How could hot-link LaTeX to Player? Tim Brophy > I downloaded LyX last night and so far have mixed reactions... I'm > used to > editing WYSIWYG in NeoOffice. It's weird seeing the text spaced all > funky-like (non-proportional fonts or something like that) UNTIL you > decide to make it printable or PDF. I'll spend a little time, though, and see if I can get used to it. >> For live documents nothing comes close to Mathematica. However, if >> you >> need >> to use a widely-accepted standard then LaTeX is the best solution. >> If you >> like to edit your LaTeX code directly then the WinEdt/MiKTeX >> combination >> is >> quite usable, but I much prefer to use a GUI to hide the LaTeX >> code. With >> this in mind, for the past 5 years or so I have used Publicon >> (www.wolfram.com/products/publicon) to create LaTeX files, but >> Publicon >> is >> still at version 1.0.1 five years after its original release in mid >> so >> I am concerned about its future. Recently, I have been looking at the >> free >> Lyx (http://wiki.lyx.org), and after a month of playing around with >> it I >> have nothing but praise for this wonderful piece of software. Also, >> transferring Publicon->Lyx via LaTeX seems to be robust. One could >> create a >> semi-live document by hot-linking the LaTeX to demonstrations (or >> whatever) >> running in Mathematica Player. For instance, static diagrams in the >> document >> could have interactive counterparts that run in Player. > > -- > DrMajorBob@longhorns.com > === > [Unless your TeX input has some error, in which case the typeset > output > will only appear up a point where the error occurs; a description > and > explanation of the error will appear in a third log window -- an= d > hitting some other key combo will take you back to the input window > **with the cursor positioned at the point or line where the error > was > encountered.] > This has been the case for many years. >> Amazing. That means they must have produced a mind-reading version of >> TeX that I am not aware of. In all versions that I know (and I have >> been using TeX,LateX,Ams-Latex etc for decades) the cursor will >> appear not at the place where the error (for example a missing right >> brace })occurred but at the place where TeX first notices some inconsi= stency >> with its syntax - which is almost never the place where the error >> actually occurred. At that point you have got to manually find the >> actual error, which can be far from simple. The only TeX >> implementation that I know that partly gets around this problem is >> the Mac TeX system Textures (http://www.bluesky.com/products/products_= frames. > html >> ), which continually typesets your output as you type (without the >> need to hit any keys), which usually will make you aware of an error >> as soon as it occurs rather than much later, when you try to typeset >> the you course code. Moreover, Textures has several other nice >> features that are implemented only imperfectly in other versions. But >> there are major caveats - a Mac OS X version is still only in beta, >> years after Mac OS X occurred, and Textures costs hundreds of >> dollars. >> But, and here is something anyone considering TeX should carefully >> ponder upon. Before Mac OS X appeared, there were many persons >> (including myself) willing to pay hundreds of dollars for Textures >> and more for regular upgrades, in spite of the fact that lots of free = TeX >> implementations have always existed on the Mac (I myself now use TeX >> Shop with Japanese PTex engine). This was because TeXtures avoids the >> huge amount of hassle that installing and using TeX is for any >> beginner and even for an experienced user. Then Blue Sky, the company >> that makes Textures, failed to come up with a Mac OS X compatible >> version and most users reluctantly drifted away to other programs. >> But if you look mailing lists where TeX on Mac OS is discussed you wil= l >> find that many are intending to return (even though it will cost them >> money) as soon as a full featured version is again available. Which >> only proves that standard, free implementations of TeX are far form >> the sort of thing some make them out to be. I strongly recommend you >> to try TeX, but I suspect you will be soon back to using Mathematica >> (if not Word). > Have you tried installing TeXLive? > -- m Yes. It certianly makes keeping up to date with various packages > easier, but I don't think it addresses the issues I mentioned and does > not have the features Textures offers (or used to). Among these were: 1. Continuously updated preview Urgh. Why would you want that? What's next, Clippy?!! :) > 2. Traffic light - an interactive device that keeps you informed > while you are typing if your input is syntactically correct (so you > can catch errors as they occur Any decent editor will have syntax highlghting, which is good enough to catch commor errors. The uncommon ones (TeX is essentially impossible to syntax check!) are uncommon ;-) > 3. Synchronicity. Command-click on any text in the preview and you are > taken to the corresponding point in your source code. Do the same to > any word in the source code and you are taken to the right place in > the preview. You can do this using xdvi and vim; I imagine emacs does it also, but I do not speak emacs. Add xdvi.editor: gvim --servername xdvi --remote +%l %f to ~/.xdvirc, and compile using latex --src-specials=cr,display,hbox,math,par,hbox ... and start editing uxing gvim --servername xdvi myfile.tex or vimx --servername xdvi myfile.tex When you then ctrl-click on something in xdvi, vim jump to the correct position in the source. On the other hand, add map :call system(xdvi -sourceposition . string(line('.')) . expand(%:r)) (This should be in one line, I guess) to your ~/.vimrc; then pressing F1 while editing a tex file will result in xdvijumping to that position. I understand that you can do this also with PDF, assuming your PDF previewer has the necessary support, but I have never tried. You should really consider Auctex. -- m === [...] LaTeX had all kinds of problems. Figures never appeared where you > wanted them. Thus the h! flag. Most of the GUI frontends to LaTeX now allow for easy specification of where you want the figures, and the degree of their floatiness. > Quite often they ended up bunched together at the end of > a chapter. You needed a kludge like the here.sty style file. Using > different fonts was next to impossible. LaTeX2e that appeared later > improved that (so I have heard). However, years later, when I tried to > typeset my plain LaTeX based thesis once again, I couldn't get it to > compile with the then current 2e version. So much for compatibility. This may still be a problem. > Equations of more than average complexity easily filled up half a page > of code rubbish and were a pain to debug. No problem with, e.g., LyX and its instant preview. > Spellchecking less than > basic. Try to write a multiple language peace and spellcheck that in > LaTeX. This is no problem now. > Virtually no picture tools. No tracked changes. No > collaboration tools etc etc. All of that is quite easy now. > I don't want to start a flame war. Just balancing the discussion > somewhat. I am well aware of many or most of the problems of Word. > Points taken! All of the desktop publishing paradigms can *really* be worked on. -- 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 === I very much recommend trying to stick with LyX for a couple of days, at least until you're convinced it's not for you. It even can use Mathematica (harder for me to get it to work on Windows than on linux; I don't know about OS X integration) as a math engine, so that if you type in an expression in a LHS = RHS format, it can often return the expression or its value automatically to LyX and typeset that. It's definitely my preferred way to produce any sort of scientific document, with Mathematica graphics incorporated as .pdf or .fig files. > I downloaded LyX last night and so far have mixed reactions... I'm used to > editing WYSIWYG in NeoOffice. It's weird seeing the text spaced all > funky-like (non-proportional fonts or something like that) UNTIL you > decide to make it printable or PDF. I'll spend a little time, though, and see if I can get used to it. Bobby > For live documents nothing comes close to Mathematica. However, if you > need > to use a widely-accepted standard then LaTeX is the best solution. If you > like to edit your LaTeX code directly then the WinEdt/MiKTeX combination > is > quite usable, but I much prefer to use a GUI to hide the LaTeX code. With > this in mind, for the past 5 years or so I have used Publicon > (www.wolfram.com/products/publicon) to create LaTeX files, but Publicon > is > so > I am concerned about its future. Recently, I have been looking at the > free > Lyx (http://wiki.lyx.org), and after a month of playing around with it I > have nothing but praise for this wonderful piece of software. Also, > transferring Publicon->Lyx via LaTeX seems to be robust. One could > create a > semi-live document by hot-linking the LaTeX to demonstrations (or > whatever) > running in Mathematica Player. For instance, static diagrams in the > document > could have interactive counterparts that run in Player. > > -- 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: Problem with an integral >I'm working with a little problem in Mathematica 7.0.0. I want to >integrate this function >fun = x^(n + 1)*E^(-x + (I*k)/x) >Assuming that both n and k are greater than zero, I write >integral = FullSimplify[Assuming[{k > 0, n > 0}, Integrate[fun, {x, >0, [Infinity]}]]] >And I obtain a symbolic result. But, when I want to put some >specific value, like this >integral /. {n -> 1, k -> 1} >I obtain always ComplexInfinity, and/or other errors. So, I've tried >to evaluate numerically the integral for the same specific values, >in this way >NIntegrate[Evaluate[fun /. {n -> 1, k -> 1}], {x, 0, [Infinity]}] >And I obtain a finite numeric result. So, there's some error in >symbolic computation, or I miss something when I try to integrate >the formula? Neither. This issue arises due to the way Mathematica does evaluations. Mathematica first does replacements indicated then evaluates the result. So, (x - 2 x +1)/(x - 1)/.x->1 will evaluate as (1 - 2 + 1)/(1 - 1) = 0/0 and generate an error. That is Mathematica does not simplify (x - 2 x +1)/(x - 1) to x - 1 and then do the substitution. Even using FullSimplify before doing the substitution will not always resolve the problem particularly for a complex result returned by Integrate. For a complex integral, FullSimplify may not be able to simplify the result from Integrate to successfully remove singularities. Nor does Mathematica do anything to improve numeric stability of the result. These are two of the reasons why NIntegrate should always be used in preference to N[Integrate[... when a numerical result for an integral is desired. === Subject: Re: slots with 2 indexed array? >First I produce some dummy data, 4000 of what I call signals, 1024 >samples each. >sigs = Table[10 i + j, {i, 4000}, {j, 1024}]; len = Length[sigs]; >I'd like to modify these signals. The For statement below works. I >can use a slot function on each of the sigs specified by i. >For[i = 1, i < len + 1, i++, sigs[[i]] = If[# >= 2048, # - >2048, # + 2048] & /@ sigs[[i]] ] While the loop above clearly works, it is a very inefficient way to get the desired result. It is more efficient to do sigs = Map[If[# >= 2048, # - 2048, # + 2048] &, sigs, {2}]; That is: In[1]:= test = sigs = Table[10 i + j, {i, 4000}, {j, 1024}]; len = Length[sigs]; In[2]:= =46or[i = 1, i < len + 1, i++, sigs[[i]] = If[# >= 2048, # - 2048, # + 2048] & /@ sigs[[i]]] // Timing Out[2]= {1.35373,Null} In[3]:= test = Map[If[# >= 2048, # - 2048, # + 2048] &, test, {2}]; // Timing Out[3]= {0.859782,Null} In[4]:= test == sigs Out[4]= True >Surely there's a way to use slots on a double indexed array but I >haven't found it yet. >If I try to let # represent every entry in sigs, the If statement >isn't processed: >sigs = If[# >= 2048, # - 2048, # + 2048] & /@ sigs; Of course the reason this doesn't work is the slot is replaced by an entire row in sigs rather than an individual element. You can make the if function map to individual elements by using the third argument to Map as I did above. === Subject: Issue with Sum Version7 Anyone seen this: In[120]:= Sum[i, {i, 0, 99999, .1}] Out[120]= 4.99991*10^10 In[121]:= Sum[i, {i, 0, 100000, .1}] Out[121]= Sum[i, {i, 0, 100000, 0.1}] On Mac OS X 10.5.6 Brian === Subject: Re: Basic questions on list manipulation in the Mathematica Way I have some basic questions about using lists in Mathematica. > Specifically I have a table that serves as sort of a database with the > following structure: ct = { > { sym1 -> {val1->20, val2->300, val3->1000, ... }, > { sym2 -> {val1->50, val2->500, val3->20000,...}, > ... > } sym1, sym2, ... are people and val1, val2 ... represent attributes of > each person. Now I'm trying to go in and modify values. I can do it, but I think > not well and I think with a programming language mindset instead of > a Mathematica mindset. Here is my specific question. In order to change a specific value in > the list above (valxxx) for a given individual (symxxx), I created > this function: changeVal[ who_, class_, amnt_ ] := ( > ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]] = > ReplacePart[ ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]], > Position[ ct[[ Position[ ct, who ][[ 1, 1 ]] ]], class ][[ 1, > 2 ]] -> (class -> amnt) ] > ); Now I know there is a better way than that using list manipulation and > patterns. Can some of you experienced pros help me out? I call this > write only code because I don't know that I could explain it once > it's written. Perhaps a more fundamental question: is this the right way to store > data in lists? Or would it be better to just have the values and > reference them by index number? > solution I was seeking (involving patterns) looks like this: changeVal[ct_, who_, class_, amt_] := ct /. Rule[who, {a___, Rule [class, _], b___}] :> Rule[who, {a, Rule[class, amt], b}] There were other, equally elegant, solutions -- just goes to show that there are lots of ways to accomplish any given task in Mathematica. === Subject: Re: Basic questions on list manipulation in the Mathematica Way An alternative to your field modification code... First, let's get us a data set in your style: In[79]:= ClearAll[data]; data = { {Thomas Jefferson -> {val1 -> 12, val2 -> 34, val3 -> 56, val4 -> 78}}, {George Washington -> {val1 -> 91, val2 -> 234, val3 -> 567, val4 -> 893}}, {John Kennedy -> {val1 -> 21, val2 -> 33, val3 -> 444, val4 -> 555}}, {Barack Obama -> {val1 -> 377, val2 -> 12, val3 -> 34, val4 -> 5534}} }; Examining an entry: In[84]:= Thomas Jefferson /. Flatten[data] Out[84]= {val1 -> 12, val2 -> 34, val3 -> 56, val4 -> 78} I used Flatten because the rules are nested a level too deep. You could remove the {} around each individual. Getting to one of its fields: In[89]:= val1 /. (Thomas Jefferson /. Flatten[data]) Out[89]= 12 Modification of a field: In[87]:= data=data /. HoldPattern[{Thomas Jefferson -> {a___, val2 -> x_, b___}}] -> {Thomas Jefferson -> {a, val2 -> 4444, b}} Out[87]= {{Thomas Jefferson -> {val1 -> 12, val2 -> 4444, val3 -> 56, val4 -> 78}}, {George Washington -> {val1 -> 91, val2 -> 234, val3 -> 567, val4 -> 893}}, {John Kennedy -> {val1 -> 21, val2 -> 33, val3 -> 444, val4 -> 555}}, {Barack Obama -> {val1 -> 377, val2 -> 12, val3 -> 34, val4 -> 5534}}} Note that since the data set consists of rules, using a rule for replacement needs some precausions otherwise the wrong rule is applied. The HoldPattern takes care of that. A slight modification prevents the necessity of providing the attribute name twice: data /. HoldPattern[{Thomas Jefferson -> {a___, y:val3 -> x_, b___}}] -> {Thomas Jefferson -> {a, y -> 4444, b}} Now for other possible data structures: If the attribute types are the same for all individuals you could use a plain list like this: data = { {Thomas Jefferson, 12, 34, 56, 78}, {George Washington, 91, 234, 567, 893}, {John Kennedy, 21, 33, 444, 555}, {Barack Obama, 377, 12, 34, 5534} }; So, every column corresponds to a certain attribute. Modifications could be done like this: data = data /. {Thomas Jefferson, x_, y_, z_, w_} -> {Thomas Jefferson, 4444, y, 1111, w} This code is easily readable and understandable, but modification in this simple way also means copying the whole database which may be a problem if it's huge. In that case, one should use indexes. An alternative would be the following, in which the database is a function: ClearAll[data]; data[Thomas Jefferson] = {12, 34, 56, 78}; data[George Washington] = {91, 234, 567, 893}; data[John Kennedy] = {21, 33, 444, 555}; data[Barack Obama] = {377, 12, 34, 5534}; data[Thomas Jefferson] = data[Thomas Jefferson] /. {x_, y_, z_, w_} -> {4444, y, 1111, w} This idea of a function as a database can be used even more: ClearAll[data]; data[Thomas Jefferson, val1] = 12; data[Thomas Jefferson, val2] = 34; data[Thomas Jefferson, val3] = 56; data[Thomas Jefferson, val4] = 78; data[George Washington, val1] = 91; data[George Washington, val2] = 234; data[George Washington, val3] = 567; data[George Washington, val4] = 893; data[John Kennedy, val1] = 21; data[John Kennedy, val2] = 33; data[John Kennedy, val3] = 444; data[John Kennedy, val4] = 555; data[Barack Obama, val1] = 377; data[Barack Obama, val2] = 12; data[Barack Obama, val3] = 34; data[Barack Obama, val4] = 5534; Modification of a value is now simply a redefinition of the function: data[Thomas Jefferson, val1] = 4444; This has the disadvantage that it is difficult to collect all values of val1. Of course, you could also use external databases, see DatabaseLink/ tutorial/Overview in the help centre. I have some basic questions about using lists in Mathematica. > Specifically I have a table that serves as sort of a database with the > following structure: ct = { > { sym1 -> {val1->20, val2->300, val3->1000, ... }, > { sym2 -> {val1->50, val2->500, val3->20000,...}, > ... > } sym1, sym2, ... are people and val1, val2 ... represent attributes of > each person. Now I'm trying to go in and modify values. I can do it, but I think > not well and I think with a programming language mindset instead of > a Mathematica mindset. Here is my specific question. In order to change a specific value in > the list above (valxxx) for a given individual (symxxx), I created > this function: changeVal[ who_, class_, amnt_ ] := ( > ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]] = > ReplacePart[ ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]], > Position[ ct[[ Position[ ct, who ][[ 1, 1 ]] ]], class ][[ 1, > 2 ]] -> (class -> amnt) ] > ); Now I know there is a better way than that using list manipulation and > patterns. Can some of you experienced pros help me out? I call this > write only code because I don't know that I could explain it once > it's written. Perhaps a more fundamental question: is this the right way to store > data in lists? Or would it be better to just have the values and > reference them by index number? > === Subject: Re: Basic questions on list manipulation in the Mathematica Way Sorry, I don't have a good answer for you. I can offer my reassurance that this is not a simple question. I have been using this nested- list-of-rules structure for databasing within Mathematica programs for years (it is pretty easy to convert this structure to and from XML using SymbolicXML), but I have not found a good, robust, and general way up making updates to the data. It would be nice if someone (hint, hint, Wolfram developers) would beef up the XML support in Mathematica by adding functions to imitate XPath, XQuery, and XUpdate. Daniel === Subject: Re: Basic questions on list manipulation in the Mathematica Way I would store the data in a function. Further, I would not store attribute names more than once. Here is an example: person[John]={1,2,3} this declares a person John with attribute values: 1,2,3 To pick a certain attribute: person[name_,attr1]:= person[name][[1]]; person[name_,attr2]:= person[name][[2]]; person[name_,attr3]:= person[name][[2]]; This scheme can be extended. hope this helps, Daniel I have some basic questions about using lists in Mathematica. > Specifically I have a table that serves as sort of a database with the > following structure: ct = { > { sym1 -> {val1->20, val2->300, val3->1000, ... }, > { sym2 -> {val1->50, val2->500, val3->20000,...}, > ... > } sym1, sym2, ... are people and val1, val2 ... represent attributes of > each person. Now I'm trying to go in and modify values. I can do it, but I think > not well and I think with a programming language mindset instead of > a Mathematica mindset. Here is my specific question. In order to change a specific value in > the list above (valxxx) for a given individual (symxxx), I created > this function: changeVal[ who_, class_, amnt_ ] := ( > ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]] = > ReplacePart[ ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]], > Position[ ct[[ Position[ ct, who ][[ 1, 1 ]] ]], class ][[ 1, > 2 ]] -> (class -> amnt) ] > ); Now I know there is a better way than that using list manipulation and > patterns. Can some of you experienced pros help me out? I call this > write only code because I don't know that I could explain it once > it's written. Perhaps a more fundamental question: is this the right way to store > data in lists? Or would it be better to just have the values and > reference them by index number? > === Subject: Re: Multiple PDF Pages using Export I would recommend what Murray says here. I do not remember the exact option right now, but there is a CellProperty to make page break before/after cell. Then you should be able to get one graphic per page. HTH. Roger Williams Franklin Laboratory > File > SaveAs offers the choice to save the notebook in PDF, and does > so, even with many pages. > === Subject: Re: Multiple PDF Pages using Export > Don, I don't think the functionality you want exists. I hope someone > for my applications. I think I read somewhere that Mathematica only > supports single page export in PDF (can't find it now) and this is indeed > my experience. What do I do? I write 4 PDF files and then use the Adobe Acrobat assemble into a singl= e > PDF option. > Hi All! > I'm interested in generating one PDF graphic per page as in > fourpages=Table[Graphics[Circle[], ImageSize -> {s, s}], {s, 100, 200= , 25}] > followed by something like > Export[file.pdf, Table[{Page[i] -> fourcircles[[i]]}, {i, 1, 4}], PD= F] > Without the nonexistent function Page[i], i.e., just fourcircles[[i]], = the > four images are horizontally juxtaposed in the same page and not > on separate pages. > Another words, one table[[i]] graphic per one PDF page for four pages. > Don J. Orser For charts I use Column[] to get two charts on a page. Something like this: fshow[plots_, title_] := Framed[ Show[plots, PlotLabel -> DisplayForm[ GridBox[ { {Style[title[[1]], FontFamily -> Helvetica, Bold, Larger]}, {Style[title[[2]], FontFamily -> Helvetica]}, {If[Length[title] == 3, Style[title[[3]], FontFamily -> Helvetica, Small], ]} } ] ], Background -> None ], FrameMargins -> 20, ImageMargins -> 5 ]; graphs = { fshow[ a, titleLista ], fshow[ b, titleListb ], fshow[ c, titleListc ], fshow[ d, titleListd ], }; Export[ graphPath<>title<> 12.pdf,Column[{graphs[[1]], graphs [[2]]}]; Export[ graphPath<>title<> 34.pdf,Column[{graphs[[3]], graphs [[4]]}]; For tabular data, I use CellPrint to create a cell with a page break in the current notebook and then print to PDF from Mathematica - you might be able to adapt this for export purposes (i.e., export a cell to a file instead of a specific graphics object). In line, I use: CellPrint[ Cell[ , PageBreakBelow -> True ] ]; Hope that helps. === Subject: Re: Problem with an integral Mathematica can't find a closed form for unknown n and integral[nn_]:= FullSimplify[ Assuming[{k > 0 && Element[k, Integers]}, Integrate[Evaluate[fun/. n->nn], {x, 0, [Infinity]}]]] give you analytic, and finite results for the corresponding n Jens > Hi. I'm working with a little problem in Mathematica 7.0.0. > I want to integrate this function fun = x^(n + 1)*E^(-x + (I*k)/x) Assuming that both n and k are greater than zero, I write integral = FullSimplify[Assuming[{k > 0, n > 0}, Integrate[fun, {x, 0, > [Infinity]}]]] And I obtain a symbolic result. > But, when I want to put some specific value, like this integral /. {n -> 1, k -> 1} I obtain always ComplexInfinity, and/or other errors. > So, I've tried to evaluate numerically the integral for the same > specific values, in this way NIntegrate[Evaluate[fun /. {n -> 1, k -> 1}], {x, 0, [Infinity]}] And I obtain a finite numeric result. So, there's some error in > symbolic computation, or I miss something when I try to integrate the > formula? === Subject: Re: Problem with an integral Integrate gives a generic result, that is correct for almost all values, but does NOT take into account special behaviour for isolated values. E.g. set k=1 and look at the result from Assuming[{ n > 0}, Integrate[fun, {x, 0, [Infinity]}]]. The result has the form of a difference of 2 summands that both have no numerical value for n==1. Therefore, this formula can not be used for n==1. Due to numerical errors, it even fails for values of n close to 1. However, you may set k==1 and n==1, now Integrate gives the correct result. hope this helps, Daniel > Hi. I'm working with a little problem in Mathematica 7.0.0. > I want to integrate this function fun = x^(n + 1)*E^(-x + (I*k)/x) Assuming that both n and k are greater than zero, I write integral = FullSimplify[Assuming[{k > 0, n > 0}, Integrate[fun, {x, 0, > [Infinity]}]]] And I obtain a symbolic result. > But, when I want to put some specific value, like this integral /. {n -> 1, k -> 1} I obtain always ComplexInfinity, and/or other errors. > So, I've tried to evaluate numerically the integral for the same > specific values, in this way NIntegrate[Evaluate[fun /. {n -> 1, k -> 1}], {x, 0, [Infinity]}] And I obtain a finite numeric result. So, there's some error in > symbolic computation, or I miss something when I try to integrate the > formula? === Subject: Re: Problem with an integral > I'm working with a little problem in Mathematica 7.0.0. > I want to integrate this function fun = x^(n + 1)*E^(-x + (I*k)/x) Assuming that both n and k are greater than zero, I write integral = FullSimplify[Assuming[{k > 0, n > 0}, Integrate[fun, {x, 0, > [Infinity]}]]] And I obtain a symbolic result. > But, when I want to put some specific value, like this integral /. {n -> 1, k -> 1} I obtain always ComplexInfinity, and/or other errors. > So, I've tried to evaluate numerically the integral for the same > specific values, in this way NIntegrate[Evaluate[fun /. {n -> 1, k -> 1}], {x, 0, [Infinity]}] And I obtain a finite numeric result. So, there's some error in > symbolic computation, or I miss something when I try to integrate the > formula? First, a side note: as written above, the assumptions are passed to the command Integrate only. Write Assuming[{k > 0, n > 0}, FullSimplify[Integrate[fun, {x, 0, [Infinity]}]]] so FullSimplify takes into account the assumptions. But this is not the crux of the problem. Your expression exemplifies that in some cases one is better off not attempting any simplifications too early, and also, that the results can be sensitive to the assumptions made. In[1]:= fun = x^(n + 1)*E^(-x + (I*k)/x) Out[1]= (I k)/x - x 1 + n E x In[2]:= integral = Integrate[fun, {x, 0, [Infinity]}] Out[2]= (2 + n)/2 If[Im[k] > 0, 2 (-I k) BesselK[-2 - n, 2 Sqrt[-I k]], (I k)/x - x 1 + n Integrate[E x , {x, 0, Infinity}, Assumptions -> Im[k] <= 0]] In[3]:= integral /. {n -> 1, k -> 1} Out[3]= 3 1 1 4 (MeijerG[{{}, {}}, {{0, -, 2}, {-}}, --] + 2 2 16 1 3 1 I MeijerG[{{}, {}}, {{-, -, 2}, {0}}, --]) 2 2 16 In[4]:= % // N Out[4]= 1.67562 + 0.832688 I In[5]:= integral = Assuming[Element[k, Reals], Integrate[fun, {x, 0, [Infinity]}]] Out[5]= 1 -2 + n/2 If[Re[n] > -2, (- k Abs[k] 2 1/4 I n Pi 3/2 ((-1) E n Pi Abs[k] (BesselI[-1 - n, (1 + I) Sqrt[2] Sqrt[Abs[k]]] - BesselJ[-1 - n, (1 + I) Sqrt[2] Sqrt[Abs[k]]]) Csc[n Pi] + 2 I n Pi I k Pi (E BesselI[2 + n, (1 + I) Sqrt[2] Sqrt[Abs[k]]] - BesselJ[2 + n, (1 + I) Sqrt[2] Sqrt[Abs[k]]]) Csc[n Pi] + I n Pi 1/4 I k Abs[k] (2 E BesselK[-2 - n, 2 (-1) Sqrt[Abs[k]]] + I n Pi 1/4 Pi (E BesselJ[-2 - n, 2 (-1) Sqrt[Abs[k]]] - 1/4 BesselJ[2 + n, 2 (-1) Sqrt[Abs[k]]]) Csc[n Pi]))) / 3/4 I n Pi (I k)/x - x 1 + n E , Integrate[E x , {x, 0, Infinity}, Assumptions -> k [Element] Reals && Re[n] <= -2]] In[6]:= integral /. {n -> 1, k -> 1} During evaluation of In[6]:= [Infinity]::indet: Indeterminate expression 0 [Pi] ComplexInfinity encountered. >> Out[6]= Indeterminate In[7]:= integral = Assuming[Im[k] > 0, Integrate[fun, {x, 0, [Infinity]}]] Out[7]= (2 + n)/2 2 (-I k) BesselK[-2 - n, 2 Sqrt[-I k]] In[8]:= integral /. {n -> 1, k -> 1} Out[8]= 1/4 3/4 -2 (-1) BesselK[3, -2 (-1) ] In[9]:= % // N Out[9]= 1.67562 + 0.832688 I --Jean-Marc === Subject: Re: Problem with an integral Try Plot[{Abs[integral /. {k -> 1}] // Evaluate, NIntegrate[fun /. {k -> 1}, {x, 0, [Infinity]}] // Abs}, {n, 0, 4}] It looks like there are singularities on integer values of n (see the term Csc[n [Pi]] in the result of the integration). Near those singularities NIntegrate fails to work correctly. It warns about this by giving out two error messages. > Hi. I'm working with a little problem in Mathematica 7.0.0. > I want to integrate this function fun = x^(n + 1)*E^(-x + (I*k)/x) Assuming that both n and k are greater than zero, I write integral = FullSimplify[Assuming[{k > 0, n > 0}, Integrate[fun, {x, 0, > [Infinity]}]]] And I obtain a symbolic result. > But, when I want to put some specific value, like this integral /. {n -> 1, k -> 1} I obtain always ComplexInfinity, and/or other errors. > So, I've tried to evaluate numerically the integral for the same > specific values, in this way NIntegrate[Evaluate[fun /. {n -> 1, k -> 1}], {x, 0, [Infinity]}] And I obtain a finite numeric result. So, there's some error in > symbolic computation, or I miss something when I try to integrate the > formula? > === Subject: Re: production quality 2-D graphs with mathematica a) this depends on the journal ? b) since Mathematica 6 the default setting for the labels is TraditionalForm and Times, this should be sufficient for the most journals c) I have never seen that a journal want to have a line that is not a line and a point that is not the point. But Mathematica 6, and 7 are very flexible only the tendency to blue colors will cause some problems Jens > Most books and sites on mathematica graphics tend to focus on the very > impressive 3-D visualizations that mathematica can perform. However, what > are the resources for making a simple 2-D graph production/professional > quality? Another way of saying this is, > it seems the defaults for the lines, data points, and fonts for Plot[] ( > and related functions) are not for production quality. Are there any > examples of the options used for graphs which go into journals, papers, > reports, etc? === Subject: Re: production quality 2-D graphs with mathematica Below is an example of a publication quality plot I've made. It looks a bit messy in plain text of this email but works out just fine if you copy and paste (separately) each of these 4 cells back into Mathematica. r[pH_, O2_, Fe2_] := 7.9 10^-6 (O2 1.26 10^-3) Fe2 + 25 3.16 10^-10 10^pH (O2 1.26 10^-3) Fe2 + 7.9 10^6 2.51 10^-21 10^(2 pH) (O2 1.26 10^-3) Fe2 ticks[start_, stop_, division_] := Table[{i, i, {0, 0.02}, {Thickness[0.005]}}, {i, start, stop, division}] homogeneousiron = Plot[Log[10, r[pH, 0.2, Fe2]/Fe2 (24 60 60)/1], {pH, 1, 7}, PlotStyle -> {Thickness[0.005]}, PlotRange -> {{0.95, 7.05}, {-5.25, 2}}, BaseStyle -> {FontFamily -> TimesNewRoman, FontSize -> 12}, Axes -> False, FrameLabel -> {pH, log !(* StyleBox[Rate,nFontSlant->Italic]) (!(*SuperscriptBox[day, RowBox[{-, 1}]]))}, Frame -> True, FrameTicks -> {ticks[1, 7, 1], ticks[-5, 1, 1], {}, {}}, ImageSize -> 72 5, AspectRatio -> .67, FrameStyle -> Thickness[0.005], Epilog -> {Text[ 25Cn!(*SubscriptBox[P, SubscriptBox[O, 2]]) = 0.2 atmn!(* StyleBox[Rate,nFontSlant->Italic]) = -!(*FractionBox[ RowBox[{dlog, [, RowBox[{Fe, RowBox[{(, II, )}]}], ]}], dt]), {1.25, 1.5}, {-1, 1}]}] SetDirectory[NotebookDirectory[]] Export[C:Documents and SettingssmartinDesktophomogeneousiron.gif, homogeneousiron, ImageResolution -> 300] > Most books and sites on mathematica graphics tend to focus on the very > impressive 3-D visualizations that mathematica can perform. However, what > are the resources for making a simple 2-D graph production/professional > quality? Another way of saying this is, > it seems the defaults for the lines, data points, and fonts for Plot[] ( > and related functions) are not for production quality. Are there any > examples of the options used for graphs which go into journals, papers, > reports, etc? > === Subject: Re: =?windows-1252?Q?Why_isn=92t_the_increase_in_frequency=2Fperiodicity_of?= because your Piecewise[] functions are not periodic, i.e., the interval where the piece is defined is not Mod[_,somePeriod] Jens > Why isn't the increase in frequency/periodicity of this waveform not > showing up tia sal2 > I'm using the manipulate command to view what the wave form will look > like will look like if I increase the frequency. > But when I vary the variable =A1=A7a=A1=A8 to 3 the waveform only shows one > complete wave instead of 3 Example I vary the variable =A1=A7a=A1=A8 to 3 it should show 3 waveforms > repeating but instead it shows just 1 waveform in 1/3 the time. Here=A1=A6s an image of what it's doing along with the code > http://test.onewithall.net/math/waveform.jpg Here's the code below: tmin:=0 > tmax:=2 Pi > per1=Pi; > startPer1=0; > fpr1[t_]:={Sin[Mod[t-startPer1,per1]+startPer1],startPer1 startPer2=Pi; > fpr2[t_]:={.3*Sin[Mod[t-startPer2,per2]+startPer2],startPer2 [(a*2 Pi)*(t-(phase/360/a))]+c}],{t,tmin,tmax}],{{tmax,1,t Time > Scale},0,5 Pi,1,Appearance=84_Labeled},{{a,1,a Repeat Signal CPS}, > 0,1000,1,Appearance=84_Labeled},{{phase,0,Phase in degrees}, > 0,-360,.5,Appearance=84_Labeled},{{c,0,Offset C}, > 0,-294,1,Appearance=84_Labeled},{choice,{Plot,Expand}}] The reason why I'm doing this is that when I do periodic interpolation > the > Formula breaks down due to the Gibbs Phenomenon. The signals I'm > creating have > about 200 separate values thats why it breaks down. But I'm using a > simple example to see if it can be done. So I can basically stitch > multiple simple wave signals together to create one big complex one > and > still have the ability to increase the frequency of the complex signal > over time. Is there another way I should be doing this? I'm open to all > suggestions Tia sal2 > === Subject: Re: Why =?windows-1252?Q?isn=92t_the_increase_in_frequen?= Hi Tia, look e.g. at fpr1: there it says that you only want a result if t Why isn't the increase in frequency/periodicity of this waveform not > showing up tia sal2 > I'm using the manipulate command to view what the wave form will look > like will look like if I increase the frequency. > But when I vary the variable =A1=A7a=A1=A8 to 3 the waveform only shows one > complete wave instead of 3 Example I vary the variable =A1=A7a=A1=A8 to 3 it should show 3 waveforms > repeating but instead it shows just 1 waveform in 1/3 the time. Here=A1=A6s an image of what it's doing along with the code > http://test.onewithall.net/math/waveform.jpg Here's the code below: tmin:=0 > tmax:=2 Pi > per1=Pi; > startPer1=0; > fpr1[t_]:={Sin[Mod[t-startPer1,per1]+startPer1],startPer1 startPer2=Pi; > fpr2[t_]:={.3*Sin[Mod[t-startPer2,per2]+startPer2],startPer2 [(a*2 Pi)*(t-(phase/360/a))]+c}],{t,tmin,tmax}],{{tmax,1,t Time > Scale},0,5 Pi,1,Appearance=84_Labeled},{{a,1,a Repeat Signal CPS}, > 0,1000,1,Appearance=84_Labeled},{{phase,0,Phase in degrees}, > 0,-360,.5,Appearance=84_Labeled},{{c,0,Offset C}, > 0,-294,1,Appearance=84_Labeled},{choice,{Plot,Expand}}] The reason why I'm doing this is that when I do periodic interpolation > the > Formula breaks down due to the Gibbs Phenomenon. The signals I'm > creating have > about 200 separate values thats why it breaks down. But I'm using a > simple example to see if it can be done. So I can basically stitch > multiple simple wave signals together to create one big complex one > and > still have the ability to increase the frequency of the complex signal > over time. Is there another way I should be doing this? I'm open to all > suggestions Tia sal2 > === Subject: Re: 0^0 = 1? and Derive make a mistake, as expected. It is stuff from the elementary school that 0^0 is undefined because x^0 /; x!=0 is 1 but 0^x /; x!=0 is 0. Only if you have some sequences x[n] and y[n] with Limit[x[n],n->Infinity]==0 and Limit[y[n],n->Infinity]==0 you can take the limit Limit[x[n]^y[n],n->Infinity] and may get a defined result. Jens > Mathematica says 0^0 = Indeterminate > Derive says 0^0 = 1 May I have any opinions? Bruno > === Subject: Re: 0^0 = 1? Yet another, defensible, possibility would be that 0^0 is 0. This is a very old issue -- and I don't mean with Mathematica. Many programming language. My conclusion was that there is no really good answer, and what the value of 0^0 is should be a user-settable (global) option. Of course such an option is available in Mathematica: Unprotect[Power] Power[0,0] = 1 > Mathematica says 0^0 = Indeterminate > Derive says 0^0 = 1 May I have any opinions? Bruno > -- 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: 0^0 = 1? Mathematically, 0^0 is undefined, BECAUSE there's no definition that would always satisfy. Bobby > Mathematica says 0^0 = Indeterminate > Derive says 0^0 = 1 May I have any opinions? Bruno > -- DrMajorBob@longhorns.com === Subject: Re: 0^0 = 1? > Mathematica says 0^0 = Indeterminate > Derive says 0^0 = 1 May I have any opinions? It's a matter of convention (possibly convenience), domain (real or choice for Mathematica) quite clearly. --Jean-Marc http://mathworld.wolfram.com/Zero.html === Subject: Re: 0^0 = 1? Well, 0^a for any real number a other than 0 is clearly zero. And a^0 for any real number a other than 0 is clearly one. Therefore, I'd say that Indeterminate is a reasonable value for 0^0. Search in this group about ways to make your own defintion of 0^0. > Mathematica says 0^0 = Indeterminate > Derive says 0^0 = 1 May I have any opinions? Bruno === Subject: Re: 0^0 = 1? > Mathematica says 0^0 = Indeterminate > Derive says 0^0 = 1 May I have any opinions? Bruno > Concrete Mathematics by Graham, Knuth and Patashnik says 0^0 = 1 for purposes of discrete mathematics so the binomial theorem is valid for x = 0, y = 0, and/or x = -y. As they say: The theorem is too important to be arbitrarily restricted! By contrast, the function 0^x is quite unimportant. Kristjan ************************************************************************ Caution, in any case, may in reality be recklessness. We must always look at the cost of doing nothing. -- Crispin Tickell === Subject: Re: 0^0 = 1? 0^0 means the limit if both base and exponent go to zero. But this statement alone is insuffucient, because it does neither say with which speed they go to zero, nor does it give the direction. If both have the same speed: Limit[x^x,x->0] we get 0 If the base goes much faster to zero: Limit[( 1/Exp[1/x])^( x), x -> 0] we get less than 1: 1/E. Or even faster: Limit[( 1/Exp[1/x^2])^( x), x -> 0] we get 0. Now, if we take the limit from the right side (below 0): Limit[( 1/Exp[1/x^2])^( x), x -> 0, Direction -> 1] we get Infinity. If we take complex numbers, there are more direction to choose from. Therefore, it make sense to say that 0^0 is undefined. However, sometimes it is convenient to set 0^0->1, provided one knows what one is doing. hope this helps, Daniel > Mathematica says 0^0 = Indeterminate > Derive says 0^0 = 1 May I have any opinions? Bruno > === > [Unless your TeX input has some error, in which case the typeset > output > will only appear up a point where the error occurs; a description > and > explanation of the error will appear in a third log window -- = > an= > d > hitting some other key combo will take you back to the input > window > **with the cursor positioned at the point or line where the error > was > encountered.] > This has been the case for many years. >> Amazing. That means they must have produced a mind-reading >> version of >> TeX that I am not aware of. In all versions that I know (and I have >> been using TeX,LateX,Ams-Latex etc for decades) the cursor will >> appear not at the place where the error (for example a missing >> right >> brace })occurred but at the place where TeX first notices some >> inconsi= > stency >> with its syntax - which is almost never the place where the error >> actually occurred. At that point you have got to manually find the >> actual error, which can be far from simple. The only TeX >> implementation that I know that partly gets around this problem is >> the Mac TeX system Textures = (http://www.bluesky.com/products/products_= > frames. > html >> ), which continually typesets your output as you type (without the >> need to hit any keys), which usually will make you aware of an >> error >> as soon as it occurs rather than much later, when you try to >> typeset >> the you course code. Moreover, Textures has several other nice >> features that are implemented only imperfectly in other versions. = >> But >> there are major caveats - a Mac OS X version is still only in beta, >> years after Mac OS X occurred, and Textures costs hundreds of >> dollars. >> But, and here is something anyone considering TeX should carefully >> ponder upon. Before Mac OS X appeared, there were many persons >> (including myself) willing to pay hundreds of dollars for Textures >> and more for regular upgrades, in spite of the fact that lots of = >> free = > TeX >> implementations have always existed on the Mac (I myself now use = >> TeX >> Shop with Japanese PTex engine). This was because TeXtures avoids = >> the >> huge amount of hassle that installing and using TeX is for any >> beginner and even for an experienced user. Then Blue Sky, the >> company >> that makes Textures, failed to come up with a Mac OS X compatible >> version and most users reluctantly drifted away to other programs. >> But if you look mailing lists where TeX on Mac OS is discussed >> you wil= > l >> find that many are intending to return (even though it will cost = >> them >> money) as soon as a full featured version is again available. Which >> only proves that standard, free implementations of TeX are far form >> the sort of thing some make them out to be. I strongly recommend = >> you >> to try TeX, but I suspect you will be soon back to using >> Mathematica >> (if not Word). > Have you tried installing TeXLive? > -- m >> Yes. It certianly makes keeping up to date with various packages >> easier, but I don't think it addresses the issues I mentioned and >> does >> not have the features Textures offers (or used to). Among these were: >> 1. Continuously updated preview Urgh. Why would you want that? What's next, Clippy?!! :) > 2. Traffic light - an interactive device that keeps you informed >> while you are typing if your input is syntactically correct (so you >> can catch errors as they occur Any decent editor will have syntax highlghting, which is > good enough to catch commor errors. The uncommon ones (TeX > is essentially impossible to syntax check!) are uncommon ;-) > 3. Synchronicity. Command-click on any text in the preview and you = >> are >> taken to the corresponding point in your source code. Do the same to >> any word in the source code and you are taken to the right place in >> the preview. You can do this using xdvi and vim; I imagine emacs > does it also, but I do not speak emacs. Add xdvi.editor: gvim --servername xdvi --remote +%l %f to ~/.xdvirc, and compile using latex --src-specials=cr,display,hbox,math,par,hbox ... and start editing uxing gvim --servername xdvi myfile.tex or vimx --servername xdvi myfile.tex When you then ctrl-click on something in xdvi, vim jump > to the correct position in the source. On the other hand, add map :call system(xdvi -sourceposition . > string(line('.')) . expand(%:r)) (This should be in one line, I guess) to your ~/.vimrc; > then pressing F1 while editing a tex file will result in > xdvijumping to that position. I understand that you can do this also with PDF, assuming > your PDF previewer has the necessary support, but I have > never tried. > You should really consider Auctex. -- m > Hmm... I don't think you have won very many friends for TeX with this post (me, I have been using TeX for over 20 years, so I am kind of resigned to it...). In particular, I am sure AES must have loved it, particularly in view of his repeated complaints about how arcane Mathematica some commands are (compared to what?) Andrzej Kozlowski= === Subject: Tab and Cursor Arrow Key Bindings Hi Does anybody know how to map a key binding so up and down arrows can tab and reverse tab through dialog fields? On the default setup 'Tab' advances through fields and 'Shift-Tab' does nothing. SystemFilesFrontEndTextResourcesWindows KeyEventTranslations.tr has bindings for Tab, Up and Down but changing their actions hasn't affecting their behaviour, puzzlingly. === Subject: A question about Mathematica I found this email address from www.mathematica-users.org as the reference that I can ask my questions about mathematica. I have not used Mathematica yet. but for one of the tasks in my research I have been told that Mathematica can be useful. My question is following: *I have couple of first order differential equations, and I want to change some variables, which I know would simplified the equations. I was wondering if you can help me with it. The equations are: m dot U + mQW + mg sin{theta} + dot Q (lambda_a eta_a + lambda_f eta_f ) + 2Q(lambda_a dot eta_a + lambda_f dot eta_f ) = F_x m dot W - mQU - mg cos{theta} + lambda_a ddot eta_a + lambda_f ddot eta_f - Q^2 (lambda_a eta_a + lambda_f eta_f ) = F_z (I_{yy} + eta_a^2 + eta_f^2)dot Q + (dot U + QW)(lambda_a eta_a + lambda_f eta_f ) + 2Q(eta_a dot eta_a + eta_f dot eta_f) - psi_a ddot eta_a - psi_f ddot eta_f = M ddot eta_f + (dot W - QU) lambda_f -dot Q psi_f + 2zeta omega_f dot eta_f + (omega_f^2 - Q^2) eta_f = N_f ddot eta_a + (dot W - QU) lambda_a -dot Q psi_a + 2zeta omega_a dot eta_a + (omega_a^2 - Q^2) eta_a = N_a and my change of variable is: tan{alpha} = W/U V_T^2 = U^2 + W^2 * M. Shakiba. === Subject: Re: Newbie Question - Change 3D Bar Chart Background Color Hi Tim, BarChart3D[{1, 2, 3}, ChartStyle -> Red] may do what you want. As to documentation: have you tried putting your cursor in the word BarChart3D, pressing F1, and in the resulting documentation page press the More Information box tight below the syntax info? > I am struggling in changing the background (the X and Y plane) in this > example from blue to any other color. BarChart3D[{1, 2, 3}] Also I **believe** I have looked ever where in the documentation about the > available options for BarChart3D.... Where would I find a comprehensive > recap of what can be done? === Subject: Extracting Graphics3D from Plots a problem I have been struggling for quite a while is how to extract a manipulatable Graphics3D object from the result of e.g. a Plot3D or RevolutionPlot3D call. By manipulatable I mean an object I can rotate or translate using RotationTransform and then combine with other objects such as Cylinder. What I do not intend to do is use Epilog in a Plot3D call. I am actually looking for the CORRECT Mathematica-way, i.e. the one anticipated by the Wolfram people and not some workaround that might fail in future versions of Mathematica. Somewhat related is another question. Is it possible to put a texture on a Cylinder, Tube or Cone? I do know how to place an image onto the surface of a Plot3D output (in a seemingly correct Mathematica way, see below). Ernst img = Import[ExampleData/rose.gif] imgS = Rasterize[img, Data, RasterSize -> {32, 32}]/255.0; Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, = ColorFunction -> (RGBColor[ imgS[[1 + Round[10 #1], 1 + Round[10 #2]]]] &), = ColorFunctionScaling -> False, Mesh -> False, PlotPoints -> 32] === Subject: Re: Formatting in text cells ... [Mail from David below.] Hi David, It seems that the problem arises from the fact that you formatted the text cell with TraditionalForm instead of keeping it at its default TextDisplay. As far as I can see, inline equations are already done in TraditionalForm, so there is no need to select this style for the whole text cell (or perhaps your using a style that does that?). Here is the cell that I get when I type it myself: Cell[TextData[{ Any single arbitrarily oriented dipole source can be represented by two scalar potentials , Cell[BoxData[ FormBox[ SubscriptBox[F, z], TraditionalForm]], FormatType->TraditionalForm], for vertical electric dipoles, and , Cell[BoxData[ FormBox[ SubscriptBox[G, z], TraditionalForm]], FormatType->TraditionalForm], for vertical magnetic dipoles. Since in a horizontally - layered earth, there can be no vertical magnetic field from a vertical electric dipole, fields from a vertical etc. etc. }], Text, CellChangeTimes->{{3.44165000465625*^9, 3.44165024390625*^9}}] In your cell expression I see things like: RowBox[{ SubscriptBox[F, z], , for, , vertical, , electric, , dipoles}] which cause parts of the sentence to be seen as independent units. Don't know whether this solves your printer problem. Haven't tested that. Hi Sjoerd, > wrt to your first question: I don't seem to have this problem. Could > you post an example of a cell that's having this problem? In the following cell, I get Mathematica-imposed new lines after potentials & earth. When printing, everything after the F(sub)z has a dark background. This is the first time I've seen the background effect but other cells in the notebook, though not all, have the line-break issue. It's the random nature of the effect that's worrying as well as the apparent non-fixableness (yes -- that is a word -- now) of the problem. Dave. An example cell is Cell[TextData[{ Any single arbitrarily oriented dipole source can be represented by two scalar potentials , Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ SubscriptBox[F, z], , for, , vertical, , electric, , dipoles}], ,, , RowBox[{ RowBox[{and, , SubscriptBox[G, z], , for, , vertical, , magnetic, , RowBox[{dipoles, ., , Since}], , in, , StyleBox[a, FontSlant->Plain], , horizontally}], -, RowBox[{layered, , earth}]}], ,, , RowBox[{ there, , can, , be, , no, , vertical, , magnetic, , field, , from, , a, , vertical, , electric, , dipole}], ,, , RowBox[{fields, , from, , StyleBox[a, FontSlant->Plain], , vertical, , electric, , dipole, , are, , called, , the, , transverse, , magnetic, , mode, , RowBox[{ RowBox[{(, TM, )}], ., , Analagously}]}], ,, , RowBox[{ fields, , from, , the, , vertical, , magnetic, , dipole, , are, , called, , the, , transverse, , electric, , mode, , RowBox[{ RowBox[{(, TE, )}], .}]}]}], TraditionalForm]]] }], Text, CellChangeTimes->{{3.441396065459997*^9, 3.4413961117040772`*^9}, { 3.4413978031905613`*^9, 3.441398018532933*^9}, { 3.4413993977116065`*^9, 3.4413993988365993`*^9}, { 3.441482720735684*^9, 3.4414827238028393`*^9}}, TextJustification- >0., FontFamily->Arial] > Hi Dave, wrt to your first question: I don't seem to have this problem. Could > you post an example of a cell that's having this problem? > Recently, (actually inspired by the What editor ... thread) I have > had occasion to use Mathematica 7 as a text entry tool -- explanatory > text followed by numbered equations, followed by more text & more > numbered equations. By and large, it's proving an easier environment > for this sort of task than MS Word (and equation editor), though not > nearly as easy as WordPerfect's equation editor from 5.1 / 6 days. > I have two (!) problems. > 1. Text cells are just fine unless they include explanatory text with > either super or subscripts. When these are involved, it seems that > justification rules go out the window; one line might end halfway > across the window while another might go all the way to the end of the > window. I can get this effect simply by having something like > Subscript[F, z] in the middle of a text cell, and on looking a little > closer, commas appear to be the signal to start a new line > irrespective of whether it's appropriate to do so. How can I get tex= t > cells to run to the end of the window when they are long enough to do > so, and still contain symbols with super & subscripts? > 2. Upon printing, some _parts_ cells which contain text as well as > symbols and super & subscripts are printed with a darker background. > Why is this, and more importantly, how do I get rid of it? > Dave. === Subject: Experimental NumericalFunction::dimsl fails with the undocumented error like: Experimental`NumericalFunction::dimsl: {1.00031} given in should be a list of dimensions for a particular argument. Would someone be able to suggest what this error means? Stuart -- UTS CRICOS Provider Code: 00099F DISCLAIMER: This email message and any accompanying attachments may contain confidential information. If you are not the intended recipient, do not read, use, disseminate, distribute or copy this message or attachments. If you have received this message in error, please notify the sender immediately and delete this message. Any views expressed in this message are those of the individual sender, except where the sender expressly, and with authority, states them to be the views the University of Technology, Sydney. Before opening any attachments, please check them for viruses and defects. === Subject: Re: message-driven function: more explanation Hi Bert, nothing exotic here. The return value is a function that consits of a Switch statement: changeCounter$448[msg$_String:++]:=Switch[msg$, ++,counter$448=counter$448+1;counter$448, --,counter$448=counter$448-1;counter$448, value,counter$448, reset,counter$448=100;counter$448, _,Print[Unknown message to counter:,msg$];counter$448] As you see, the Switch simply compares the strings. hope this helps, Daniel > In the book Programming Paradigms with Mathematica > http://library.wolfram.com/infocenter/MathSource/1847/ > in the notebook Hw21.nb there is following function: Clear[makeCounter]; > makeCounter::usage=makeCounter[] returns a message-driven function > which manipulates a hidden counter variable. The initial value > of the counter variable may be set via an optional argument to > makeCounter (default is 0). Valid messages for the function are > ++ (increment), -- (decrement), value, and reset. > For example, ctr = makeCounter[100]; ctr[value] returns 100.; makeCounter[ > defaultValue_Integer:0 > ] := > Module[ > { counter = defaultValue, > changeCounter > }, > changeCounter[msg_String:++] := > Switch[msg, > ++, > counter = counter + 1; counter, > --, > counter = counter - 1; counter, > value, > counter, > reset, > counter = defaultValue; counter, > _, > Print[Unknown message to counter:, msg]; > counter > ]; > changeCounter > ]; ctr = makeCounter[100] > ctr[value] > ctr[++] gives as output changeCounter$723 > 100 > 101 Where can I find more explanation of this type of message-driven function? > === Subject: Re: 0^0 = 1? > 0^0 means the limit if both base and exponent go to zero. No, that is not how 0^0 is defined. Does 2+2 mean the limit as both summands go to 2? The value may happen to be the same in that case, but that is not how 2+2 is defined. The value of x^y for cardinal numbers x and y is the cardinality of the set of mappings from y into x. In the case where x and y are the empty set, there is exactly one such mapping. Hence, 0^0 = 1. It's a theorem of ZF (as stated in Suppes, _Axiomatic_Set_Theory_) that m^0 = 1 for every cardinal number m. Another way is to notice that 0^0 represents an empty product, whose value is the identity element in the monoid of the integers (or the reals). In[1]:= Product[0,{k,0}] Out[1]= 1 One might also consider the series expansion for Exp[0], which reduces to 1 = 0^0/0! + (lots of terms that all reduce to zero). Having x^y be discontinuous at (0,0) does not cause problems any more than having the Sign function be discontinuous at 0 causes problems. Anyone who works with limits should be aware that you can't just blindly assume continuity when evaluating limits. You have to consider the actual definition of the limit. -- Dave Seaman Third Circuit ignores precedent in Mumia Abu-Jamal ruling. === Subject: Re: Problem with an integral When I see an expression like: fun = x^(n + 1)*E^(-x + (I*k)/x) it always makes me cringe a little. That is because it has parameters and a variable and it is always better to make these a part of the definition. So I would write: fun[n_, k_][x_] := x^(n + 1)*E^(-x + (I*k)/x) Then if I wanted to see precisely what I was doing, I would use the Student's Integral section of the Presentation package. Needs[Presentations`Master`] integrate[fun[1, 1][x], {x, 0, [Infinity]}] % // UseIntegrate[] % // N giving... !( *SubsuperscriptBox[([Integral]), (0), ([Infinity])](( *SuperscriptBox[(E), ( *FractionBox[(I), (x)] - x)] *SuperscriptBox[(x), (2)]) [DifferentialD]x)) 4 (MeijerG[{{}, {}}, {{0, 3/2, 2}, {1/2}}, 1/16] + I MeijerG[{{}, {}}, {{1/2, 3/2, 2}, {0}}, 1/16]) 1.67562 + 0.832688 I If one wanted to do simplifications on the integrand or use other integration techniques after the first step, that could also be done. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hi. I'm working with a little problem in Mathematica 7.0.0. I want to integrate this function fun = x^(n + 1)*E^(-x + (I*k)/x) Assuming that both n and k are greater than zero, I write integral = FullSimplify[Assuming[{k > 0, n > 0}, Integrate[fun, {x, 0, [Infinity]}]]] And I obtain a symbolic result. But, when I want to put some specific value, like this integral /. {n -> 1, k -> 1} I obtain always ComplexInfinity, and/or other errors. So, I've tried to evaluate numerically the integral for the same specific values, in this way NIntegrate[Evaluate[fun /. {n -> 1, k -> 1}], {x, 0, [Infinity]}] And I obtain a finite numeric result. So, there's some error in symbolic computation, or I miss something when I try to integrate the formula? === Subject: Re: Problem in generating a IF cycle which Mathematica Hi Sjoerd, Jens and others... thank you very much for your suggestions. If I didn't use always your modifications is because my Professor preferred not follow that way... may be he is '50ish ;-) He wanted me to use the DO cycle! Valeria 2009/1/22 Sjoerd C. de Vries of your last post. > === Subject: Re: bug in LinearProgramming Hi Veit, I think this is simply a bug with the recognition of conditions. In your case, the second condition is ignored. If you change b to: {{1, 0}, {0, 0}, {0, 1}} the third condition is ignored. Please send this to Wolfram. Daniel > This is a re-post because the original did not draw any comments. > The data > c = {1, 1}; > m = {{1, 0}, {1, -2}, {-1, 1}}; > b = {{1, 0}, {0, 1}, {0, 1}}; > lu = {{0, 1}, {0, 1}}; > d = {Reals, Reals}; > used in > LinearProgramming[c, m, b, lu, d] > corresponds to the problem > minimize x1+x2 > subject to the constraints > x1 == 1, x1-2*x2 >= 0, -x1+x2 >= 0 > with real variables in the ranges > 0 <= x1 <= 1, 0 <= x2 <= 1 > It's clear that this problem has no solution, and Mathematica > recognizes this fact. > But when the domain of x2 is changed to Integers, Mathematica returns > the solution > x1 == 1., x2 == 1 > This violates the constraint x1-2*x2 >= 0. **** earlier posting **** > Here is a simple linear programming problem: c = {1, 1}; > m = {{1, 0}, {1, -2}, {-1, 1}}; > b = {{1, 0}, {0, 1}, {0, 1}}; > lu = {{0, 1}, {0, 1}}; > d = {Reals, Reals}; sol = LinearProgramming[c, m, b, lu, d] Mathematica 6 returns: LinearProgramming::lpsnf : No solution can be found that > satisfies the constraints. which is obviously correct. But if I change the domain of the second > variable, d = {Reals, Integers}; then Mathematica gives the solution sol = {1., 1}. The problem is that m.sol = {1., -1., 0.} violates the bound vector b (second component should be greater than 0). > Is there a bug, or am I getting the syntax wrong? Veit Elser > === Subject: Re: slots with 2 indexed array? data = {{1, 2, 3}, {4, 5, 6}}; Map[g, data, {2}] {{g[1], g[2], g[3]}, {g[4], g[5], g[6]}} data = sigs = Table[10 i + j, {i, 4000}, {j, 1024}]; len = Length[sigs]; f = If[# >= 2048, # - 2048, # + 2048] &; Timing[For[i = 1, i < len + 1, i++, sigs[[i]] = f /@ sigs[[i]]]] {1.3219,Null} Timing[res = Map[f, data, {2}];] {0.833989,Null} Verifying that Map performs the same function sigs == res True Bob Hanlon First I produce some dummy data, 4000 of what I call signals, 1024 samples each. sigs = Table[10 i + j, {i, 4000}, {j, 1024}]; len = Length[sigs]; I'd like to modify these signals. The For statement below works. I can use a slot function on each of the sigs specified by i. For[i = 1, i < len + 1, i++, sigs[[i]] = If[# >= 2048, # - 2048, # + 2048] & /@ sigs[[i]] ] Surely there's a way to use slots on a double indexed array but I haven't found it yet. If I try to let # represent every entry in sigs, the If statement isn't processed: sigs = If[# >= 2048, # - 2048, # + 2048] & /@ sigs; I tried Which that Help says uses HoldAll but that doesn't work either; Which[] still isn't evaluated. I tried using #2 and ## instead of # but that doesn't work. In reading about slot functions I haven't seen any examples using multi indexed arrays. === Subject: Frames on Density Plots in Version 7 When I submitted this to support they said they couldn't reproduce the problem. It may be platform dependent. (I'm working on Windows 32-bit Vista.) In the following plots the upper frame line is missing but the ticks are present. DensityPlot[x y, {x, 0, 1}, {y, 0, 1}] VectorDensityPlot[{Sin[x], Cos[y]}, {x, 0, 2 [Pi]}, {y, 0, 2 [Pi]}] In Version 6 the first one displays correctly, and the second plot doesn't exist. This problem is easily corrected by adding an ImagePadding option, but still it would be annoying to casual users. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Issue with Sum Version7 > Anyone seen this: In[120]:= > Sum[i, {i, 0, 99999, .1}] Out[120]= 4.99991*10^10 In[121]:= > Sum[i, {i, 0, 100000, .1}] Out[121]= Sum[i, {i, 0, 100000, 0.1}] On Mac OS X 10.5.6 Brian I confirm this on v.7: In[1]:= Sum[i, {i, 0, 100000, .1}] Out[1]= Sum[i, {i, 0, 100000, 0.1}] But in v. 5.2 it is OK: In[1]:= Sum[i,{i,0,100000,.1}] Out[1]= !(5.000005`*^10) === Subject: Re: Issue with Sum Version7 another bug that was introduced in version 7. Please send it to Wolfram. Daniel > Anyone seen this: > In[120]:= > Sum[i, {i, 0, 99999, .1}] Out[120]= 4.99991*10^10 In[121]:= > Sum[i, {i, 0, 100000, .1}] Out[121]= Sum[i, {i, 0, 100000, 0.1}] On Mac OS X 10.5.6 Brian > === Subject: Re: Issue with Sum Version7 > Anyone seen this: > In[120]:= > Sum[i, {i, 0, 99999, .1}] Out[120]= 4.99991*10^10 In[121]:= > Sum[i, {i, 0, 100000, .1}] Out[121]= Sum[i, {i, 0, 100000, 0.1}] On Mac OS X 10.5.6 No, though I am not sure what the question was... In[1]:= Sum[i, {i, 0, 99999, .1}] Out[1]= 4.99991*10^10 In[2]:= Sum[i, {i, 0, 100000, .1}] Out[2]= 5.00001*10^10 In[3]:= $Version Out[3]= 6.0 for Mac OS X x86 (64-bit) (May 21, 2008) --Jean-Marc === Subject: Re: Issue with Sum Version7 this is a bug but: Sum[i, {i, 0, 100000, 1/10}] may work as well as Sum[i, {i, 0, 100000, 0.1}] //N Jens > Anyone seen this: > In[120]:= > Sum[i, {i, 0, 99999, .1}] Out[120]= 4.99991*10^10 In[121]:= > Sum[i, {i, 0, 100000, .1}] Out[121]= Sum[i, {i, 0, 100000, 0.1}] On Mac OS X 10.5.6 Brian > === Subject: Re: Basic questions on list manipulation in the Mathematica Way > This idea of a function as a database can be used even more: ClearAll[data]; > data[Thomas Jefferson, val1] = 12; > data[Thomas Jefferson, val2] = 34; > data[Thomas Jefferson, val3] = 56; > data[Thomas Jefferson, val4] = 78; > data[George Washington, val1] = 91; > data[George Washington, val2] = 234; > data[George Washington, val3] = 567; > data[George Washington, val4] = 893; > data[John Kennedy, val1] = 21; data[John Kennedy, val2] = 33; > data[John Kennedy, val3] = 444; data[John Kennedy, val4] = > 555; > data[Barack Obama, val1] = 377; data[Barack Obama, val2] = 12; > data[Barack Obama, val3] = 34; > data[Barack Obama, val4] = 5534; Modification of a value is now simply a redefinition of the function: data[Thomas Jefferson, val1] = 4444; This has the disadvantage that it is difficult to collect all values > of val1. I agree that this is a useful scheme for storing data in mathematica, but I don't agree that it is difficult to collect all values of e.g. val1. Just use DownValues, the following does collect all val1 entries: Select[DownValues[data], Not[FreeQ[#, val1]] &] (of course there are myriads of other possibilities to collect whatever you need to once you have the DownValues...) Another very useful but not very common pattern I often use are SubValues for this purpose, by defining e.g. data[Thomas Jefferson][val1] = 12; data[Thomas Jefferson][val2] = 34; data[Thomas Jefferson][val3] = 56; data[Thomas Jefferson][val4] = 78; data[George Washington][val1] = 91; data[George Washington][val2] = 234; data[George Washington][val3] = 567; data[George Washington][val4] = 893; data[John Kennedy][val1] = 21; data[John Kennedy][val2] = 33; data[John Kennedy][val3] = 444; data[John Kennedy][val4] = 555; data[Barack Obama][val1] = 377; data[Barack Obama][val2] = 12; data[Barack Obama][val3] = 34; data[Barack Obama][val4] = 5534; using this definitions, you can do something like this: mrpresident = data[Barack Obama] mrpresident[val1] or, if you like: mrpresident@val1 collecting data can now be done by filtering SubValues[data] accordingly. > Of course, you could also use external databases, see DatabaseLink/ > tutorial/Overview in the help centre. and not only just using DatabaseLink on its own is interesting, with the above scheme(s) and taking advantage of the fact that you can mix regular definitions with delayed ones you can also easily build something like e.g. a database read cache which only looks up entries in the database that it hasn't seen before, with something like: (* open demo database which comes with mathematica: *) Needs[DatabaseLink`] $demo=OpenSQLConnection[demo] (* definition for unseen entries: fetch them from database and put them in SubValues *) ClearAll[democache] democache[namex_String][propx_String]:=Module[{val}, Quiet[ val=SQLSelect[ propx, SQLColumn[Name]==namex ] ]; If[val=!=$Failed[And]Length[val]>0, With[{ name=ToUpperCase[namex], prop=ToUpperCase[propx] },democache[name][prop]=val[[1,1]]], $Failed,$Failed ] ] (* example usage and checks what is there: *) democache[Day3][Value] SubValues[democache]//TableForm (* some syntactic pleasantries which are for free: *) day=democache[Day3]; day[Value] day@Entry day@Name (* don't forget to close the SQLConnection when you are done: *) CloseSQLConnection[$demo] hth, albert === Subject: Re: Basic questions on list manipulation in the Mathematica Way > An alternative to your field modification code... First, let's get us > a data set in your style: In[79]:= ClearAll[data]; > data = > { > {Thomas Jefferson -> {val1 -> 12, val2 -> 34, val3 -> 56, > val4 -> 78}}, > {George Washington -> {val1 -> 91, val2 -> 234, val3 -> 567, > val4 -> 893}}, > {John Kennedy -> {val1 -> 21, val2 -> 33, val3 -> 444, > val4 -> 555}}, > {Barack Obama -> {val1 -> 377, val2 -> 12, val3 -> 34, > val4 -> 5534}} > }; Examining an entry: In[84]:= Thomas Jefferson /. Flatten[data] Out[84]= {val1 -> 12, val2 -> 34, val3 -> 56, val4 -> 78} I used Flatten because the rules are nested a level too deep. You > could remove the {} around each individual. Getting to one of its fields: In[89]:= val1 /. (Thomas Jefferson /. Flatten[data]) Out[89]= 12 Modification of a field: In[87]:= data=data /. > HoldPattern[{Thomas Jefferson -> {a___, val2 -> x_, > b___}}] -> {Thomas Jefferson -> {a, val2 -> 4444, b}} Out[87]= {{Thomas Jefferson -> {val1 -> 12, val2 -> 4444, > val3 -> 56, val4 -> 78}}, {George Washington -> {val1 -> 91, > val2 -> 234, val3 -> 567, > val4 -> 893}}, {John Kennedy -> {val1 -> 21, val2 -> 33, > val3 -> 444, val4 -> 555}}, {Barack Obama -> {val1 -> 377, > val2 -> 12, val3 -> 34, val4 -> 5534}}} Note that since the data set consists of rules, using a rule for > replacement needs some precausions otherwise the wrong rule is > applied. The HoldPattern takes care of that. A slight modification prevents the necessity of providing the > attribute name twice: data /. HoldPattern[{Thomas Jefferson -> {a___, y:val3 -> x_, > b___}}] -> {Thomas Jefferson -> {a, y -> 4444, b}} Now for other possible data structures: If the attribute types are the same for all individuals you could use > a plain list like this: data = > { > {Thomas Jefferson, 12, 34, 56, 78}, > {George Washington, 91, 234, 567, 893}, > {John Kennedy, 21, 33, 444, 555}, > {Barack Obama, 377, 12, 34, 5534} > }; So, every column corresponds to a certain attribute. > Modifications could be done like this: data = data /. {Thomas Jefferson, x_, y_, z_, > w_} -> {Thomas Jefferson, 4444, y, 1111, w} This code is easily readable and understandable, but modification in > this simple way also means copying the whole database which may be a > problem if it's huge. In that case, one should use indexes. An alternative would be the following, in which the database is a > function: ClearAll[data]; > data[Thomas Jefferson] = {12, 34, 56, 78}; > data[George Washington] = {91, 234, 567, 893}; > data[John Kennedy] = {21, 33, 444, 555}; > data[Barack Obama] = {377, 12, 34, 5534}; data[Thomas Jefferson] = > data[Thomas Jefferson] /. {x_, y_, z_, w_} -> {4444, y, 1111, w} This idea of a function as a database can be used even more: ClearAll[data]; > data[Thomas Jefferson, val1] = 12; > data[Thomas Jefferson, val2] = 34; > data[Thomas Jefferson, val3] = 56; > data[Thomas Jefferson, val4] = 78; > data[George Washington, val1] = 91; > data[George Washington, val2] = 234; > data[George Washington, val3] = 567; > data[George Washington, val4] = 893; > data[John Kennedy, val1] = 21; data[John Kennedy, val2] = 33; > data[John Kennedy, val3] = 444; data[John Kennedy, val4] = > 555; > data[Barack Obama, val1] = 377; data[Barack Obama, val2] = 12= ; > data[Barack Obama, val3] = 34; > data[Barack Obama, val4] = 5534; Modification of a value is now simply a redefinition of the function: data[Thomas Jefferson, val1] = 4444; This has the disadvantage that it is difficult to collect all values > of val1. Of course, you could also use external databases, see DatabaseLink/ > tutorial/Overview in the help centre. > I have some basic questions about using lists in Mathematica. > Specifically I have a table that serves as sort of a database with the > following structure: > ct = { > { sym1 -> {val1->20, val2->300, val3->1000, ... }, > { sym2 -> {val1->50, val2->500, val3->20000,...}, > ... > } > sym1, sym2, ... are people and val1, val2 ... represent attributes of > each person. > Now I'm trying to go in and modify values. I can do it, but I think > not well and I think with a programming language mindset instead of > a Mathematica mindset. > Here is my specific question. In order to change a specific value in > the list above (valxxx) for a given individual (symxxx), I created > this function: > changeVal[ who_, class_, amnt_ ] := ( > ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]] = > ReplacePart[ ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]], > Position[ ct[[ Position[ ct, who ][[ 1, 1 ]] ]], class ][[ 1= , > 2 ]] -> (class -> amnt) ] > ); > Now I know there is a better way than that using list manipulation and > patterns. Can some of you experienced pros help me out? I call th= is > write only code because I don't know that I could explain it once > it's written. > Perhaps a more fundamental question: is this the right way to store > data in lists? Or would it be better to just have the values and > reference them by index number? > deep requiring Flatten all the time. === Subject: Re: Using Coefficient on an equation But caution: First[0==a*x^2] and First[a*x^2==0] do not return the > same result. After a Simplify they do. > Right. Unless and until Simplify changes its handling of Equal. Which is to say, if you preprocess with Simplify to do this then you are relying quite heavily on magic rather than sound code. And slow magic at that (but my guess is your primary focus is on the stability, not speed.) Much safer is to preprocess equations by subtracting rhs from lhs. Could use maybe exprs = eqns /. Equal[a_,b_]:>a-b; Now you can use Coefficient as before. Daniel Lichtblau Wolfram Research === Subject: Re: Which editor do you use for math My advice? Stick to Mathematica and/or Word. (Unless you're willing to learn LaTeX from the ground up, the hard way.) I spent several hours last night sleuthing how to use Mac fonts in LyX, which led to using them in TeXShop, which led to indecipherable instructions for using LyX with XeTex, which led to utter confusion. I found a LyX document that explained and demonstrated how to do this; but that document explained exactly nothing and could not be typeset, neither with LaTeX NOR XeTeX. Trying to do so popped up error messages (like the ones mentioned below). Explanations (and ERROR messages) FREQUENTLY repeated the equivalent of, If you use *nix, you'll be able to figure this out. No need to explain it, or Make like Sherlock Holmes, and look for clues. Apparently, the developers of this stuff MAY be a lot wise-a**es who'd rather, really, have nobody else use their code. Or, at least, they can't be bothered with meaningful documentation or installers that do the full job. Bobby > [...] >> LaTeX had all kinds of problems. Figures never appeared where you >> wanted them. Thus the h! flag. Most of the GUI frontends to LaTeX now allow for > easy specification of where you want the figures, and the degree of > their floatiness. > Quite often they ended up bunched together at the end of >> a chapter. You needed a kludge like the here.sty style file. Using >> different fonts was next to impossible. LaTeX2e that appeared later >> improved that (so I have heard). However, years later, when I tried to >> typeset my plain LaTeX based thesis once again, I couldn't get it to >> compile with the then current 2e version. So much for compatibility. This may still be a problem. > Equations of more than average complexity easily filled up half a page >> of code rubbish and were a pain to debug. No problem with, e.g., LyX and its instant preview. > Spellchecking less than >> basic. Try to write a multiple language peace and spellcheck that in >> LaTeX. This is no problem now. > Virtually no picture tools. No tracked changes. No >> collaboration tools etc etc. All of that is quite easy now. > I don't want to start a flame war. Just balancing the discussion >> somewhat. I am well aware of many or most of the problems of Word. > > Points taken! All of the desktop publishing paradigms can *really* > be worked on. > -- DrMajorBob@longhorns.com === Ack. I wish I knew something about OS X and/or XeTeX; I've never seen such kinds of error messages. I use LyX on Windows and Linux, and it's nearly flawless for me. I'm a regular recipient of the LyX user's group (and, sometimes, of the developers' group) emails, and I've never found them to be anything but the most helpful bunch of people (on par with the Mathematica users in this group). lyx-users@lists.lyx.org , just in case you wish a response from people who can help. Anyway, YMMV. I know I've had unresolvable issues with pieces of software which everyone else use effortlessly, and I'm sorry it happened to you in this case. > My advice? Stick to Mathematica and/or Word. (Unless you're willing to > learn LaTeX from the ground up, the hard way.) I spent several hours last night sleuthing how to use Mac fonts in LyX, > which led to using them in TeXShop, which led to indecipherable > instructions for using LyX with XeTex, which led to utter confusion. I > found a LyX document that explained and demonstrated how to do this; > but that document explained exactly nothing and could not be typeset, > neither with LaTeX NOR XeTeX. Trying to do so popped up error messages > (like the ones mentioned below). Explanations (and ERROR messages) FREQUENTLY repeated the equivalent of, > If you use *nix, you'll be able to figure this out. No need to explain > it, or Make like Sherlock Holmes, and look for clues. Apparently, the developers of this stuff MAY be a lot wise-a**es who'd > rather, really, have nobody else use their code. Or, at least, they can't be bothered with meaningful documentation or > installers that do the full job. Bobby === Subject: Re: Issue with Sum Version7 >Anyone seen this: >In[120]:= Sum[i, {i, 0, 99999, .1}] >Out[120]= 4.99991*10^10 >In[121]:= Sum[i, {i, 0, 100000, .1}] >Out[121]= Sum[i, {i, 0, 100000, 0.1}] >On Mac OS X 10.5.6 I get the same result. But this result is easily avoided by either In[3]:= NSum[i, {i, 0, 100000, .1}] Out[3]= 5.00001*10^10 or In[4]:= Sum[i, {i, 0, 100000, 1/10}] Out[4]= 50000050000 The general rule in Mathematica is when working with machine precision numbers you should use the functions that start with N. The key advantage of Sum over NSum is being able to return symbolic answers for simple problems. Note In[7]:= Sum[n, {n, 0, k, a}] Out[7]= (k (a+k))/(2 a) returns nearly instantly, much faster than doing the explicit sum. Compare In[1]:= Sum[n, {n, 0, 100000, 1/10}] // Timing Out[1]= {0.135397,50000050000} In[2]:= Sum[n, {n, 0, k, a}] /. {a -> 1/10, k -> 100000} // Timing Out[2]= {0.018729,50000050000} Of course none of this changes the fact there appears to be a problem with Sum. === Subject: Re: export to ps, transparency issue Hi Ruth, Did you really use the Export function as shown here? Problem is that the only postscript that Mathematica exports is Encapsulated Postscript, which has a file extension eps. Since you are using ps (which is the extension for standard postscript, unsupported by Mathematica) Mathematica does not know what to export. The primary problem is that Postscript level 2 does not support transparancy, at least not as far as I know. This is the postscript level that Mathematica exports to (with a few lvl 3 extensions). As of PDF 1.4, transparancy is supported. Mathematica does PDF 1.5. If you really want eps output you have to forget transparency. We want to overlay to contourplots, so we do ContourPlot[{x^2/4 + y^2/16}, {x, -6, 6}, {y, -5, 5}, > Contours -> {1.}, > ContourShading -> {{Red, Opacity[0.4]}, Opacity[0.]}, > ContourStyle -> Opacity[0.2]] ContourPlot[{x^2/25 + y^2/9}, {x, -6, 6}, {y, -5, 5}, > Contours -> {1.}, > ContourShading -> {{Blue, Opacity[0.4]}, Opacity[0.]}] Show[%,%%] The question is that when we do Export[contours.ps,%] the resulting > image has a black area in the non-coloured region, which appears white > on the screen. No problem when exporting to pdf. Is there some replacement rule which will do the trick? > Ruth Lazkoz === Subject: Re: export to ps, transparency issue What happens if you use: Show[%, %%, Background -> White] ? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ We want to overlay to contourplots, so we do ContourPlot[{x^2/4 + y^2/16}, {x, -6, 6}, {y, -5, 5}, Contours -> {1.}, ContourShading -> {{Red, Opacity[0.4]}, Opacity[0.]}, ContourStyle -> Opacity[0.2]] ContourPlot[{x^2/25 + y^2/9}, {x, -6, 6}, {y, -5, 5}, Contours -> {1.}, ContourShading -> {{Blue, Opacity[0.4]}, Opacity[0.]}] Show[%,%%] The question is that when we do Export[contours.ps,%] the resulting image has a black area in the non-coloured region, which appears white on the screen. No problem when exporting to pdf. Is there some replacement rule which will do the trick? Ruth Lazkoz === Subject: Re: export to ps, transparency issue no, PostScript have no transparent colors. You can try to convert it via Rasterize[] to a bitmap and export it than. Jens We want to overlay to contourplots, so we do ContourPlot[{x^2/4 + y^2/16}, {x, -6, 6}, {y, -5, 5}, > Contours -> {1.}, > ContourShading -> {{Red, Opacity[0.4]}, Opacity[0.]}, > ContourStyle -> Opacity[0.2]] ContourPlot[{x^2/25 + y^2/9}, {x, -6, 6}, {y, -5, 5}, > Contours -> {1.}, > ContourShading -> {{Blue, Opacity[0.4]}, Opacity[0.]}] Show[%,%%] The question is that when we do Export[contours.ps,%] the resulting > image has a black area in the non-coloured region, which appears white > on the screen. No problem when exporting to pdf. Is there some replacement rule which will do the trick? > Ruth Lazkoz === Subject: ordering terms for display I have a few mathematica expressions. say like 1 + x + x^2 I want these to be displayed in reverse order, so that I can copy them for use in latex.