title: Find zero crossing in a list

text: I'm looking for a function that finds the index of the zero-crossing points of a list. Before I go making my own subroutine to do this, I was wondering if anyone knows of any built-in Mathematica function for it. Example of what I want:               list = {-2,-1,0,1,2,3,4,3,1,-2,-4,8,9,10};     ZeroCrossing[list] returns: {3,10,12}      Thanks, EDIT: Per whuber's suggestion, I'm adding my findings to the initial question, instead of just in a solution. I've checked LabVIEW (the other language I know well), and it considers "Bounces" ({1,0,2}, {-2,0,1}) and duplicates ({1,0,0,2}) to be zero-crossings. It outputs a T/F value for each array index. Example:               ZeroCrossing[{1,0,2}]     (* Returns: {F,T,T} *)     ZeroCrossing[{1,0,0,2,3}]     (* Returns: {F,T,T,T,F} *)


title: ImageAlign doesn't always work correctly

text: I've been working with `ImageAlign` in Mathematica 8 and I'm having trouble getting it working reliably. Perhaps there are some subtleties that I'm not yet aware of? Here's an example:               mandrill = ExampleData[{"TestImage", "Mandrill"}]     eye = ImageTake[mandrill, {50, 91} , {150, 190}]      ![mandrill and the mandrill eye](http://i.stack.imgur.com/qCE31.png) Now `ImageAlign` is supposed to be able to align these two images, returning, say, the eye in the right place on the original image:               ImageAlign[mandrill, eye, Background -> Gray]      ![enter image description here](http://i.stack.imgur.com/P99f6.png) but it appears in the wrong place. According to the documentation, it should appear in the correct location, but it shows up in the bottom corner. There are Transformation options, but they seem to make no difference to the success of the function. Strangely, I have been achieving some success with other images, although it's not consistent. Are there some restrictions that I'm not aware of?


title: Using Partition to allow sublists of different lengths

text: As a minimal example, suppose I have a list of the integers from 1 to 25. Suppose I want to use `Partition` to partition the list into sublists of length 10 **but** without dropping the "end" elements. For example, this code               list = Range[1, 25];     Partition[list, 10]      gives: `{{1,2,3,4,5,6,7,8,9,10},{11,12,13,14,15,16,17,18,19,20}}`, where the integers 21 through 25 have been dropped. What if I want to keep those integers? I would like `Partition` to partition the list into sublists of length 10 only when possible (i.e., keeping the "end" elements). How can I do this? In the `Partition` documentation, this entry looks like a possibility: > `Partition[list, n, d, {kL, kR}, {}]` uses no padding, and so can yield > sublists of different lengths. So I tried: Partition[list, 10, 0, {1, 1}, {}] but this did not work (according to the documentation `{kL, kR} = {1, 1}` means "allow maximal overhang at the end"). On the other hand, this seems to work:               Partition[list, 10, 10, 1, {}]      which gives the correct output: `{{1,2,3,4,5,6,7,8,9,10},{11,12,13,14,15,16,17,18,19,20},{21,22,23,24,25}}`. Is this the best way to solve the problem, or am I making a conceptual mistake? I obtained the idea `Partition[list, 10, 10, 1, {}]` from the following documentation, but conceptually I am not really sure what it is doing: > Use no padding, so later sublists can be shorter: > `Partition[{a,b,c,d,e,f,g},3,3,1,{}]` > > `{{a,b,c},{d,e,f},{g}}`


title: Why does Assuming[...] work in one case but not in another?

text: Why does this work               Assuming[α > 0 && ϵ > 0 && t > 0,      FullSimplify @ Integrate[(z^2 Exp[-α t (z^2 + ϵ)])/(z^2 + 1), {z, 0, ∞}]]      > >     (E^(-t α ϵ) (Sqrt[π] - E^(t α) π Sqrt[t α] Erfc[Sqrt[t α]]))/(2 Sqrt[t > α]) >   but not this?               MyAssumptions := Assuming[α > 0 && ϵ > 0 && t > 0, #] &;     MyAssumptions[FullSimplify @ Integrate[(z^2 Exp[-α t (z^2 + ϵ)])/(z^2 + 1), {z, 0, ∞}]]      > >     ConditionalExpression[ >       (E^(-t α ϵ) (Sqrt[π] - E^(t α) π Sqrt[t α] Erfc[Sqrt[t α]]))/(2 Sqrt[t > α]), >       Re[t α] > 0] >


title: Filter list with different list in it

text: I have a list like:                  {{{4, 14}, 1}, {{4, 15}, 1}, {{4, 16}, 1}, {{4, 17}, 1},          {{4, 18}, 1}, {{4, 14}, 3},  {4,15},      {{4, 16}, 2},{4,18}}      Now I want to filter this list. First I want to delete lists that have the form: `{a,b}` like `{4,15}` and `{4,18}`. So what remains is:                {{{4, 14}, 1}, {{4, 15}, 1}, {{4, 16}, 1}, {{4, 17}, 1},        {{4, 18}, 1}, {{4, 14} ,3}, {{4, 16}, 2}}      And now I want only the lists which are a minimum: For example now you have a list with:               {{4, 14}, 1} and {{4, 14}, 3}     {{4, 16}, 1} and {{4, 16}, 2}      I want that only `{{4, 14}, 1}` and `{{4, 16}, 1}` remain (minimum of the third number). Finally remains:               {{{4, 14}, 1}, {{4, 15}, 1}, {{4, 16}, 1}, {{4, 17}, 1}, {{4, 18}, 1}      How can I easily do this??


title: Composition à la Mondrian

text: I would like to paint something like this ![enter image description here](http://i.stack.imgur.com/XiK7O.jpg) or,even better, like this ![enter image description here](http://i.stack.imgur.com/vrJcC.jpg) I have tried               colors =       {Red, Blue, Yellow, White, Black};          cells =       ConstantImage[RandomChoice[colors], #] & /@         RandomInteger[{50, 10}, {30, 2}];          ImageCollage[      cells,      Background -> Black,      Method -> "Rows",      ImagePadding -> 1,      ImageSize -> 400]      ![enter image description here](http://i.stack.imgur.com/djFWm.jpg) The result is unpleasing, especially because all rows have equal height. How could one produce a more Mondrian - like image?


title: RegionPlot3D in cylindrical or spherical coordinates?

text: RegionPlot3D is awesome. Unfortunately, it appears to work only for Cartesian coordinates. While there are ways to draw surfaces in spherical or cylindrical coordinates, I can't find a way to draw solids. Is there a way to do so that doesn't involve translating the equations to Cartesian coordinates? Thanks.


title: Solving Integrals

text: Here's a problem that I don't understand.               f[x_] := Exp[Cos[3*x]]     g[x_] := (1/3)*x^3 - x^2 + 2       When I try to find the limit:               Solve[NIntegrate[f[x] - 0.1 g[x], {x, 0, t}] == 3, t]       I get these errors x3 > NIntegrate::nlim: > > Solve::inex: Solve was unable to solve the system with inexact coefficients > or the system obtained by direct rationalization of inexact numbers present > in the system. Since many of the methods used by Solve require exact input, > providing Solve with an exact version of the system may help. >>


title: Factoring polynomials to factors involving complex coefficients

text: I've run into some problems using `Factor` on polynomials with complex coefficient factors. Reading the documentation it looks like it only factors over the `Integers` by default. So I've found I can factor some polynomials with complex factors like this:               Factor[ poly, Extension -> I ]      For example `x^2+1` won't factor with just `Factor[x^2+1]` but it does factor properly when I add the imaginary unit extension. However another polynomial such as: $$8x^3-7x^2+10x-5$$ still won't be factorized even with the imaginary extension added. What am I missing here? How do I simply get `Mathematica` to completely factor any polynomial with complex factors I give it?


title: List Manipulation matrices

text: I have the following two lists: List A:               A={{-0.0390625, 0., 0., 0., 0.0390625}, {-0.174377, -0.073478,        3.0893*10^-16, 0.073478,        0.174377}, {-0.196939, -0.112309, -1.50053*10^-16, 0.112309,        0.196939}, {-0.174377, -0.073478, 5.52991*10^-16, 0.073478,        0.174377}, {-0.0390625, 0., 0., 0., 0.0390625}}      List B:               B={{5, 6, 6, 5, 5}, {5, 5, 1, 5, 5}, {5, 4, 3, 4, 5}, {5, 5, 5, 5,        5}, {5, 0, 5,6, 5}}      I want to create 6 (max. value in list B) copies of List A, but if a value at point {i,j} in List B is smaller then 6, by example value X at point {i,j} in List B, then the value at point {i,j} in List A should only be used in the first X copies. Hence the last 6-X copie(s) should be zero at point {i,j}. How can I fix this?


title: How can I graph an equation with five variables?

text: {c*((a - b*Cot θ)/(Subscript[r, 1])^4) + ((b*Csc θ)/(Subscript[r, 2])^4)      This is a form of Poiseuille's Law I need to graph. I want the value of the variables to be `c = 1, a = 10, b = 5, r1 = 1, r2 = 2/3`.


title: Checking result for expression

text: I want to verify the following result: $\sum _{y=2}^{n+1} \left(\sum _{x=y-1}^n \frac{1}{x-y}\right)=n \left(H_n^{(1)}-1\right)$ In Mathematica i try with:               Sum[Sum[1/(x - y), {x, y - 1, n}], {y, 2, n + 1}] == n*(HarmonicNumber[n, 1] - 1)      But I don't understand Mathematica output, is a large formula. And WolframAlpha doesn't say anything for it.


title: Finding the coefficient of a certain power in a generating function

text: I want to compute $(t^1+\dots +t^5)(t^2+\dots+ t^6)(t^3+\dots +t^9)$ and find the coefficient of $t^{15}$ for example. $t$ is an indeterminate Now in _Maple_ this is simply as               p:=sum(t^i,i=1..5)*sum(t^i,i=2..6)*sum(t^i,i=3..9);     coeff(p,t,15);      But I can't seem to learn how to do this in _Mathematica_. I have tried using               Series[ %, {t, 1, 10}] * Series[ %, {t, 4, 20}] * Series[ %, {t, 6, 15}]      But it outputs a number(I don't know what this number even is) Where can I find documentation to solve such a problem?


title: Character display color

text: I'm looking to cause the front end to display individual characters in a specific color, just in general, as a default sort of thing. For instance, the character "1" would always display as a red 1, except of course when an output color is manually specified. I'm basically looking for something like the image. I have no idea how to go about doing this. I looked at stylesheets enough to know I hate them. ![enter image description here](http://i.stack.imgur.com/4V4Ki.png)


title: Evaluate Initialization Cells of another notebook

text: Although there may be better ways to get data and definitions from another notebook (packages, read/write dumps, ...), sometimes it is convenient to just evaluate the initialization cells from another notebook to re-use the data and definitions. Normally I would open this notebook and manually `Evaluate Initialization Cells`, but I was wondering if there is a way to do this automatically, i.e. with some code. **Question: is there a way to evaluate the Initialization Cells of a certain notebook by filename?** Related questions:   * Evaluation of Notebook chosen by FileNameSetter   * How to select all initialization cells?


title: How can I construct "better" block graphs?

text: A graph is a _block graph_ if it can be constructed from an undirected tree by replacing each edge with a clique. My method of generating "random" block graphs is as follows. The parameters are the number of blocks and the maximum size of any clique.               RandomBlockGraph[b_, max_] :=       Module[{g = Graph[{}], L = Table[i, {i, 1, b*max}]},         For[i = 1, i <= b, ++i,           r = RandomInteger[{2, max}];           h = IndexGraph[CompleteGraph[r], First[L]];           L = Drop[L, r - 1];           g = GraphUnion[g, h];         ];           Return[g];       ];      The function "glues" together cliques. The weakness is that right now, a vertex is joining at most 2 cliques. Here's a few examples of what the function spits out with `RandomBlockGraph[3, 5]`: ![enter image description here](http://i.stack.imgur.com/oqk7s.png) ![enter image description here](http://i.stack.imgur.com/IwJSl.png) It would be nice if my function could say take a tree, and then actually replace every edge with a clique. This would make it possible to get as an output say a star graph on $n$ vertices, where every edge was replaced with a clique. The current function can't do this, since every vertex joins at most 2 cliques. > How can I modify (or write a better function) for generating block graphs > such that a vertex can join more than just 2 cliques?


title: Placing bar chart labels on the upper and lower frame axes

text: In the bar chart (with negative values)               BarChart[{{1, 2, 3}, -{4, 5, 6}},       ChartLabels -> {Placed[{"r1", "r2"}, Above],         Placed[{"c1", "c2", "c2"}, Below]}]      ![enter image description here](http://i.stack.imgur.com/QmI3s.png) the bar and group labels can be placed above and below the bars. How can I place the bar and group labels on the upper and lower frame axes like in the paired bar chart               PairedBarChart[{Range[4], Range[4]/2}, {Range[4], Range[4]/2},       ChartLabels -> {Placed[{"pair1", "pair2"}, Above],         Placed[{"g1", "g2"}, "LeftAxis"],         Placed[{"a", "b", "c", "d"}, "RightAxis"]}]      ![enter image description here](http://i.stack.imgur.com/Ipx5E.png) where the labels are placed to the left and right axis by using `Placed[{"g1", "g2"}, "LeftAxis"]` and `Placed[{"a", "b", "c", "d"}, "RightAxis"]`? Unfortunately, this doesn't work with `BarChart` and "TopAxis" nor "BottomAxis".


title: Incorporating a Manipulation in an Animation

text: I am having trouble incorporating a manipulation into my animation. I want to be able to maniuplate the 5 constants at the beginning. Am I going to need to combine all of the code into one string?                N0 = 10; ρ = .1; d = 1; ϵ = 2; j = 1     eqone = Flatten[                Join[                Table[x[i]''[t] == ϵ*(1 - x[i][t]^2)*x[i]'[t] - x[i][t] + d (z[t] - x[i][t]),                      {i, 0, N0}],                 {z'[t] == ρ*d/N0 (Sum[x[i][t] - z[t], {i, 0, N0}]) - j*z[t], z[0] == 1,                x[0][0]        == 0,                 x[0]'[0]       == 0,                 x[N0/2][0]     == 0,                 x[N0/2]'[0]    == 0},                 Table[x[i]'[0] == 0, {i, 1, N0/2 - 1}],                 Table[x[i][0]  == 0, {i, 1, N0/2 - 1}],                 Table[x[i]'[0] == 0, {i, N0/2 + 1, N0}],                 Table[x[i][0]  == 0, {i, N0/2 + 1, N0}]]];          eqtwo = NDSolve[eqone, Append[Table[x[i], {i, 0, N0}], z], {t, 500},      MaxSteps -> Infinity]          Animate[ptss = Table[{i, x[i][t]} /. eqtwo, {i, 0, N0}];        ListPlot[ptss, PlotRange -> {{0, N0}, {-5, 5}},                       PlotStyle -> Directive@AbsolutePointSize@4,                       Epilog -> {Line@ptss[[All, 1]]}, ImageSize -> Large],              {t, 0, 500},              AnimationRate -> 2,              AnimationRepetitions -> 2,              AnimationRunning -> False]


title: Solving and plotting ODEs while varying one of the initial conditions

text: How can I vary an initial condition in the numerical solution of a system of ODEs and then make a 3D plot of the solution space with that condition as one of the variables.               sol = NDSolve[       {y''[t] + y'[t] + 4*y[t] + x[t] - x'[t] == 0,         x'[t] + 3*c*y[t] == 0,        y[1] == 1, y'[1] == 1,         x[0] == 1}, {x, y}, {t, 0, 10}]      I want to vary one of the condition variables, say `y[1]` over `u = Range[-10, 10, step]`. Then I want to make a 3D plot of the solution space `(x[t[, y[t], y[1][u])`. Can anyone please guide me in solving this query.


title: Is it possible to use a mathematical expression as function name?

text: This might seem as a silly question, but is it feasible to use a mathematical expression as the name of a function? For example, I'm studying the cross section of Compton scattering and there is a formula for the differential cross section, which is denoted as $\frac{d\sigma}{d\Omega}$. I'd like to express the latter as a function of energy E, angle θ and atomic number Z. If I, naively, use $\frac{d\sigma}{d\Omega}[Z\\_, E\\_, \theta\\_] := \ldots$ I get the anticipated error: > SetDelayed::write : Tag Times in dσ/dΩ[Z_,E_,θ_] is Protected Instead of the obvious workaround of using a name such as `diffSection`[Z_,E_,θ_] := ... is there any other way ?


title: Creating documentation for sub-packages in Workbench

text: I'd like to create proper documentation for a package of mine, and Workbench in principle provides the tools to do this. However, I've split my package into multiple sub-packages (because I found it easier to maintain the code that way), structured as follows:               mainPackage`                `myPackage`                          `subPackage1`                          `subPackage2`                          `subPackage3`      The documentation tools in Workbench are set up in such a way that, out of the box, they only work with one top-layered package. For instance, the _Create symbol pages_ button from the _Documentation_ tab in the PacletInfo.m editor only looks for symbols within the context \$ApplicationName (which you can set in the _Overview_ tab of the PlacletInfo.m editor), and it's not possible for $ApplicationName to have quotes (`). So my question is: does anyone have a workaround for this? I could merge all my _subPackages_ into _myPackage_ , but unfortunately it won't be possible to remove the top-layer _mainPackage_.


title: How can I get all the results from a Wolfram | Alpha query?

text: When I query Wolfram | Alpha with "city in orange county, california", it returns the first four results with a note that there are "42 total". I can then hit the "more" button until all 42 are visible. I tried to get the same 42 results as computable data, in Mathematica 9.0.1.0, with this:               WolframAlpha["city in orange county, california", "ComputableData"]      which returns a list of the four items that initially come up when I ran the query on the Wolfram Alpha website:               {"Santa Ana", "Anaheim", "Irvine", "Huntington Beach", "Garden Grove"}      I've been sifting through online documentation and Google but haven't been able to figure out how to get all 42 cities. Any hints?


title: factorization of integer into two parts with specific prime factors

text: I would like to write a _Mathematica_ code to decompose an integer into two or more parts with primes in special intervals. For instance, I want to decompose $m=\binom{n}{k}$ into two parts U and V such that $\binom{n}{k}=UV$ and $$ U=\prod_{\substack{p\le k\\\p^\alpha||m}} p^{\alpha} $$ and $$ V=\prod_{\substack{k<p\le n\\\p^\alpha||m}} p^{\alpha} $$ where $p^\alpha||m$ mean $p^\alpha$ is the maximum prime power dividing m. I tried               Product[If[Element[p,Primes]&&Mod[Binomial[n, k], p] == 0, p, 1], {p,2,k-1}]          Product[If[Element[p,Primes]&&Mod[Binomial[n, k], p] == 0, p, 1], {p,k,n}]      , but it was not true


title: m equations and n variables. Reducing using Mathematica

text: I have six equations and thirteen variables. I would like to reduce it to seven free parameters. I used Reduce to solve it but it is taking really long (one full day and no output yet) and I think there must be a better way. Here is my code               Y = {{y1}, {y2}, {y3}}      T = {{t11, t12, t13}, {t21, t22, t23}, {t31, t32, t33}}      K = k*IdentityMatrix[3]          M = Y.Transpose[Y] + T.Transpose[T] - K %This is a symmetric matrix          Reduce[M[[1]][[1]]==0&&M[[1]][[2]]==0&&M[[1]][[3]]==0&&M[[2]][[2]]==0&&M[[2]][[3]]==0&&M[[3]][[3]]==0, Reals]      What should I do to speed this up? I'm sure if I spent a few hours, I could do it by hand but surely, there is a simple way to do it in Mathematica?


title: Whats the best practice of using subscripts in symbols?

text: I have stumbled over several issues about subscripted symbols recently. I would like that I can enter subscripted variables with my keyboard and that they are treated as symbols. I would also like to have lists (matrices) of these subscripted symbols and that they are formatted in the output nicely so that I can do calculations which them and still be able to see the nice output. **So far I have come up with the following (which uses the Notation Package):**               Needs["Notation`"];          Symbolize[ParsedBoxWrapper[SubscriptBox["_", "_"]]]     Symbolize[ParsedBoxWrapper[SubsuperscriptBox["_", "_", "_"]]]          makeSpecialSymb[var_String, i_, j_] :=        ToExpression[SubscriptBox[var, ToString[i], ToString[j]]];          makeSpecialSymb[var_SubscriptBox, i_, j_] :=        ToExpression[        SubscriptBox[var[[1]],          var[[2]] <> "," <> ToString[i] <> "," <> ToString[j]]];               makeSpecialSymb[var_SubsuperscriptBox, i_, j_] :=        ToExpression[        SubsuperscriptBox[var[[1]],          var[[2]] <> "," <> ToString[i] <> "," <> ToString[j], var[[3]] ]];          SymbolicMatrix[func_Function, m_Integer, n_Integer] :=       Table[func[i, j], {i, 1, m}, {j, 1, n}];          SymbolicMatrix[func_Function, m_Integer] :=       Table[func[i], {i, 1, m}, {j, 1, 1}];          SymbolicMatrix[argSpecSymb_, m_Integer, n_Integer] :=       Table[makeSpecialSymb[argSpecSymb, i, j], {i, 1, m}, {j, 1, n}];          SymbolicMatrix[argSpecSymb_, m_Integer] :=       Table[makeSpecialSymb[argSpecSymb, i], {i, 1, m}, {j, 1, 1}];      **So i can do the following:**               A = Map[HoldForm, SymbolicMatrix["W", 2, 2], 2];     B = SymbolicMatrix[SubsuperscriptBox["G", "S", "k"], 2, 2] ;     A // FullForm     B // MatrixForm     ?"Global`*"      ![enter image description here](http://i.stack.imgur.com/QRRd7.png) **So everything works fine, I can make a Matrix out of Symbols which are defined in the global context and which get formatted really nice. This is cool!** Another approach would be something (from Mike), where we do not generate the symbols but rather use some sort of formatting expression like the following:                ClearAll[fancySubscript1];          SetAttributes[fancySubscript1, HoldFirst]          fancySubscript1 /:       MakeBoxes[fancySubscript1[var_, index_], StandardForm] :=       SubscriptBox[MakeBoxes[var, StandardForm],        StyleBox[RowBox[{MakeBoxes[var, StandardForm],           MakeBoxes[index, StandardForm]}], ZeroWidthTimes -> True]]          fancySubscript1[var_, indices : {_Integer ..}] :=       fancySubscript1[var, #] & /@ indices               fancySubscript[H, {{1, 2}, {3, 4}}]      **Which gives:** ![enter image description here](http://i.stack.imgur.com/iTEbe.png) If I would go with this method, which prints all values very nicely, I can make matrices which do not contain symbols but rather function expression. In this method I am probably also much more flexible when I want to define my own look how the individual fancySubscripts are formatted. Which version would you go for in which cases? I am a bit unsure, which one of these is better to use, also with respect to flexibility. Also with respect to what method is better to use for if I want to replace the variables with values in subsequent calculations (either by replacement rules or by Set[] ) ? Another question for method 1, how does mathematica decide how to display my crazy named variables like: `W\[UnderBracket]Subscript\[UnderBracket]1` in the output? It seems that all symbols, which get created by the `ParsedBoxWrapper` which I think gets called when ever it sees a `SubscriptBox` pattern as defined in the `Symbolize` command, are displayed nicely. If I enter `RR\[UnderBracket]Subscript\[UnderBracket]100` in a new notebook it does not immediately get converted to a nice subcripted output format? Whats the problem here? I would be really interessted what the caveats are in these two methods, because I am not kind of a hero with mathematica. Thanks!


title: Add a column to a matrix as a function of the other columns

text: I was wondering if its possible to add a column to a matrix by a formula that uses all other columns, like this:               {a1,b1,c1,f(a1,b1,c1)}     {a2,b2,c2,f(a2,b2,c2)}     {a3,b3,c3,f(a3,b3,c3)}      Thanks!


title: Solving a large system of non-linear equations

text: I am new to _Mathematica_ , and I am currently trying to use it to solve a large symbolic system of non-linear equations. I began the code below about 30 hrs ago, and the _Mathematica_ Kernal has been using between 4 and 7GB of RAM since that time. Is there any chance (at this point) that a solution is still forthcoming? That is, should I continue to let this thing run? If so, is there any time threshold beyond which a solution is unlikely? There are currently 22 unknowns, and a bunch of other parameters. An alternative specification of the problem could drop this to 16 unknowns with 16 equations. Would _Mathematica_ be significantly more likely to solve this formulation in a reasonable amount of time? Here is my code:               Solve[{F1^γ1 L1^(-1 + α1)       P1 R1^η1 S1^β1 T1^ζ1 α1 - λ - P1 r (S1 θ1 + F1 S1 ι1 + S1 TV1 κ1 + RV1 S1 μ1) == 0,       -Cs + F1^γ1 L1^α1 P1 R1^η1 S1^(-1 + β1) T1^ζ1 β1 -          L1 P1 r (θ1 + F1 ι1 + TV1 κ1 + RV1 μ1) == 0,       -Cf + F1^(-1 + γ1) L1^α1 P1 R1^η1 S1^β1 T1^ζ1 γ1 - L1 P1 r S1 ι1 == 0,       F2^γ2 L2^(-1 + α2) P2 R2^η2 S2^β2 T2^ζ2 α2 - λ -          P2 r (S2 θ2 + F2 S2 ι2 + S2 TV2 κ2 + RV2 S2 μ2) == 0,       -Cs + F2^γ2 L2^α2 P2 R2^η2 S2^(-1 + β2) T2^ζ2 β2 -        L2 P2 r (θ2 + F2 ι2 + TV2 κ2 + RV2 μ2) == 0,       -Cf + F2^(-1 + γ2) L2^α2 P2 R2^η2 S2^β2 T2^ζ2 γ2 - L2 P2 r S2 ι2 == 0,       F3^γ3 L3^(-1 + α3) P3 R3^η3 S3^β3 T3^ζ3 α3 - λ -          P3 r (S3 θ3 + F3 S3 ι3 + S3 TV3 κ3 + RV3 S3 μ3) == 0,       -Cs + F3^γ3 L3^α3 P3 R3^η3 S3^(-1 + β3) T3^ζ3 β3 -          L3 P3 r (θ3 + F3 ι3 + TV3 κ3 + RV3 μ3) == 0,       -Cf + F3^(-1 + γ3) L3^α3 P3 R3^η3 S3^β3 T3^ζ3 γ3 - L3 P3 r S3 ι3 == 0,       F4^γ4 L4^(-1 + α4) P4 R4^η4 S4^β4 T4^ζ4 α4 - λ -         P4 r (S4 θ4 + F4 S4 ι4 + S4 TV4 κ4 + RV4 S4 μ4) == 0,       -Cs + F4^γ4 L4^α4 P4 R4^η4 S4^(-1 + β4) T4^ζ4 β4 -          L4 P4 r (θ4 + F4 ι4 + TV4 κ4 + RV4 μ4) == 0,       -Cf + F4^(-1 + γ4) L4^α4 P4 R4^η4 S4^β4 T4^ζ4 γ4 - L4 P4 r S4 ι4 == 0,       F5^γ5 L5^(-1 + α5) P5 R5^η5 S5^β5 T5^ζ5 α5 - λ -          P5 r (S5 θ5 + F5 S5 ι5 + S5 TV5 κ5 + RV5 S5 μ5) == 0,       -Cs + F5^γ5 L5^α5 P5 R5^η5 S5^(-1 + β5) T5^ζ5 β5 -          L5 P5 r (θ5 + F5 ι5 + TV5 κ5 + RV5 μ5) == 0,       -Cf + F5^(-1 + γ5) L5^α5 P5 R5^η5 S5^β5 T5^ζ5 γ5 - L5 P5 r S5 ι5 == 0,       F6^γ6 L6^(-1 + α6) P6 R6^η6 S6^β6 T6^ζ6 α6 - λ -         P6 r (S6 θ6 + F6 S6 ι6 + S6 TV6 κ6 + RV6 S6 μ6) == 0,       -Cs + F6^γ6 L6^α6 P6 R6^η6 S6^(-1 + β6) T6^ζ6 β6 -          L6 P6 r (θ6 + F6 ι6 + TV6 κ6 + RV6 μ6) == 0,       -Cf + F6^(-1 + γ6) L6^α6 P6 R6^η6 S6^β6 T6^ζ6 γ6 - L6 P6 r S6 ι6 == 0,       F7^γ7 L7^(-1 + α7) P7 R7^η7 S7^β7 T7^ζ7 α7 - λ -         P7 r (S7 θ7 + F7 S7 ι7 + S7 TV7 κ7 + RV7 S7 μ7) == 0,       -Cs + F7^γ7 L7^α7 P7 R7^η7 S7^(-1 + β7) T7^ζ7 β7 -          L7 P7 r (θ7 + F7 ι7 + TV7 κ7 + RV7 μ7) == 0,       -Cf + F7^(-1 + γ7) L7^α7 P7 R7^η7 S7^β7 T7^ζ7 γ7 - L7 P7 r S7 ι7 == 0,       -L1 - L2 - L3 - L4 - L5 - L6 - L7 + ℒ == 0},       {L1, L2, L3, L4, L5, L6, L7, S1, S2, S3, S4, S5, S6, S7, F1, F2, F3, F4, F5, F6, F7}]


title: Modify all the second elements of every pair in a list of pairs

text: I have a list in the form {{a, 1}, {b, 2}, {c, 3}}. Let's say I want to operate a transformation on all the second elements of each sublist, but this transformation is a function of them all together. As an example I want to Standardize them. At the moment I've implemented this with Transpose.               mylist = {{a, 1}, {b, 2}, {c, 3}};     newlist = Transpose[{mylist[[All, 1]], Standardize[mylist[[All, 2]]]}]      and the output is correctly               {{a, -1}, {b, 0}, {c, 1}}      I find this a little cumbersome, this approach can become complicated and hard to read sometimes. Isn't there a more natural way?


title: Wavelet transform order problem

text: I have a signal that I'm trying to study its time-frequency features by continuous wavelet transform. By choosing different wavelet order, I get some differences in the results.               data={2.9014*10^-6,2.90163*10^-6,2.90184*10^-6,2.90199*10^-6,2.90211*10^-6,2.90227*10^-6,2.90256*10^-6,2.90306*10^-6,2.90371*10^-6,2.90441*10^-6,2.90497*10^-6,2.90531*10^-6,2.9055*10^-6,2.90578*10^-6,2.90646*10^-6,2.90772*10^-6,2.90945*10^-6,2.91123*10^-6,2.91259*10^-6,2.91325*10^-6,2.91343*10^-6,2.91381*10^-6,2.91522*10^-6,2.91808*10^-6,2.92209*10^-6,2.92617*10^-6,2.92908*10^-6,2.93018*10^-6,2.93004*10^-6,2.93033*10^-6,2.93297*10^-6,2.93891*10^-6,2.94732*10^-6,2.95574*10^-6,2.9614*10^-6,2.96299*10^-6,2.96185*10^-6,2.96162*10^-6,2.96628*10^-6,2.97767*10^-6,2.99387*10^-6,3.00976*10^-6,3.01981*10^-6,3.02167*10^-6,3.01827*10^-6,3.0168*10^-6,3.02483*10^-6,3.04546*10^-6,3.07459*10^-6,3.10242*10^-6,3.11891*10^-6,3.12028*10^-6,3.11252*10^-6,3.10893*10^-6,3.12272*10^-6,3.15854*10^-6,3.20828*10^-6,3.25426*10^-6,3.27939*10^-6,3.27836*10^-6,3.26281*10^-6,3.25606*10^-6,3.27983*10^-6,3.34039*10^-6,3.4223*10^-6,3.49512*10^-6,3.53107*10^-6,3.52363*10^-6,3.49457*10^-6,3.48331*10^-6,3.52429*10^-6,3.62491*10^-6,3.75702*10^-6,3.86957*10^-6,3.91859*10^-6,3.89724*10^-6,3.84478*10^-6,3.82651*10^-6,3.89594*10^-6,4.06072*10^-6,4.27145*10^-6,4.44408*10^-6,4.50948*10^-6,4.46164*10^-6,4.369*10^-6,4.33805*10^-6,4.45164*10^-6,4.71689*10^-6,5.05039*10^-6,5.31582*10^-6,5.40427*10^-6,5.31103*10^-6,5.15072*10^-6,5.09455*10^-6,5.2712*10^-6,5.68762*10^-6,6.20894*10^-6,6.61828*10^-6,6.74349*10^-6,6.57916*10^-6,6.30884*10^-6,6.20238*10^-6,6.4596*10^-6,7.09078*10^-6,7.88788*10^-6,8.51491*10^-6,8.70166*10^-6,8.43447*10^-6,7.9931*10^-6,7.79107*10^-6,8.13561*10^-6,9.04922*10^-6,0.0000102271,0.0000111668,0.0000114527,0.0000110468,0.0000103528,9.98182*10^-6,0.0000103954,0.0000116448,0.0000133079,0.0000146643,0.0000150967,0.000014515,0.000013469,0.0000128233,0.000013247,0.0000148457,0.0000170679,0.0000189313,0.0000195583,0.0000187682,0.0000172645,0.0000162108,0.0000165364,0.0000184334,0.0000212252,0.0000236427,0.0000245012,0.0000234839,0.0000214325,0.0000198316,0.000019909,0.0000219786,0.0000252636,0.0000282157,0.0000293231,0.0000280882,0.0000254475,0.0000231909,0.0000228567,0.0000249121,0.0000285254,0.0000319176,0.0000332699,0.0000318712,0.0000286827,0.000025737,0.000024859,0.0000266879,0.0000303991,0.0000340713,0.0000356473,0.0000341925,0.0000306028,0.0000270451,0.0000255658,0.0000269767,0.0000305281,0.0000342767,0.0000360407,0.000034684,0.0000309405,0.0000269673,0.00002493,0.0000257916,0.0000289396,0.0000325431,0.0000344431,0.0000333581,0.0000297724,0.0000256719,0.0000232159,0.0000234769,0.0000260252,0.0000292689,0.0000312323,0.0000305725,0.0000274598,0.0000235556,0.0000208833,0.0000205699,0.0000223903,0.0000250907,0.0000270255,0.0000268888,0.0000245043,0.0000210875,0.000018415,0.0000176113,0.0000186525,0.0000206803,0.0000224893,0.0000229019,0.000021395,0.0000186677,0.000016177,0.0000149982,0.0000152855,0.0000165867,0.0000181916,0.0000191149,0.000018512,0.0000165548,0.0000143599,0.0000129276,0.000012555,0.000013165,0.000014534,0.0000158876,0.0000160998,0.0000148657,0.0000129981,0.0000114223,0.0000105418,0.0000105894,0.0000117571,0.0000134455,0.0000142913,0.0000136192,0.0000120292,0.0000103999,9.20804*10^-6,8.90906*10^-6,9.98279*10^-6,0.0000119153,0.0000131483,0.0000127878,0.0000113584,9.74472*10^-6,8.47082*10^-6,8.11189*10^-6,9.26401*10^-6,0.0000113633,0.0000126963,0.0000123374,0.0000109064,9.3632*10^-6,8.25912*10^-6,8.17564*10^-6,9.62188*10^-6,0.0000118203,0.000012945,0.0000122487,0.0000106348,9.21487*10^-6,8.54772*10^-6,9.09781*10^-6,0.0000110663,0.0000132919,0.0000138925,0.0000125211,0.0000105526,9.32172*10^-6,9.36753*10^-6,0.0000109027,0.0000135961,0.0000157529,0.0000155162,0.0000131626,0.0000107069,9.75865*10^-6,0.0000107928,0.0000136236,0.0000171774,0.0000191241,0.0000177518,0.0000141711,0.0000111629,0.0000106266,0.0000129044,0.0000172576,0.0000216974,0.0000232339,0.0000204642,0.0000155096,0.0000119739,0.0000120098,0.0000157303,0.0000216963,0.0000269007,0.0000277722,0.0000234185,0.0000170818,0.0000131483,0.0000139225,0.0000191729,0.0000266498,0.0000323315,0.0000322612,0.0000262685,0.0000187195,0.0000146189,0.0000162587,0.0000229503,0.0000316008,0.000037322,0.0000360748,0.0000285839,0.0000201923,0.0000162308,0.0000187689,0.0000265874,0.0000358375,0.0000410694,0.0000385343,0.0000299253,0.0000212457,0.0000177555,0.000021086,0.0000294887,0.0000385878,0.0000428113,0.0000390708,0.0000299529,0.0000216567,0.0000189327,0.0000228023,0.0000310861,0.0000392347,0.0000420573,0.0000374097,0.0000285341,0.000021288,0.000019523,0.0000235719,0.0000310124,0.0000375351,0.000038791,0.0000337031,0.0000258056,0.0000201218,0.0000193602,0.0000232043,0.0000292277,0.0000337383,0.0000335339,0.0000285325,0.000022157,0.0000182685,0.0000183955,0.0000217204,0.0000260417,0.0000285313,0.0000272103,0.0000227513,0.0000181274,0.0000159479,0.0000167255,0.0000193539,0.0000220184,0.0000228182,0.0000208507,0.0000172182,0.0000142504,0.0000134414,0.0000145815,0.0000164881,0.0000177985,0.0000174337,0.0000152762,0.0000125511,0.0000109148,0.0000110238,0.0000122648,0.0000135413,0.0000139169,0.0000129276,0.0000109173,9.01633*10^-6,8.30148*10^-6,8.89899*10^-6,0.0000100554,0.0000108503,0.0000106919,9.50391*10^-6,7.82257*10^-6,6.57486*10^-6,6.40567*10^-6,7.16874*10^-6,8.14135*10^-6,8.60627*10^-6,8.21702*10^-6,7.09626*10^-6,5.79527*10^-6,5.01389*10^-6,5.11097*10^-6,5.8423*10^-6,6.60103*10^-6,6.85917*10^-6,6.42795*10^-6,5.50012*10^-6,4.5507*10^-6,4.07673*10^-6,4.26498*10^-6,4.87088*10^-6,5.42821*10^-6,5.56594*10^-6,5.18801*10^-6,4.48472*10^-6,3.82361*10^-6,3.54108*10^-6,3.72838*10^-6,4.18349*10^-6,4.57192*10^-6,4.6435*10^-6,4.35255*10^-6,3.85484*10^-6,3.41314*10^-6,3.24569*10^-6,3.39435*10^-6,3.71047*10^-6,3.96784*10^-6,4.00462*10^-6,3.80047*10^-6,3.46885*10^-6,3.18544*10^-6,3.08611*10^-6,3.18886*10^-6,3.39344*10^-6,3.5553*10^-6,3.57424*10^-6,3.44177*10^-6,3.23332*10^-6,3.05918*10^-6,3.00022*10^-6,3.06376*10^-6,3.18717*10^-6,3.28334*10^-6,3.29322*10^-6,3.21342*10^-6,3.09013*10^-6,2.98825*10^-6,2.95355*10^-6,2.98889*10^-6,3.05797*10^-6,3.11154*10^-6,3.11673*10^-6,3.0722*10^-6,3.004*10^-6,2.94775*10^-6,2.92784*10^-6,2.94539*10^-6,2.98096*10^-6,3.00864*10^-6,3.01132*10^-6,2.98845*10^-6,2.95351*10^-6,2.92455*10^-6,2.91369*10^-6,2.92137*10^-6,2.93804*10^-6,2.95116*10^-6,2.95251*10^-6,2.94182*10^-6,2.92545*10^-6,2.91174*10^-6,2.90622*10^-6,2.90907*10^-6,2.91606*10^-6,2.92168*10^-6,2.92234*10^-6,2.9179*10^-6,2.91102*10^-6,2.90518*10^-6,2.90262*10^-6,2.90344*10^-6,2.90597*10^-6,2.90808*10^-6,2.90838*10^-6,2.90679*10^-6,2.90429*10^-6,2.90212*10^-6};          cwd = ContinuousWaveletTransform[data, GaborWavelet[6], {Automatic, 12}];     ListDensityPlot[Abs[cwd[All, "Values"]], PlotRange -> Automatic,        ClippingStyle -> Automatic, ColorFunction -> "TemperatureMap"]      ![enter image description here](http://i.stack.imgur.com/U0B4F.png) I'm interested in a weak frequency component in the signal. The zoom out of above figure looks like               ListDensityPlot[Abs[cwd[All, "Values"]],       PlotRange -> {{100, 400}, {20, 28}, {Min[Abs[cwd[All, "Values"]]],          0.02 Max[Abs[cwd[All, "Values"]]]}}, ClippingStyle -> Automatic,       ColorFunction -> "TemperatureMap", AspectRatio -> 1/GoldenRatio]      ![enter image description here](http://i.stack.imgur.com/xoXmJ.png) . From this plot, the weak signal is not easy to see because there are "stripes" from the other strong signal. However, if we use a higher order of wavelet, for the same region, we can see clearly the weak signal               cwd2 = ContinuousWaveletTransform[data, GaborWavelet[10], {Automatic, 12}];     ListDensityPlot[Abs[cwd2[All, "Values"]],       PlotRange -> {{100, 400}, {20, 28}, {Min[Abs[cwd2[All, "Values"]]],          0.02 Max[Abs[cwd2[All, "Values"]]]}}, ClippingStyle -> Automatic,       ColorFunction -> "TemperatureMap", AspectRatio -> 1/GoldenRatio]      ![enter image description here](http://i.stack.imgur.com/U9yDG.png) **Question** :   1. Why there are strong "stripes" in the low order wavelet case? Are those "stripes" a "true" feature of my signal or it's an artificial effect from the wavelet transform?   2. In general, what are the guide lines to choose the order of the wavelet?


title: FullSimplify inconsistent

text: I'm having problems using `FullSimplify` to simplify a differential equation. The expression is simplifying just as I would like when I express a variable `c` as a function, but not when I leave it by itself. It boils down to this:               FullSimplify[       1 - (4 H n (c[x]^(-1 + 2 n)) )/(K^n + c[x]^n)^2 + (4 H n (c[x]^(-1 + n)))/(K^n + c[x]^n)]      Gives the expected output: > >     1 + (4 H K^n n c[x]^(-1 + n))/(K^n + c[x]^n)^2 >   However, when I replace `c[x]` with just `c`, the output changes completely and refuses to simplify. The output then is: > >     (c^(1 + 2 n) + c K^(2 n) + 2 c^n K^n (c + 2 H n))/(c (c^n + K^n)^2) >   I don't understand why _Mathematica_ is behaving inconsistently, or what I am doing wrong. I've tried adding assumptions about `c`, using things like `Part`, and searching the web to no avail. Can anyone help?


title: Problem with Maximize

text: As $\\{p1,p2,p3,p4,p5\\}$ represents a probability distribution and $l1,l2$ are the eigenvalues of a stochastic matrix, the function $f$, as defined below, has to be maximized over a certain region.               L[p_List] := (p[[1]] - 0.2)*Log[p[[1]]] + (p[[2]] - 0.2)*     Log[p[[2]]] + (p[[3]] - 0.2)*Log[p[[3]]] + (p[[4]] - 0.2)*     Log[p[[4]]] + (p[[5]] - 0.2)*Log[p[[5]]]          CirculantMatrix[l_List?VectorQ] :=      NestList[RotateRight, RotateRight[l], Length[l] - 1]     CirculantMatrix[l_List?VectorQ, n_Integer] :=      NestList[RotateRight,      RotateRight[Join[Table[0, {n - Length[l]}], l]], n - 1] /;      n >= Length[l]          invFou[l_List] := 0.2*{1 + 2 l[[1]] Cos[2 Pi/5] + 2 l[[2]] Cos[4 Pi/5],      1 + 2 l[[1]] Cos[4 Pi/5] + 2 l[[2]] Cos[2 Pi/5],      1 + 2 l[[1]] Cos[4 Pi/5] + 2 l[[2]] Cos[2 Pi/5],      1 + 2 l[[1]] Cos[2 Pi/5] + 2 l[[2]] Cos[4 Pi/5],      1 + 2 l[[1]] + 2 l[[2]]}          m[l_List] := CirculantMatrix[invFou[l]]          f[p_List, M_List] := L[p.m[M]]/L[p]      We may assume that $l1=0.5$ and $0.37\leq l2 \leq 0.5$. If we try               Maximize[{f[{p1, p2, p3, p4, p5}, {0.5,      l2}], {p1 + p2 + p3 + p4 + p5 == 1 && p1 >= 0 && p2 >= 0 &&      p3 >= 0 && p4 >= 0 && p5 >= 0 && 0.37 <= l2 <= 0.5}}, {p1, p2, p3, p4, p5, l2}]      we get an error: > NMaximize::nrnum: The function value -0.206184-0.256075 I is not a real > number at {l2,p1,p2,p3,p4,p5} = > {0.446053,-0.0362605,0.263705,0.324533,0.369047,0.0789762}. >> Why doesn't _Mathematica_ take the maximum over the specified region?


title: How can I prevent these warnings while using ParallelTable

text: I have this code to find all the permutations of a set of letters that form legal words.               <<Combinatorica`     Module[{str = "abc", chars, len, r, check},      chars = Characters[str];      len = StringLength[str];      r = Range[len];      check[n_Integer] :=        DictionaryLookup[{"BritishEnglish",          StringJoin[chars[[UnrankPermutation[n, r]]]]}, 1];      DistributeDefinitions[check, chars, r];      ParallelTable[check[i], {i, 1, len!}]]      I've verified that, if I replace ParallelTable with Table, I get this:               {{}, {}, {}, {"cab"}, {}, {}}      With ParallelTable, however, in addition to that result, I also get warnings like these:               Part::pspec: Part specification Combinatorica`UnrankPermutation[1,{1,2,3}] is neither a machine-sized integer nor a list of machine-sized integers.          Part::pspec: Part specification Combinatorica`UnrankPermutation[2,{1,2,3}] is neither a machine-sized integer nor a list of machine-sized integers.          StringJoin::string: String expected at position 1 in StringJoin[{a,b,c}[[Combinatorica`UnrankPermutation[1,{1,2,3}]]]].          StringJoin::string: String expected at position 1 in StringJoin[{a,b,c}[[Combinatorica`UnrankPermutation[2,{1,2,3}]]]].      These warnings seem to come from kernel 7 and higher. My guess is that the computation reaches those kernels and there isn't any data left, since there are only 6 permutations, and causes them to spit out those warnings. Is my understanding correct? How do I prevent these warnings?


title: Is it possible to define a function in terms of a power series?

text: Is it at all possible to define a function in Mathematica in terms of a power series? For a specific example, I wish to write $x(\tau)$ as $x(\tau)=x_{0}(\tau)+\mu x_{1}(\tau)+\mu^{2}x_{2}(\tau)+\cdots$ (I'm okay with truncating terms, as long as I can determine how many terms I keep.) Thanks in advance. EDIT: I am looking to use these symbolically to plug into a differential equation and solve for each $x_i$ after grouping coefficients of powers of $\mu$. (Along with another power series $\omega = \omega_0 + \mu\omega_1+\mu^2\omega_2\cdots$ where each $\omega_i$ is constant.) It's important to note that each $x_i$ is a separate function of $\tau$, which is why the basic Mathematica tutorials I have seen have been of no help.


title: Checking powers of a matrix for zeros

text: I'm currently working on a project that deals with numerical semigroups and their connection to matrices. I'm pretty new to _Mathematica_ , so I wouldn't be surprised if my question has a simple solution; nevertheless I can't find it haha! I need code that will check the entries in a matrix to see if any of them are zero, and if there is at least one zero in the matrix, take the next power of the matrix and check it again until all of the entries are non-zero. All of the matrices I am working with **WILL** become completely non-zero, so I don't need to worry about an infinite loop or anything. I was thinking that I could just multiply all of the elements in the given matrix and if the product = 0, then loop back through. Either that or scan elements of the matrix individually since the matrices aren't any bigger than 5 x 5. Any help is greatly appreciated! P.S, -- If anyone has a method of then checking individual elements of a matrix to see if they are nonzero, and if they are, then adding the current power of that matrix to a set of numbers, I would be grateful to hear how it could be done. This is secondary to the above question though.


title: How do I put an image on the complex plane?

text: I watched this video and became interested in transforming an image. But I have no good idea on how to embed an image in the complex plane using _Mathematica_. I have a method that seems to work, but there has to be a better way to do this. Can somebody point me in the right direction?               a = Reverse[ImageData[ImageApplay[Mean,img]]]          f[c_] := Module[{re, im, d1, d2},        {d1, d2} = Dimensions[a];        re = Round[Re[d2 c]];        im = Round[Im[d1 c]];        If[1 <= re <= d2 && 1 <= im <= d1, a[[im, re]], 1]     ];          ListDensityPlot@Table[f[(y + x I)], {x, -1, 1.5, 0.02}, {y, -1, 1.5, 0.02}]


title: Mean Squared Deviation for Population Data

text: I've been using the Lotka-Volterra equation to estimate population sizes and need to find the MAD (mean absolute deviation), MSD (mean squared deviation) and mape (mean absolute percentage error) for my estimated population data vs the actual population data. I have 14 years of data. Important part of code I've been working on is below. However when I run this I get wrong/strange output. Any ideas? The sum code I'm using for MSD is likely the one that needs to be fixed and is at the very end. Thanks.               MyLVPredatorError[myPreyPopList_, myPredatorPopList_, myalpha_, myc_, myd_, myh_] :=          Module [{n, myPredatorPopValueList, myPredatorPopErrorList,          myLastN, myLastP, CurrentP, MSD, MSDError, MSDSqr,          numberOfValues, DebugFlag = False},              (* Step #3: Calculate the Predator Population Values  *)                                          If[DebugFlag, Print["Entering While loop"]];                    (*************)                                             myPredatorPopValueList = myPreyPopList;         myLastN = myPreyPopList[[1]];         myLastP = myPredatorPopList[[1]];         n = 1;              (* Calculate the prey population for varying number of predators *)          While[n <= numberOfValues,                 CurrentP = myLastP + (((-myd*myLastP) + (myc*myalpha*myLastN*myLastP))*myh);               myPredatorPopValueList[[n]] = CurrentP;               myLastN = myPreyPopList[[n + 1]];               myLastP = myPredatorPopList[[n + 1]];                                                         myPredatorPopValueList[[n]] = CurrentP;               MSDError = myLastP - CurrentP;               MSDSqr = MSDError*MSDError;                       If[DebugFlag, Print["n = ", n]];                                                         If[DebugFlag, Print["numberOfValues =", numberOfValues]];                                                          If[DebugFlag, Print["myPredatorPopErrorList =", myPredatorPopErrorList]];                    n = n + 1             (* end of While loop *)          ];                                         If[DebugFlag, Print["leaving While loop"]];                                                      MSD = Sum[MSDSqr, {n, numberOfValues}]/14;              Return[MSD];           (* end of the MyLVPredatorSoln module *)                                   ];


title: While loop not breaking when condition is met

text: I am having trouble with the while loop not breaking,               While[Abs[f[a, b] - f[aold, bold]] > 10^-5,      aold = a; bold = b;      α = dfx[a, b];      β = dfy[a, b];      l[t_] = {a, b} + t*{α, β};      h[t_] = f[l[t][[1]], l[t][[2]]];      dh[t_] = D[h[t], t];      tnew = t /. Solve[dh[t] == 0, t];      a = a + tnew*α;      b = b + tnew*β;      count++;      If[count == 10, Break[]];      ]      When I print the output, `Abs[f[a, b] - f[aold, bold]]` is way smaller than `10^-5`, the condition should be met around `5` loops.   Can you see what is wrong with the code?


title: For loop with steps other than 1

text: I would like to do a For loop with a jump 2*Pi instead of 1.               For[j = 0, j <= nmax, (incr = 2 Pi), ...]      Actually what I want to do is `j = n 2 Pi`, where `n` takes values from 0 to `n-1`, so the iteration stops at `nmax = (n - 1) 2 Pi`. I know this is a pretty trivial question, but I have not found anything equivalent in the "Documentation center".


title: Sampling a musical instrument (or re-tuning MIDI)

text: I'd like to try to convert a piece of MIDI music made with SoundNote to another tuning (not microtonal or even split-black-keys, just a slightly different tuning for each note). I searched for pitch parameters and it seems it only accepts "C" or "Db", not frequencies, and plays the piece in 12-tone equal temperament. (Am I right? Or could I somehow make a MIDI note sounding at a different frequency than those pre-defined notes?) So I'm trying to recreate piano sound with Play function. I add some harmonics to a sine wave but the more I add, the worse it sounds. Adding attack and decay shouldn't be very hard but for adding the harmonics in right amounts, I'd need to sample. I could have access to a piano and get some sound samples. In what file format should I record them so that Mathematica could run a Fourier transform on it? What functions should I use? How do I give a sound file as an input? Or, is there any way to re-tune a MIDI file with some other program after I compose it with Mathematica and export?


title: Lyapunov Exponent

text: Does anyone know a (simple) Mathematica code for computing the Lyuponov Exponent for the Rossler System? Thank you Rossler System:               rossler = {           x'[t] == -(y[t] + z[t]),           y'[t] == x[t] + 0.1 y[t],           z'[t] == 0.2 + x[t] z[t] - 5.7 z[t],           x[0] == 1, y[0] == 1, z[0] == 1          }


title: Assign keyboard shortcut unique to notebook

text: What is the most portable way to assign keyboard shortcuts unique to each notebook? To clarify I would like to have the keyboard shortcut change when simply changing the current `InputNotebook`. Currently I'm have the following code which allows for me to essentially have the defined function be defined in a notebook and execute in the Global` context.               FrontEndExecute@      FrontEnd`AddMenuCommands[       "DuplicatePreviousOutput", {MenuItem["Ctrl &q",          FrontEnd`KernelExecute@ToExpression@MakeBoxes[            F2[]            ], MenuKey["q", Modifiers -> {"Control"}],          System`MenuEvaluator -> Automatic]}]      I would like to somehow attach functions to notebooks without changing the context(most ideal). Alternatively I might be able to use something like a custom `FrontEnd'NotebookExecute` instead of `FrontEnd'KernelExecute`.


title: How to write a robust memberQ that test membership in set theory sense?

text: Select[{{"foo", "bar"} -> "a", {"foo", "baz"} ->         "a", {"foo", _} -> "a"}, MemberQ[{{"foo", "bar"}}, #[[1]]] &]          (* {{"foo", "bar"} -> "a", {"foo", _} -> "a"} *)      I'd like the answer to be `{{"foo", "bar"} -> "a"}`. The built-in `MemberQ` seems to use `MatchQ` for testing equality. I'd like a `memberQ` that uses `SameQ` or `TrueQ[Equal[#1, #2]]&`, and works for possibly funky arguments such as patterns.


title: Replacing a sum of expressions

text: I have an equation which Mathematica solves but gives a huge output. However I notice in this output that the same expression occurs many times. Namely: $E=864 a^6 - 432 a^4 b^2 + 54 a^2 b^4 - b^6 + 54 b^4 x^2$ where $a,b,c$ are constants. However this expression can appear in the form $-E$, $E^2$, $\sqrt{E}$, $4E$, ... I'm struggling to tell Mathematica to make the replacement $(864 a^6 - 432 a^4 b^2 + 54 a^2 b^4 - b^6 + 54 b^4 x^2) \space \to \space E$ wherever it appears. All the ways I've tried (I'm not that handy with Mathematica I note) don't change output. Any ideas?


title: How can I align the labels of the buttons on a setter bar to the button centers?

text: I tried to align the labels on the buttons of a `SetterBar`to the button centers. This is my code:               lis = {"1", "2", "3", "dsf"};     SetterBar[Dynamic[buttonValue],        Table[lis[[iteration]], {iteration, 1, 4}],        BaseStyle -> {Red, Alignment -> {Center, Center}}, {ImageSize -> {100, 50}}]      How do I get the labels of the buttons aligned to their centers? Can any one show me how?


title: Unexpected dots from Line

text: I have noticed cases where `Line` produces dots in a graphics object when I think it shouldn't. The first of these is:               Line[{{0., 0.}}]      The second is:               Line[{{0., 0.}, {0., 0.}}]      Longer lists of same point do not produce dots. To see this evaluate               repeatPts [pt_, n_] := Line[ConstantArray[pt, n]]     Graphics[{Thickness[.125], repeatPts[{0., 0.}, #], repeatPts[{1., 1.}, #]},       ImageSize -> 50, Frame -> True, FrameTicks -> None, PlotRangePadding -> .3] & /@ Range[5]      ![Dots.png](http://i.stack.imgur.com/Y6IKI.png) Is this version or platform depended? I got the results shown above on with V9.0.1 running on OS X. Should it be considered a bug or a weird feature?


title: Reading Eigenvalue / Eigenfunction result from Reduce

text: I am trying to find the eigenvalue/eigenfunction solution to: $$\tag 1 y''+3y + \lambda y=0 ; y'(0)=0, y'(\pi)=0$$ I used DSolve and Reduce and they seem to converge, however (embarrassingly) I am having a difficult time understanding the Reduce output (which seems to have an issue with a particular branch point). Ignoring that warning, how do you read the output below?                sol = DSolve[y''[x] + 3 y[x] + a y[x] == 0, y, x]           {{y -> Function[{x}, E^(Sqrt[-3 - a] x) C[1] + E^(-Sqrt[-3 - a] x) C[2]]}}            Reduce[        y'[0] == 0 && y'[Pi] == 0 && a != 0 && (C[1] != 0 || C[2] != 0) /.         sol, a] // FullSimplify      During evaluation of In[29]:= Reduce::useq: The answer found by Reduce contains unsolved equation(s) {0==(2 I [Pi] C[3]-2 [Pi] Sqrt[-Power[<<2>>]])/(2 [Pi])}. A likely reason for this is that the solution set depends on branch cuts of Mathematica functions. >>                 (C[1] !=          0 && ((C[3] \[Element] Integers && Abs[C[3]] == C[3] &&          3 + a == C[3]^2 && C[1] == C[2] && a != 0) ||          a == -3)) || (a == -3 && C[2] != 0)


title: Google Map in Notebooks?

text: Using Mark McClure's GPXToGoogleMap results in a HTML and Javascript code which can be viewed by any browser. Is it possible to load this map into the notebook, which obviously means for example that               <script src="http://maps.google.com/maps?file=api&v=2.s&key="         type="text/javascript">     </script>     <script src="/Users/meinmacbookpro/Desktop/Messprojekte/gps.js"          type="text/javascript">     </script>      should be implemented somehow into the Mathematica code?


title: Bags and non-standard evaluation

text: What can internally be happening here? Is the evaluator just messing with us and going non-standard because it's a `Bag`? Or am I just not seeing how something like this could be done in _Mathematica_?               AppendTo[$ContextPath, "Internal`"];          In[19]:= ClearAll[x, y];     {x, y} = {Bag[{1, 2, 3}], Bag[{4, 5}]};      Heads are               In[21]:= Head /@ {x, y}          Out[21]= {Bag, Bag}      But they are just a head, no depth. Depths               In[22]:= Depth /@ {x, y}          Out[22]= {1, 1}      However, they are different. I take their second elements, or I print them in `InputForm`               In[23]:= BagPart[#, 2] & /@ {x, y}     InputForm /@ {x, y}          Out[23]= {2, 5}          Out[24]= {InputForm[Internal`Bag[{1, 2, 3}]], InputForm[Internal`Bag[{4, 5}]]}


title: Formatting legend text font

text: I am using this code to plot a graph, and I am trying to make the font of the legend bigger.               <<PlotLegends`     ListLogLogPlot[{Sort[moby]}, PlotRange -> Full, Joined -> True,          PlotLegend -> {"Moby Dick"}, LegendPosition -> {0.30, -0.20}, LegendShadow -> None,          LegendBorder -> None, PlotStyle -> {Dashed}, BaseStyle -> {FontSize -> 14}]      This only seems to change the font size of the labels on my axis. But I also want the legend to be size 14.


title: Extracting information from list

text: I have a huge list that looks like this:               list = {8, 12, 201, 0.001, 3, 7, 100        (InterpolatingFunction[{{0., 0.0018}},"<>"][2916/35] +         InterpolatingFunction[{{0., 0.0018}}, "<>"][2916/35]),        23, 44, 11, -0.002}      I want to extract only the numbers, specifically the numbers around 10. I tried using this `Select[list, _?(7 <= # <= 13 &)]` but it returns an empty list. I think this happens because the list has both numbers and the `100 (InterpolatingFunction...` that I want to ignore. I would also be happy just to extract ALL numbers hence ignoring the `100(InterpolatingFunction...` elements. Could you give me some tip please?


title: Number format of axes in a plot

text: How can I have a conditional format of the values appearing in the axis of a plot ? I have in mind the number format options available in Excel for plots as described here http://peltiertech.com/Excel/NumberFormats.html. I'm mostly interested in how to format numbers as shown in the paragraph "Thousands, Millions, etc." in order to display 100 000 as 100k and 100 000 000 as 100M for example. Also is it possible to set this format by default in plots ?


title: Different results with DateRange and LeapYearsQ in Mathematica 9 and 10

text: With Mathematica 9.0 for Mac OS X x86 (64-bit) (January 24, 2013) one could use               DateRange[{2000}, {2010}, "Year"]      to achive               {{2000}, {2001}, {2002}, {2003}, {2004}, {2005}, {2006}, {2007}, {2008}, {2009}, {2010}}      or               leapyears = Select[DateRange[{2000}, {2020}, "Year"], LeapYearQ[#] &]      with the result               {{2000}, {2004}, {2008}, {2012}, {2016}, {2020}}      With Mathematica 10.0 for Mac OS X x86 (64-bit) (June 29, 2014)               DateRange[{2000}, {2010}, "Year"]      one will get               {{2000, 1, 1}, {2001, 1, 1}, {2002, 1, 1}, {2003, 1, 1}, {2004, 1,        1}, {2005, 1, 1}, {2006, 1, 1}, {2007, 1, 1}, {2008, 1, 1}, {2009,        1, 1}, {2010, 1, 1}}      `leapyears = Select[DateRange[{2000}, {2020}, "Year"], LeapYearQ[#] &]`               {{2000, 1, 1}, {2004, 1, 1}, {2008, 1, 1}, {2012, 1, 1}, {2016, 1,        1}, {2020, 1, 1}}      The Function `DateObject` does not clear a bean to me               DateRange[DateObject[{2000}], DateObject[{2012}], "Year"]      ![enter image description here](http://i.stack.imgur.com/Tcqmd.png) So, how can i get rid of the additional `month, day` information on V10, i.e. using `leapyears` and `DateObject` returning `Year` only?


title: Show[] combines my Graphics3D objects in an undesirable way

text: Thanks to those (Heike, Jens, MrWizard, and R.M.) who helped me yesterday with figuring out how to plot an EM wave. Now I am running into trouble with the `Show` command. I am trying to combine three Graphics3D objects:   * a slab   * a grating, and   * a wave. The wave is supposed to be comparable in size with the grating and it should fall on it from the top (like light would fall on a grating). `Show` puts these together as a GIANT giant slab with grating and a puny EM wave. The problem is that Mathematica puts all objects' coordinate axes origin to the same point. How can I control the relative placement and sizes of these objects in `Show`? My code follows:               (*     sw = slab width, sh = slab height, gw = grid width, gh =       grid height, cw = channel width, sl = slab length, EM1s =       strentgth of EM wave 1, EM1f = frequency of EM wave 1     *)          sw = 38; sh = 4; gw = 3; gh = 4; cw = 6; sl = 7 gw + 6 cw;     grating = Graphics3D[{RGBColor[0.917, 0.082, 0.478],         Cuboid[{{0, 0, sh}, {sw, gw, sh + gh}}],         Cuboid[{{0, gw + cw, sh}, {sw, 2 gw + cw, sh + gh}}],         Cuboid[{{0, 2 (gw + cw), sh}, {sw, 3 gw + 2 cw, sh + gh}}],         Cuboid[{{0, 3 (gw + cw), sh}, {sw, 4 gw + 3 cw, sh + gh}}],         Cuboid[{{0, 4 (gw + cw), sh}, {sw, 5 gw + 4 cw, sh + gh}}],         Cuboid[{{0, 5 (gw + cw), sh}, {sw, 6 gw + 5 cw, sh + gh}}],         Cuboid[{{0, 6 (gw + cw), sh}, {sw, 7 gw + 6 cw, sh + gh}}]},         Boxed -> False];     slab = Graphics3D[{RGBColor[0.101, 0.701, 0.623],         Cuboid[{0, 0, 0}, {sw, sl, sh}]}, Boxed -> False        ];     EM1s = 1; EM1f = 3; x1 = 2 Pi;     pts1 = Table[{t (x1/(2 Pi)), -EM1s Sin[EM1f t (x1/(2 Pi))], 0}, {t, 0,          2 Pi, 0.03}];     pts2 = {#, 0, -#2} & @@@ pts1;     EMw1 = Graphics3D[{Thickness[0.007],         {RGBColor[0.439, 0.188, 0.627], Line[pts1]},         {RGBColor[1, 0.721, 0.039], Line[pts2]}, Thickness[0.002],          Line[{#, # {1, 0, 1}}] & /@ pts1[[;; ;; 3]],          RGBColor[1, 0.721, 0.039],          Line[{#, # {1, 1, 0}}] & /@ pts2[[;; ;; 3]]},         AxesOrigin -> {0, 0, 0}, Axes -> {True, False, False},         Ticks -> None,         AxesStyle ->          Directive[Thickness[0.0075], RGBColor[0.439, 0.188, 0.627]],         Boxed -> False];     Show[slab, grating, EMw1, Axes -> False, Boxed -> False,       ImageSize -> {400, 520}, PlotRange -> All]      ![enter image description here](http://i.stack.imgur.com/K7K8R.jpg)


title: Why does Mathematica give the wrong answer when integrating?

text: I integrate               Integrate[Exp[I Cos[b - c]] Cos[b], {b, 0, 2 Pi}]      Mathematica gives:               2 I Pi BesselJ[1, 1]      Which is indepedent on $c$. However, the result is NOT independent on $c$. The numerical value of what Mathematica gives is `0. + 2.76492 I` while               NIntegrate[Exp[I Cos[b - 0.5]] Cos[b], {b, 0, 2 Pi}]      Gives               1.16655*10^-10 + 2.42645 I      Certainly not the same. If we multiply the value Mathematica gives with $\cos(0.5)$ the result is the same. What is wrong?


title: Are there advantages to using additional arguments of common functions rather than alternative ways of calculating with lists?

text: (Apologies for the long question title.) One of the interesting, if sometimes confusing, things about Mathematica is that there is always more than one way to do things. Even intermediate users can be confronted with the sudden realisation that there was an alternative syntax to do the same thing. There seem to be a number of less-well-known parts of the language hiding in plain sight as additional arguments to some very well known functions. Consider the following examples:   1. **Total** : `Total[somematrix, {2}]` is equivalent to   `Total /@ somematrix`   2. **Partition** : `Divide @@@ Partition[somevector, 2, 1]` is equivalent to   `Most[somevector]/Rest[somevector]`   3. **Join** : `Join[somematrixwith10rows, Array[f, {10, 1}], 2]` is equivalent to some complicated thing involving `Append` or `Transpose` to add a column at the end. I am sure there are others. The common thread between all three of the first example in each pair above is an additional argument that is often not well known, at least by me. Are there reasons for preferring one style over the other? It has been suggested to me that at least in the first example, the additional-argument version doesn't unpack and therefore saves memory over the case using `Map`. But are there other reasons, for example the ability to `Compile`, or other efficiency improvements? If it all down to personal taste and knowledge, I worry that it makes it hard to understand and learn from other people's code. And if there are best practices to follow, it would be good to make them more widely known.


title: A combination of Set::setraw and Set::shape errors

text: Please consider the following toy code:               In[1]:= toylist = {hyb["chip1"], hyb["chip2"], hyb["chip3"]};          toyindices = {{{3, 1}, {3, 2}}, {{2, 3}, {2, 3}}, {{1, 3}, {1, 2}}};          toydata = {{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, {{10, 11, 12}, {13, 14,           15}, {16, 17, 18}}, {{19, 20, 21}, {22, 23, 24}, {25, 26, 27}}};          Table[Evaluate[toylist[[i]]] =        Extract[toydata[[i]], toyindices[[j]]], {i, 1, Length[toylist]}, {j,        1, Length[toyindices]}] (* Version B *)          During evaluation of In[1]:= Set::setraw: Cannot assign to raw object 7. >>          During evaluation of In[1]:= Set::setraw: Cannot assign to raw object 8. >>          During evaluation of In[1]:= Set::setraw: Cannot assign to raw object 7. >>          During evaluation of In[1]:= General::stop: Further output of Set::setraw will be suppressed during this calculation. >>          Out[4]= {{{7, 8}, {6, 6}, {3, 2}}, {{16, 17}, {15, 15}, {12,         11}}, {{25, 26}, {24, 24}, {21, 20}}}          In[5]:= hyb["chip2"]          Out[5]= {16, 17}      * * * Even though the toy code above is producing the results I want, Mathematica throws the `Set::setraw` error. Question1: Is the error happening because I am using strings as indexes? Question2: Would it be safe to ignore or even turn this error off? The toy code above was designed to help troubleshoot a real-world problem I have. In the real-world case, I get two errors `Set::setraw` and `Set::shape`, from the following statement:               Table[Evaluate[mmsignalnames[[i]]] =         Extract[celvarnames[[i]], mmammindices[[j]]], {i, 1,         Length[celvarnames]}, {j, 1, Length[mmammindices]}];      Would you have any advice about the `Set::shape` error? I can't tell if it is related to the `Set::setraw` error. * * * More detail about the real-world problem....   1. I have 24 different biology datasets that have unique names. I have created a list called mmsignalnames which is composed of indexed symbols such as mmsignal["GSM356796"], mmsignal["GSM356797"] .... up to all 24 datasets. This is what I was trying to replicate in the toycode variable above.   2. My desire is to programmatically load each of these mmsignal["GSM356796"] etc symbols with specific data from each experiment. Each of the mmsignal[ .... ] symbols needs to receive a subset of data from a master list containing all 24 experiments worth of data, where each experiment is a sublist within the master list. This is what I was trying to replicate in the toydata variable above, where in the toydata varaiable I have 3 experiments worth of data entered as sublists.   3. The coordinates used to extract information from the masterlist (or toydata above) are contained within a list of indices that will be the same for each experiment. In other words, the same indices are used to extract data from the same position in 24 different experiments. So, in my toy code above, the output provided by my toy code, is actually what I want, and perhaps sloppily, does programmatically load specific information into the hyp["chip"] symbols.   4. Unfortunately, my real-world problem also has the Set::shape error which I can't seem to replicate in my toycode.


title: Effects of single-point and multi-point calls of Point on plot range

text: Several Graphics primitives are listable. For instance, `Point` accepts lists of coordinates so that multiple calls to `Point` are often unnecessary. The results are the same, except for one thing I noticed while working on the eye fixation question, yesterday.               pts = RandomReal[10, {30, 2}];       pl1 = Graphics[Point@pts];    (* single Point function call    *)     pl2 = Graphics[Point /@ pts]; (* multiple Point function calls *)          GraphicsRow[{pl1, pl2}, Frame -> All]      ![Mathematica graphics](http://i.stack.imgur.com/wl3At.png) The difference lies in the effect on `PlotRange`. Whereas a list of `Point`s yields a `PlotRange` of:               AbsoluteOptions[pl2, PlotRange]          (*     ==> {PlotRange -> {{0.493385472, 9.588596333}, {0.2849334536, 9.012342799}}}     *)      using the multi-`Point` syntax gives:               AbsoluteOptions[pl1, PlotRange]          (*     ==> {PlotRange -> {{0., 1.}, {0., 1.}}}     *)      The Get Coordinates tool gets the same coordinates in both figures. The question is: is there any good reason for the `PlotRange` reported in `pl1` or is this a bug?


title: Open Excel file with Mathematica

text: I would like to open an Excel file and manipulate it as a COM object. While I'm able to open an instance of excel with               Needs["NETLink`"]     InstallNET[]     excel = CreateCOMObject["Excel.Application"]      This doesn't work for me:                wb = excel@Workbooks@Open["D:\\prices.csv"]      Producing these errors:               NET::netexcptn: A .NET exception occurred: System.Runtime.InteropServices.COMException (0x80028018): Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))        at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad). Is this a known problem? I would very much appreciate any ideas on how to open an excel file with Mathematica as a COM object.


title: Find the parameter values satisfying conditions for all roots of an equation

text: Hi I'm very new at Mathematica. My real problems concerns a much more difficult equation with many parameters, but I want to check that the method is good, so I made up a test equation. My test equation and roots:               equ = (5 x^3 + z + x z + x^2 (1 + z) == 0)       sol = x /. Solve[equ, x]      Here is problem. I'm looking to the parameter `z` such that all the roots of the equation are less than zero (edit: real parts less than 0, where, `z` is a real number and the roots can be complex:               Reduce[Re[sol[[1]]] < 0 && Re[sol[[2]]] < 0 && Re[sol[[3]]] < 0 && Im[z] == 0, z]      The answer is (I think) `z > 4`, but the function `Reduce` doesn't calculate this in a reasonable time. How do I proceed? * * * EDIT after few days: In equation with more parameters:               equ=-11.8193 + 12.0482 b - 59.0964 x + 12.0482 a x - 11.8193 d x + 12.0482 b d x + 0.320482 x^2 + 12.0482 c x^2 - 59.0964 d x^2 + 12.0482 a d x^2 + 1. x^3 + 0.320482 d x^3 + 1. d x^4      Reduce[ForAll[x, equ == 0 \[And] Element[{a, b, c, d}, Reals], Re[x] < 0], {a, b, c, d}]      It is good code? I waiting and waiting for a response from the Mathematica. Maybe it would be faster if the program could write only one/few numerical answer?


title: How to REALLY Hold arguments and capture FullForm?

text: I'm trying to write an expression deconstructor or `FullForm`-capturer; might even call it a parser, maybe, but that might be too glorious a word. I got some great ideas from "Head and everything but...", but have plunged headlong back into the fog of my own limited understanding again, which got even foggier when I tried to understand "...function arguments on a stack...". I'd be most grateful for ideas, advice, and more clarity. Consider this example: `a + b + c`. We know its `FullForm` is `Plus[a, b, c]`, and I can "capture" that `FullForm` in a `List` with something like               Cases[{a + b + c}, head_[args___] -> {head, args}]      which produces               {{Plus, a, b, c}}      Now I go get myself all drunk on recursion and think I can write               SetAttributes[capture, HoldAllComplete];     capture[expr_?AtomQ] := {Head@expr, expr};     capture[head_[args___]] := {head, capture /@ {args}};      so that something like `capture[a + b + c]` gives me fantastic detail               {Plus, {{Symbol, a}, {Symbol, b}, {Symbol, c}}}      or, in stunningly beautiful `TraditionalForm` $\left\\{\text{Plus},\left( \begin{array}{cc} \text{Symbol} & a \\\ \text{Symbol} & b \\\ \text{Symbol} & c \\\ \end{array} \right)\right\\}$ All is well till I try               capture[1 + 2 + 3] ~~> {Integer, 6}      OH NO, it's not Holding inside! What I want, of course, is $\left\\{\text{Plus},\left( \begin{array}{cc} \text{Integer} & 1 \\\ \text{Integer} & 2 \\\ \text{Integer} & 3 \\\ \end{array} \right)\right\\}$ My problem is revealed by `traceView2`, which I got from "... clearest way to represent ..." ![Trace of offending call](http://i.stack.imgur.com/bGgQv.png) We see that `1 + 2 + 3` arrives held to `AtomQ`, as expected, but greedy old evaluator grabs it right there and smooshes it into 6. Everywhere else in the trace, the same thing happens. I don't know an easy way to stop the evaluator inside my `capture` faction. It has occurred to me to copy and adapt the code of `traceView2` to my application, since it exploits `Trace` to get ahead of the evaluator, and I will proceed that way unless I receive a cool answer here. In my dreams I imagine something like               SetAttributes[capture, DudeReallyHoldAllCompleteEverywhere];      or               SetAttributes[capture, HoldAllComplete, Levels -> Infinity];


title: Creating ghost trail effects

text: Does anyone know how to create a ghost trail effect? For a simple example look at this screenshot: ![Ghosting Effect](http://i.stack.imgur.com/6QriY.png) You can find the actual animation here. What I would ultimately like to see it happen is to make the object move based on whatever equations you specify it. For instance, to make it move around a circle the object should have the position `(cos[t], sin[t])`. Or, lets say you have a list of specified coordinates `{(x1,y1), (x2,y2), ..., (xn,yn)}`, All I want to be able to see is the trace as an object takes in the coordinates I specify. Here is a simple ball moving without the ghosting effect.               Animate[      Graphics[       Disk[{Cos[u], Sin[u]}, .25],       PlotRange -> {{-2, 2}, {-2, 2}},       ImageSize -> 400,        Axes -> True      ],      {u, 0, 6}     ]      ![enter image description here](http://i.stack.imgur.com/qp8ew.gif)


title: Plotting spherical surfaces

text: I am trying to make surface plots of squashed spheres. The spheres are defined by a list of points. For simplicity, consider the round sphere:               pts = Flatten[        Table[{Sin[θ] Cos[ϕ], Sin[θ] Sin[ϕ],           Cos[θ]}, {θ, 0, π, π/14}, {ϕ, 0,           2 π, 2 π/14}], 1];      One way to plot this is               ListPlot3D[pts,-pts,BoundaryStyle -> None,ColorFunction -> "Rainbow",InterpolationOrder      -> 2]      `ListPlot3D` has the nice feature that it interpolates the data to make a smooth surface. However, the northern and southern hemispheres are shaded differently, so there is a clear break at the equator: ![enter image description here](http://i.stack.imgur.com/A7jdx.png) An alternative is to do               ListSurfacePlot3D[pts]      Now the shading is uniform (there is no break at the equator). However, the data is no longer interpolated (and interpolation is not an option for `ListSurfacePlot3D`), so the surface looks rough and lumpy: ![enter image description here](http://i.stack.imgur.com/xkfXr.png) I am trying to find a solution that combines the best of both world: the smooth surface of `ListPlot3D` with the uniform shading of `ListSurfacePlot3D`.   Any suggestions? Thanks!


title: How to find all vertices reachable from a start vertex following directed edges?

text: How to find all vertices reachable from a given start vertex following directed edges, in a cyclic directed graph given as               Graph[{v1, v2, ...},            {v1 -> v11, v1 -> v12, ..., v2 -> v21, v2 -> v21, ..., vn -> vn1, vn -> vn2, ...}]      where all the ending vertices of edges `vij` are in the list of vertices `{v1, v2, ...}`. ?


title: How do I produce iterative equations and bifurcation diagrams?

text: I need to produce orbit diagrams for different values of x for the following equation:               f[r_][x_]:= r*x - x^3      I'm fairly new to _Mathematica_ , so I haven't had a lot of practice using it. Basically I need to produce bifurcation diagrams for different values of `x`; then, using these plots, identify `r` values at which bifurcation occurs and determine the convergence ratio. Any help would be much appreciated.


title: Compose one image over another

text: I'm a newbie in image processing using Mathematica. I'd like to compose an image $A$ over an image $B$ into an image _C_ such that $\quad C[i,j] = B[i,j]$, if $A[i,j]$ is white $\quad C[i,j] = A[i,j]$, otherwise It would work if I could do `Min` on each pixel: $\quad C[i,j] = \min(A[i,j],B[i,j])$ but `Min` does not seem to work component-wise. Perhaps I could turn white in $A$ into transparency and then compose over $B$. How can I do this?


title: Mean path length of randomly generated graphs

text: I am looking to find the the average path length of 1000 random graphs with the following degree distribution, a few of the vertex degrees are included below               {2, 12, 5, 1, 12, 3, 6, 4, 2, 6, 3, 4, 4, 1, 2, 4, 4, 1, 4, 4, 7, 9}      Now, I have done this with finding the mean global clustering coefficient in a very straightforward way:               Mean[GlobalClusteringCoefficient /@         RandomGraph[         DegreeGraphDistribution[           {2, 12, 5, 1, 12, 3, 6, 4, 2, 6, 3, 4, 4, 1, 2, 4, 4, 1, 4, 4, 7, 9}],          10000]]      This did the job quite well for `GlobalClusteringCoefficient`, but is there a way to do this to get the average path length of all 10000 random graphs? My intuition was using `GraphDistance`, but it only works as a per vertex basis -- for it to work, it needs a complete graph or else it calculates the distance as infinity.


title: Problem with numerical integration

text: I am not very used to do numerical simulations on Mathematica. I have a problem with numerical integration of this function. Is there any way for this calculation? Input:               α := 0.07          A := Sin[θ]*Sin[θ2]*Cos[φ - φ2] + Cos[θ]*Cos[θ2]     B := Sin[θ]*Sin[θ3]*Cos[φ - φ3] + Cos[θ]*Cos[θ3]     V := Sin[θ2]*Sin[θ3]*Cos[φ2 - φ3] + Cos[θ2]*Cos[θ3]          c2 := (B*c*c3 - c3*c3)/(A*c - c3*V)          integrand :=       1/2 1/((-1 + E^(c^2 - α)) (-1 + E^(c2^2 - α)) Abs[A c - c3 V])       c^4 c2^2 c3^2 (1 + 1/(-1 + E^(c^2 - α))) (1 + 1/(-1 + E^(c3^2 - α)))      (1 + 1/(-1 + E^(c^2 + 2 A c c2 + c2^2 - B c c3 + c3^2 - 2 c2 c3 V - α)))       (1 + 3 Cos[2 θ]) (c Cos[θ] - c3 Cos[θ3])      (c2 Cos[θ2] - c3 Cos[θ3]) Sin[θ] Sin[θ2] Sin[θ3]          NIntegrate[integrand,          {c3, 0, ∞}, {θ3, 0, π}, {θ2, 0, π},          {φ3, 0, 2 π}, {φ2, 0, 2 π}, {c, 0, ∞}, {θ, 0, π}, {φ, 0, 2 π},          Method -> "MultiDimensional"]      Output:                   NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the      following: singularity, value of the integration is 0, highly oscillatory integrand, or      WorkingPrecision too small. >>              NIntegrate::eincr: The global error of the strategy GlobalAdaptive has increased more      than 2000 times. The global error is expected to decrease monotonically after a number of      integrand evaluations. Suspect one of the following: the working precision is insufficient      for the specified precision goal; the integrand is highly oscillatory or it is not a      (piecewise) smooth function; or the true value of the integral is 0. Increasing the value of      the GlobalAdaptive option MaxErrorIncreases might lead to a convergent numerical      integration. NIntegrate obtained -27257.8 and 652260.228217954` for the integral and error      estimates. >>      I am using Mathematica 8.0


title: Is it possible to suppress 'Out[xxx]=' without suppressing 'In[xxx]:='?

text: While I have not exhaustively searched `Help/Documentation Center` for an answer to my question, I have put forth a yeoman's effort without any success. Does anyone know if it is possible to suppress `Out=` on an on-going basis within a notebook without also suppressing `In:=` and if it is, could you please tell me how? Thanks!


title: Add one to a major diagonal of a matrix given a coordinate point

text: n = 10;          board = ConstantArray[0, {n, n}];          diag1[x0_, y0_] :=      Module[{x = x0, y = y0},       While[{x != 1 || y != 1},        x--;        y--        ];       While[{x != n + 1 || y != n + 1},        board[[x, y]]++;        x++;        y++        ]       ]      I have an n by n matrix of all zeroes. On a given coordinate in the matrix, I need to increase everything in its major diagonal by one. A runchart of this works fine. All that this does, is increase the (x-1,y-1) by one. I believe that the while loops are only executing the statements once, but I can't be sure.


title: CDF file posted in WordPress won't run

text:
I just installed Mathematica 8.0.4.0, which has a CDF Deployment Wizard. This is supposed to make it easy to post a CDF file on a WordPress blog. I tried it, and it indeed was easy; the problem is that when I Previewed the post, the CDF logo showed up and created a rectangle that quickly turned solid gray. This is the entire code I used in my blog:

The example

      The two scripts were created by the Wizard and pasted into the post. You can download the file Elaborate Riemann Example.cdf yourself from the URL above, and, if you have CDF Player on your computer, you can run it. It works fine on my computer. But it won't appear within the post. Any ideas why?


title: Rearranging a biclustered matrix

text: I currently have a $77\times 38$ matrix, and I have used a clustering algorithm to cluster the row data and column data. The rows and columns of my matrix correspond to a list of country codes (not in numerical order). That is, I have a list of numbers:               {10, 28, 34, 44, ...}      where country 10 corresponds to row 1, country 28 to row 2, etc. I have a corresponding list for the columns of my matrix. I have independently clustered the columns and rows into groups of 3. For example, the row clusters look like so:               {{10, 1, 4, 2, ...,37 }, {28, 34, 27, 21, ..., 18}, {38, 20, ..., 12}}      Again, I have another clustering for the columns. I want to rearrange the rows and columns of my matrix such that the clustered rows and columns are next to one another. Using my example row cluster list, I want to rearrange the matrix such that row 1 corresponds to country 10, row 2 to country 1, row 3 to country 4, etc. After this, I wish to do the same with the columns of my matrix. Any help is appreciated. Edit: Haha, I apologize. I have a bad habit of haphazardly posting questions before going to sleep, hoping that my problems will all be solved in the morning. I have class now, but I'll probably update this later (+ examine all of the information already posted).


title: Applying l'Hôpital's Rule to NDSolve with Piecewise Function

text: OK, so I've been working on this problem for over a week and it's driving me crazy. I'm trying to solve a system of two differential equations in $x(t)$ and $y(t)$ using a "time-elimination method," such that $\tfrac{d x}{d t}/\tfrac{d y}{d t}=\tfrac{dx}{dy}$ reduces the system to a single differential equation in $x(y)$. The tricky part is that the initial condition needs to be defined at the steady state of the system $\\{x_{ss},y_{ss}\\}$, where $x'(t)=y'(t)=0$. The slope at this point is undefined since $dx/dy=0/0$ as $y\to y_{ss}$ by construction. I've seen two common ways of dealing with this. The first involves finding a kind of approximation to the solution by slightly perturbing the correct initial condition so that $x'(y)$ is always well defined. For example, suppose the system is defined as:               y0 = 1; yss = 10;     xdot = 2*x[t]-y[t];     ydot = (.01 + .1*x[t])*(Log[yss/y[t]]);      We can find a solution using:               xdoty[y_] = (xdot/ydot) /. {x[t] -> x[y], y[t] -> y};     NDSolve[{x'[y] == xdoty[y], x[yss - .001] == xss}, x, {y, y0, yss - .001}];      which yields the following results for $x(t)$ (purple) and $y(t)$ (blue): ![diffeqns_example1.png](http://i.stack.imgur.com/Kmclb.png) Notice that the solution for $y(t)$ "blows up" as it comes within .001 of $y_{ss}$. The second, more accurate approach is to overcome the ill-defined slope at the steady state via an application of l'Hôpital's rule. In _Mathematica_ , I usually deal with this by passing a `Piecewise` function to `NDSolve`, e.g.:               NDSolve[{x'[y]==Piecewise[{{xdoty[y],y<yss},{xdotyss,y==yss}}],x[yss]==xss},x,{y,y0,yss}]      where `xdotyss` is $x'(y_{ss})$ (a single scalar value) calculated after the application of l'Hôpital's rule. This yields the following results for the system: ![diffeqns_example2](http://i.stack.imgur.com/MBSmj.png) where both $x(t)$ and $y(t)$ are well-behaved throughout. The problem I am having is that this approach does not always seem to work well. Particularly, for some differential systems I can get the first "perturbation" method to give me approximately correct looking results, but the second "l'Hôpital method" always gives me the following error: > NDSolve::ndsz: At y == yss, step size is effectively zero; singularity or > stiff system suspected. Given that the first approach causes no errors, and the second approach is using the same differential equations to derive the value of the slope at that single point, shouldn't this always be a viable approach? I can't think of what would be causing the system to suddenly become "stiff." Any ideas?


title: How do I get VertexList to work directly on older graphs defined using rules?

text: In MMA 8, it seems that sometimes `VertexList` will work with rule-based graphs without needing GraphUtilities and at other times it won't. Once it starts working, it keeps working until I restart MMA. In addition, while it is working, `VertexList` is not colored Red to indicate shadowing. I know that I can use `GraphUtilities`VertexList` as shown below, but that is a bit much to type and I really want to understand why it is sometimes unnecessary. I also have dozens of notebooks with VertexList and don't really want to need to change all of them. Here is what happens:               In[1]:= VertexList[{a -> b}]     During evaluation of In[1]:= VertexList::graph: A graph object is expected at position 1 in VertexList[{a->b}]. >>         Out[1]= VertexList[{a -> b}]              In[2]:= GraphUtilities`VertexList[{a -> b}]         Out[2]= GraphUtilities`VertexList[{a -> b}]              In[3]:= Needs["GraphUtilities`"]         In[4]:= VertexList[{a -> b}]         Out[4]= {a, b}              In[5]:= $ContextPath = Rest[$ContextPath]         Out[5]= {"PacletManager`", "WebServices`", "System`", "Global`"}              In[10]:= VertexList[{a -> b}]         During evaluation of In[10]:= VertexList::graph: A graph object is expected at position 1 in VertexList[{a->b}]. >>         Out[10]= VertexList[{a -> b}]              In[7]:= GraphUtilities`VertexList[{a -> b}]         Out[7]= {a, b}      Is there any consistent way to force MMA to get VertexList to work on older style graphs without needing to use the full name? One more detail. When this works, I get exactly this behavior:               ?VertexList          VertexList[g] gives the list of vertices for the graph g.     VertexList[g,patt] gives a list of vertices that match the pattern patt. >>      which makes it look like the symbol is coming from System`


title: Importing High Precision (22 digits) data from a file

text: I want to import list from a file and I am using `ReadList` but my data is in format like this 8.2457409790900004e+08 but it i being imported like $8.24574*10^8$. Is there a way to increase the precision of import? Or even better, is there a way to change the notebook's precision globally ?


title: Meshing the surface of a non-convex object

text: I would like to mesh the surface of a cloud of points that may not be completely convex, for example the points in this question. Mathematica does not provide triangulation of 3D points, but there is a link to TetGen                Needs["TetGenLink`"]           {mypts, mysurface} = TetGenConvexHull[dat];      Graphics3D[GraphicsComplex[mypts, Polygon[mysurface]], Boxed -> False]      which results in this ![enter image description here](http://i.stack.imgur.com/I5TH5.jpg) Notice it doesn't get the surface meshing associated with subtle twist in the curved shape, and meshes points further away in the goal of creating a convex object. I suppose one could try to mesh the surface piece by piece and slowly merge it as in this answer, but that sounds like a nightmare. Here is the cloud of points for reference: ![enter image description here](http://i.stack.imgur.com/O0nL3.jpg)


title: Importing FITS file from HEALPix

text: I am trying to read FITS file created by HEALPix software. The file contains a spherical map of a scalar field. There is the online support on how to use the file in IDL, but not for Mathematica. I understand FITS is partly binary format, but I expect it is still standardised and contains readable description on how the data is stored. I tried reading Elements from the file in this way               Import["test.fits", #] & /@        Import["test.fits", "Elements"]      but the output is quite short and mainly empty lists, especially for               Import["test.fits", "Data"]     Import["test.fits", "TableData"]      The size of my file is 12.6 MB. Here is a link to the file. Is there another way to read the content of FITS file, besides these general 'Elements'? Do I need to know something about the structure of my FITS file in order to be able to read it with Mathematica? Could it be the problem is that Mathematica does not read all types of FITS files?


title: Dynamically show a specific number of the fractional part's digits

text: What is the fastest way to cut off all `n z` digits of the fractional part of a real number? (For example 12390.20934230) I came up with this so far:               Round[l_List, z_] :=       IntegerPart[l] +         Module[{r = RealDigits[l]},          Fold[10 #1 + #2 &, 0, Take[r[[1]], {Max[r[[2]],0]+z, r[[2]]+z}]] 10^-z]      Best would be a fast pure function to run over an array, and optimal would be to just show the output rounded (aka ScientificForm), but let the actual numbers as they are.


title: How can I change the scoping of a pure function returned by a function in a package?

text: I have written a small Mathematica package that contains a module that solves some differential equation with initial conditions. Suppose that the solution to this differential equation defines some other functions _y(t)_ and _z(t)_. I want this function to return these functions _y_ and _z_ as rules, much as NDSolve returns a rule for evaluating a function. Here is my first naive attempt to do this:               SolveEquation[x_, xp0_, x0_] := Module[{y, z},       sol = Flatten[         NDSolve[{x''[t] + x'[t]^3 == x[t]^2, x'[0] == xp0,            x[0] == x0}, {x}, {t, 0, 100}]];       y[t_] := (x[t] /. sol)^1/2;       z[t_] := y'[t] /. y[t];       Return[Join[sol, {Symbol["y"] -> Function[t, y[t]],Symbol["z"] -> Function[t, z[t]]}]]]      ` I can then correctly access the values of these functions with               rules=SolveEquation[x,0,100];     y[3]/.rules     9.89546      ` However, a call to _rules_ itself gives me:               {x -> InterpolatingFunction[{{0.,100.}},<>],y -> Function[t$, y$5338[t$]],       z -> Function[t$, z$5338[t$]]}      ` This is okay but in terms of human readability (the code will be used by individuals besides myself), I would much prefer:               {x -> InterpolatingFunction[{{0.,100.}},<>],y -> Function[t, y[t]],       z -> Function[t,z[t]}      ` or even better:               {x -> InterpolatingFunction[{{0.,100.}},<>],y -> x[t]^1/2,       z -> y'[t]/y[t]}      ` or some other way in which the dependence of each function on the others is made explicit. Is it possible to achieve this result by somehow changing the scoping of these variables or do I need to just settle for my method that works but appears sloppy?


title: Send HTML tables with SendMail

text:
I'm trying to send some HTML table using _Mathematica_ `SendMail` function. To do it I wrote this function:               createHTMLTable[list_List] /; Length[Dimensions@list] == 2 :=       Module[{r, head, data}, head = First@list;       data = Rest@list;       head = Map["   " <> ToString[#] <> "	\n" &, {head}, {2}];       data = Map["   " <> ToString[#] <> "	\n" &, data, {2}];       headData = Join[{head}, data];       r = "
\n" <> StringJoin[##] <> "
\n" & /@ headData // StringJoin;       r = "<!DOCTYPE html>
                         " <> r <> "
                                  "       ]      When I send the mail, as in this example:               list = RandomInteger[100000, {10, 3}]          SendMail["From" -> "test@test.com", "To" -> "test@test.com",       "Subject" -> "Sending Email from Mathematica", "Body" -> createHTMLTable[list],       "Server" -> "XXXXX"]      there is no table in the mail, but only the HTML text. Anyone knows how to correct this? Is there another way to do it?


title: How can I access a variable in one evaluator from another evaluator?

text: I have two notebooks, each with a different kernel. Is there a way to grab the value of a variable in KernelA from KernelB?


title: Building Reusable Custom Controls?

text: I would like to build an application using Mathematica 10. I would very much like to structure the application for maximum maintainability. To this end I would like to segregate controls and user interfaces to one set of source code files and calculations to another set of files. The basic idea being that the calculations are UI agnostic. They receive data and return the results of calculations and know nothing of UI code. The he same calculation .m files may be used from multiple user-interfaces (CDF, Web, Unit Test,.net, etc.). Scope is important. I would like to minimize the risk of changing a variable in a calculation that unintentionally sets a variable value in UI or if I call a function that wraps a custom control, I want to keep all Manipulate variables local to the Manipulate or function that wraps the Manipulate. I have tried using DynamicModule and LocalizeVariables->True but find that variables used by Manipulate are completely visible and settable in the notebook calling my DynamicModule where my control is defined. (I may be working with a set of assumptions and definitions of scope from application development languages that are not the same in Mathematica...) Ideally I would like the ability to decide which variables are global and which variables are local to the manipulate. I would like to build a set of re-usable custom controls in Mathematica 10 with the following criteria:   1. Would like to wrap my control(s) in a function or module in a .m or .wl file under specific contexts.   2. Variables are local to Manipulate and not visible or settable from the calling notebook.   3. Would like to package user settings and return them from the module that wraps Manipulate. Something along these lines: mySettings = MyControl[] Where MyControl[] encapsulates the manipulate and returns a dataset or array of settings selected by the user. I would also like the Manipulate variables to be local to MyControl[] and not visible or settable in the calling code or notebook. Again, I'm probably working under scope definitions of local and global used in application development languages. Below is an example:               EKSWaveFormControl[] :=          DynamicModule[                 {treatmentSpecRow},                 Manipulate[                     Plot[ ctrlVdc + ctrlVac  ctrlgFunc[ 2 \[Pi] ctrlf t + ctrlPhi],{t,0, 0.4}],                         {{ctrlgFunc,Sin,""},{Sin,Cos, Tan, Cot }},                         Delimiter,                         {{ctrlVac,1.5,Subscript["V","ac"]}, -10,10},                         {{ctrlVdc, 0.5, Subscript["V","dc"]}, -1,1},                         Delimiter,                         {{ctrlf, 10, "Frequency"}, 0.001,100},                         {{ctrlPhi, 0, "\[Phi]"}, 0, 2 \[Pi]},                         Delimiter,                         Button[                             "Update",                              treatmentSpecRow = Dataset[ Association @ { Func -> ctrlgFunc,                                                                        Vac -> ctrlVac,                                                                       Vdc -> ctrlVdc,                                                                       \[Phi] -> ctrlPhi,                                                                       \[Omega] -> 2 \[Pi] ctrlf }]],                         ControlPlacement->Left, Paneled->True, LocalizeVariables->True]             ]      When a user clicks the "Update" button, I would like to return a Dataset or array of the settings. But otherwise keep all variables used by Manipulate local to the Module.


title: Selecting morphological components, of a certain size, centered on points of interest in an image

text: I have a set of points in an image, for example:               POI = {{32.5, 257.5}, {73., 250.5}, {55.5, 248.5}, {209., 246.5}, {186.5, 245.5}, {154.5, 241.}, {213.5, 235.5}, {169.5, 233.5}, {212.5, 233.5}, {104., 231.5}, {18., 229.5}, {93., 228.5}, {203.5, 227.5}, {109.5, 224.5}, {138., 223.5}, {222., 222.}, {208.5, 218.5}, {0.5, 210.5}, {65.5, 209.5}, {98.5, 208.5}, {7.16667, 205.167}, {30.5, 205.5}, {257., 205.5}, {88., 203.}, {210., 202.5}, {246.5, 203.5}, {257.5, 199.}, {40.5, 198.5}, {217.5, 198.5}, {193.5, 197.5}, {0.5, 195.5}, {44.5, 192.5}, {159.5, 188.}, {120.75, 185.}, {39.8333, 183.833}, {207., 184.}, {239., 184.5}, {178.5, 183.5}, {52.5, 182.5}, {19.3, 178.9}, {155.5, 180.5}, {167.5, 179.5}, {19.5, 174.5}, {89.5, 174.}, {206.5, 173.5}, {44., 169.5}, {32.5, 169.}, {130.5, 168.5}, {106.833, 166.833}, {202.9, 165.7}, {215.167, 164.833}, {231.5, 165.5}, {46.5, 164.5}, {242.5, 164.5}, {200.5, 160.5}, {255., 155.5}, {108.5, 154.5}, {197.167, 154.167}, {192., 153.}, {10.5, 151.5}, {32.5, 149.5}, {111.3, 146.3}, {136.5, 147.5}, {187.5, 147.5}, {257.5, 146.5}, {63.1667, 146.167}, {122.5, 144.}, {135.5, 144.5}, {177., 144.}, {218.5, 144.5}, {26.1667, 143.167}, {211.5, 141.5}, {188.5, 140.5}, {106.833, 137.833}, {0.5, 136.5}, {29., 136.}, {98.5, 135.5}, {185.5, 134.5}, {145.5, 133.5}, {113.5, 131.5}, {219., 130.5}, {70., 129.5}, {11.1667, 128.167}, {183.5, 128.5}, {63.5, 125.5}, {60.5, 124.}, {85.5, 124.5}, {67.5, 122.5}, {43.5, 121.}, {182.5, 121.5}, {155.5, 119.5}, {252.5, 119.5}, {124., 118.5}, {97.5, 117.5}, {45., 115.5}, {104.167, 114.833}, {69.5, 112.}, {40.5, 111.5}, {117.5, 111.}, {1., 110.}, {34.5, 109.5}, {189.5, 109.5}, {32.1667, 107.833}, {100.5, 106.5}, {45.5, 105.5}, {106.5, 104.5}, {205.5, 104.}, {167.5, 103.}, {173.5, 103.5}, {185.5, 102.5}, {123.5, 95.5}, {181.5, 95.}, {45.5, 94.5}, {26.5, 87.5}, {74.5, 86.5}, {179., 86.5}, {93.5, 83.}, {188.5, 83.5}, {13.5, 80.5}, {75.5, 79.5}, {41.5, 78.5}, {162.5, 78.5}, {9.83333, 76.1667}, {179.5, 76.5}, {151.5, 74.5}, {182., 72.5}, {141.167, 67.1667}, {235.5, 66.5}, {156., 64.5}, {167.5, 64.5}, {212.5, 64.5}, {199.833, 60.8333}, {157.5, 60.}, {121.5, 54.}, {198.5, 54.5}, {83.5, 48.5}, {179.5, 46.5}, {228.5, 46.5}, {127., 44.5}, {204.5, 44.5}, {35.5, 42.5}, {79.5, 41.5}, {66.5, 40.5}, {80.8333, 38.8333}, {190.5, 38.5}, {51., 36.5}, {243.5, 31.5}, {93., 29.5}, {232.5, 29.5}, {232.5, 22.5}, {35.5, 20.5}, {121.5, 20.5}, {159., 17.5}, {219.5, 14.5}, {253.5, 13.}, {214.5, 11.5}, {77.5, 9.5}, {7.,8.5}, {168., 8.5}, {219.833, 6.83333}, {83.8333, 4.83333}, {22.5, 3.}, {140.5, 0.5}, {227.5, 0.5}, {253.5, 0.5}};      I would like to generate rectangular morphological components (compatible with ComponentMeasurements) of a certain size that are centered on each of these points. Specifically, I would like the components to have a side length of $l$ pixels, and where each point in the morphological component is at most a fixed Manhattan distance $d_{max}$ away from its centerpoint. How might I do this, perhaps using Dilate? And is it possible to have overlapping morphological components? Update : Answer to the last point on whether components can overlap: No (see comment by belisarius below). Update 2 : The command:               Dilation[Components, r]      Will take a single pixel, and blow it up it up into a square block with $r$ pixels on either side of the centerpoint. If there were some manner of generating a single-pixel component at each of my POI positions, I believe that would solve my problem. Is there an easy manner of doing this?