title: How to make Mathematica Simplify?

text: Let us define               r1 = 1;r2 = 2;      and               beta2[t_] := {r1*Cos[2*Pi*t], r2*Sin[2*Pi*t]}     beta1[t_] := beta2[t + 4.8*t^2*(t - 1)^2]      k[v_] := If[Norm[v] > 0, v/Sqrt[Norm[v]], 0]      with               q2[t_] :=  FunctionExpand[k[beta2'[t]], Assumptions -> t \[Element] Reals]          q1[t_] :=  FunctionExpand[k[beta1'[t]], Assumptions -> t \[Element] Reals]      Now when I call                q1'[3]      I get {4.56985 + 0.157049 (10.2293 Derivative[1][Abs][-5.97566] - 40.9174 Derivative[1][Abs][-3.88322]), -28.1291 + 0.102057 (10.2293 Derivative[1][Abs][-5.97566] - 40.9174 Derivative[1][Abs][-3.88322])} **Question** > How to simplify this expression?


title: Permutations: selecting reviewers without conflicts of interest

text: I would like to automate the process of selecting a number of proposal reviewers that fit a conflict of interest criterion. Let's say I have 5 reviewers and 5 applicants from 5 departments. The department of a person can be obtained from the function `getdept`:               depts = { "science",  "language",  "art", "history",  "education"};     reviewers = { "mary", "jane", "bob", "joe", "john"};     applicants = { "mary", "pete",  "al", "fred", "patty"};     getdept[person_] :=       person /. {"mary" -> "science", "jane" -> "language",         "bob" -> "art", "joe" -> "history", "john" -> "education",         "pete" -> "language", "al" -> "art", "fred" -> "art",         "patty" -> "language"}      Each proposal must be read by three reviewers, none of whom can be from the same department as the applicant. I can generate a table of possible reviewers:               possrev =       Table[{i,         DeleteCases[reviewers, x_ /; getdept[x] === getdept[i]]}, {i,         applicants}]      And looking at the result in this trivial example, I can manually identify reviewers:               possrev[[All, 2]] // MatrixForm      ![Mathematica graphics](http://i.stack.imgur.com/0ZcPI.png) I'm stuck with how to select sublists. It looks to me as if I should end with a 3xN matrix where N is the number of applicants. No element in the resulting matrix would be represented more than three times. (We can assume that `Length[reviewers] >= Length[applicants]`). I suspect that there will not be unique solutions and I do not need all solutions (although that would be interesting). Is it possible to find a solution matrix, `assignments` such that:               Length/@Union/@assignments = 3      and               Count[Flatten[assignments], #] & /@ reviewers <= 3       [I think these are the correct mathematical representations of my criteria, but I may be mistaken.]


title: Are built-in Mathematica functions already parallelized?

text: I've been noticing something strange since updating to Mathematica 8, and that is that occaisionally I'll see that the MathKernel is using up to 800% CPU in my Activity Monitor on OS X (I have 8 cores). I have no Parallel calls whatsoever, and this is in a single kernel, not across multiple kernels. My code is pretty much only Interpolates, Maps, Do loops, and plotting routines. I'm curious if some of the built-in Mathematica routines are in fact already parallel, and if so, which ones?


title: Revert y-axis in RegionPlot

text: I have the following code:               Module[{n = 300, p = 0.29},        RegionPlot[{y > (1/2)*(n - x) && y + x <= n && y > p/(1 - p)*x},          {x, 0, n}, {y, n, 0}, FrameLabel -> {"x", "y"},          PlotStyle -> {Directive[Yellow, Opacity[0.5]]}]]      which will give you the yellow region on the LHS in the figure below. ![enter image description here](http://i.stack.imgur.com/KTtZC.png) **Question** : I want to revert the y-axis of the RegionPlot so that the axis will look like the RHS in the figure above and the position and the shape of the region change accordingly. This would be the first step to make a ternary RegionPlot.


title: FE`symbols that remain in notebook internals even after removing them and SaveDefinitions->True issue

text: How does one clear the notebook from symbols that remain in it after an edit session?


title: How to draw the axis with ContourPlot3D

text: I see ContourPlot3D doesn't show the X, Y, Z axis by default (i mean inside the graph), i tried adding ",Axis->True" to the call, but doesn't make effect. How to do this?


title: What is the right way to rotate an array?

text: Suppose I have an array, not necessarily square: a = $\left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{array} \right)$ I want to rotate it like one of these: $\left( \begin{array}{ccc} 3 & 6 & 9 \\ 2 & 5 & 8 \\ 1 & 4 & 7 \end{array} \right)$     $\left( \begin{array}{ccc} 7 & 4 & 1 \\ 8 & 5 & 2 \\ 9 & 6 & 3 \end{array} \right)$     $\left( \begin{array}{ccc} 9 & 8 & 7 \\ 6 & 5 & 4 \\ 3 & 2 & 1 \end{array} \right)$ I have been using:               a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};          Reverse[a, {2}]\[Transpose]          Reverse[a\[Transpose], {2}]          Reverse[a, {1, 2}]      Is there a cleaner, faster, or otherwise better way to do it? I am more interested in a general solution rather than a compiled solution for an integer array, but if you have a nice compiled approach please make it work on version 7.


title: How to get and set default font parameters for Plot, ListPlot, LogPlot, etc.?

text: How can I find the _default_ font parameters (family, size, etc.) for the text that appears in `Graphics` produced by `Plot`, `ListPlot`, `LogPlot`, etc.? I'm interested not only in the font specs used for axis and plot labels, but also (and importantly) in those for the numbers displayed next to tick marks. EDIT: At the moment there appears to be two entirely different ways to set these parameters, and it is not clear to me which one takes precedence. One, suggested by ybeltukov, is through `Format->EditStylesheet...`. The other one, described in the post linked to by Kuba, is through `SetOptions[Graphics, BaseStyle -> {...}]`.


title: Nested For loop with NDsolve

text: I am solving two simple differential equation using `NDsolve`.               solution = NDSolve[{X'[t] == μ*S[t]*X[t]/(k + S[t]),                          S'[t] == -μ*S[t]*X[t]/(0.664252*(k + S[t])),                         X[0] == 10,S[0] == 300}, {X, S}, {t, 0, 40.7}]      bacteria[t_] = X[t] /. solution;      food[t_] = S[t] /. solution;      qq = Table[310 - bacteria[t] - food[t], {t, time}];      error = MapThread[Plus,Abs[(exp[[All, 1]] - qq)/exp[[All, 1]]*100/298]]      I need to evaluate `error` for different values of `k` and μ in order to check the values of k and μ for which error is less than 5%. `exp` and `time` are results which I have. When I try to put my code in a For-loop, it fails.               For[μ = 0.1, μ <= 1, μ = μ + 0.1,       k = 100       solution = NDSolve[{X'[t] == μ*S[t]*X[t]/(k + S[t]),                            S'[t] == -μ*S[t]*X[t]/(0.664252*(k + S[t])),                            X[0] == 10, S[0] == 300}, {X, S}, {t, 0, 40.7}]       bacteria[t_] = X[t] /. solution;       food[t_] = S[t] /. solution;       qq = Table[310 - bacteria[t] - food[t], {t, time}];       error = MapThread[Plus,Abs[(exp[[All, 1]] - qq)/exp[[All, 1]]*100/298]]       Print[error]]      The above is giving me errors and I do not get any results. My plan is to use this For-loop to vary μ and then use a nested loop for varying k. Any comments?


title: Column specific data inputs

text: My data is in the form of 6 columns in a notepad file. I want to import, only from a specific column,say, the third column into Mathematica in the form of a list, i.e., i want commas to be placed after each data points. Thanks in advance!


title: why version 9 is much slower than version 8 in producing these graphics

text: Consider this example(taken from Thomas's question here)               rv = RandomVariate[ExponentialDistribution[2], 10^6];     t = AbsoluteTime[]; ListLinePlot[rv, PlotRange -> All]     AbsoluteTime[] - t (*Put this line into the NEXT cell,and evaluate \     both cells together*)          t = AbsoluteTime[];     Style[ListLinePlot[rv, PlotRange -> All], Antialiasing -> False]     AbsoluteTime[] - t (*This line in separate cell!*)      and this example (taken from a related question here)               ls = Table[Sinc[x*y], {x, -10, 10, 0.1}, {y, -10, 10, 0.1}];     ListPlot3D[ls, PlotRange -> All,        InterpolationOrder -> 2] // AbsoluteTiming      I get different performance in version 8 and version 9. Version 8 seems to be about twice as fast as version 9. Why this happens and how to make version 9 as fast as version 8? ![enter image description here](http://i.stack.imgur.com/eLrV8.png) ![enter image description here](http://i.stack.imgur.com/AwdOC.png)


title: Is it possible to find a limit of a sequence given by its recurrence relation?

text: I need to calculate a limit of a sequence given by its recurrence relation. I tried the following:               Limit[DifferenceRoot[Function[{y, n}, {           - n (1 + n)^2 (5 + 2 n) y[n]            - (1 + n) (3 + n) (11 + 14 n + 4 n^2) y[1 + n]            + (-77 - 128 n - 69 n^2 - 12 n^3) y[2 + n]            + (29 + 84 n + 79 n^2 + 30 n^3 + 4 n^4) y[3 + n]            + (3 + n)^3 (3 + 2 n) y[4 + n] == 0,            y[1] == 0, y[2] == -1, y[3] == 1/8, y[4] == -215/216       }]][n], n -> Infinity]      but it returned unevaluated.


The function `PowerExpand[z^(a+b)]` does not transform $z^{a+b}$ into $z^a z^b$. Is there a way to force Mathematica 8 to expand $z^{a+b}$ into $z^a z^b$? In this case, the particular reason why is because the Mod function does not simplify expressions very well. I end up having to expand the powers by hand. For example, this expression should simplify to zero,               2^(3 + 4 k) + 2^(7 + 8 k) - 81^(1 + k);         Assuming[Element[k, Integers] && k > 1, FullSimplify[Mod[PowerExpand[%],5]]]      > >     Mod[4 (2^(1 + 4 k) + 2^(5 + 8 k) + 81^(1 + k)), 5] >


title: Plotting a StateResponse inside a loop for some reason gives an error

text: /edit Nevermind i figured it out, i now have:                   Do[AppendTo[sr,         StateResponse[{StateSpaceModel[{amtrx[[i]], b, c, d}], {rad3,            rad4}}, M1[t], {t, 0, 5}]], {i, 9}];     Do[Print[Plot[sr[[i]][[1]], {t, 0, 5}, PlotLegends -> i]], {i, 9}]      and it works If have tried               Do[Plot[StateResponse[{StateSpaceModel[{amtrx[[i]], b, c, d}], {rad3,        rad4}}, M1[t], {t, 0, 5}][[1]], {t, 0, 5}], {i, 9}]      as well as `For[x = 1, x < 10, x++, Plot[StateResponse[{StateSpaceModel[{amtrx[[x]], b, c, d}], {rad3, rad4}}, M1[t], {t, 0, 5}][[1]], {t, 0, 5}]]` but for some reason i keep getting the following error: > StateResponse::nsymb: 0.00010214285714285715` must be a symbol. >> However, when i remove the Plot from the loop and instead use print, like so:               Do[Print[StateResponse[{StateSpaceModel[{amtrx[[i]], b, c, d}], {rad3,       rad4}}, M1[t], {t, 0, 5}]], {i, 9}]      it does give the output i expect, namely 9 times: > > {InterpolatingFunction[{{0.,5.}},<>][t],InterpolatingFunction[{{0.,5.}},<>][t]} so why when i want to build a Plot inside the loop does it break all of a sudden, and how do i fix this?


title: How to simplify an expression with square roots?

text: The expression $\sqrt{L^2 M+\sqrt{L^2 (-J^2 + L^2 M^2)}}/\sqrt{2}$，can be simplified into $\sqrt{L}(\sqrt{LM + J}+\sqrt{LM - J})/2$, but how can I obtain this result with _Mathematica_? That is, how can I simplify               Sqrt[L^2 M + Sqrt[L^2 (-J^2 + L^2 M^2)]]/Sqrt[2]      into               Sqrt[L]/2 (Sqrt[L M + J] + Sqrt[L M - J])


title: How to make each node of a graph a button?

text: A newbie question this one - MMA help seems to suggest it would be possible to place a button on ( or have a button be ) each node of graph, labelled with the name of said node. I have no idea where to start with the syntax for this though...any help much appreciated.


title: Integral converging in M9 but not in M10

text: **Background** : Mac OSX 10.9.4, Mathematica _9.0.1_ vs. Mathematica _10.0_ (both versions are Student Editions). I have a notebook. It used to evaluate fine in Mathematica _9_. I upgraded to _10_ and, without doing any modification at all to the notebook, an integral stopped converging. I even tried after quitting/restarting the kernel and doing an OS reboot. In an attempt to provide a minimal test case I wrote a code snippet that had a typo (epsilon instead of 'element of ') which caused a great deal of confusion. The code would not work, neither in _9_ nor _10_. Thanks to Michael for identifying it. The original code in my notebook did not suffer from this typo, although I'm afraid most people thought it did. * * * I narrowed the problem down to the following code:               ClearAll["Global`*"];     u[n_, x_] := If[x <= 0 || x >= L, 0, Sqrt[2/L] Sin[n π x /L]]     φ[n_, k_] =     Assuming[{n \[Element] Integers, L > 0},         Simplify@             (1/Sqrt[2 π]) Integrate[u[n, x] Exp[-I k x], {x, 0, L}]]          Δk[n_] :=     Assuming[{n \[Element] Integers},     Simplify@         ((Integrate[             φ[n, k]\[Conjugate] k^2 φ[n, k], {k, -Infinity, +Infinity}] -         Integrate[             φ[n, k]\[Conjugate] k φ[n, k], {k, -Infinity, +Infinity}]^2)^(1/2))]     L = 1;     (* If I replace ParallelTable[] with Table[], the problem disappears *)     ParallelTable[Δk[n], {n, 1, 1}]          (* If I uncomment the following line, the problem disappears no matter        whether I use ParallelTable[] or just Table[] *)     (*Quit[]*)          (* From now on it's the original code snippet I wrote with the typo fixed *)     ClearAll["Global`*"];     u[n_, x_] := If[x <= 0 || x >= L, 0, Sqrt[2/L] Sin[n π x/L]]          \[Phi][n_, k_] =     Assuming[{n \[Element] Integers, L > 0},         FourierTransform[u[n, x], x, k, FourierParameters -> {0, -1}]]          η[n_, k_] =         Assuming[{n \[Element] Integers, L > 0, k \[Element] Reals},             FullSimplify[                 \[Phi][n, k]\[Conjugate] \[Phi][n, k]]]          Δk[n_] =         Assuming[{n \[Element] Integers, n > 0, L > 0, k \[Element] Reals},         Simplify@Sqrt@             Integrate[k^2 η[n, k], {k, -\[Infinity], +\[Infinity]}]]      Mathematica _9_ yields $n\pi/L$ as a result for the last expression. In Mathematica _10_ I get a convergence error: ![enter image description here](http://i.stack.imgur.com/Uu9Ww.png) **Summary**   1. The problem is real.   2. The problem happens only when I use `ParallelTable[]` (instead of just `Table[]`).   3. The problem goes aways when I run `Quit[]` just before the 2nd `ClearAll` command.


title: Standard Deviation and StandardDeviationFilter

text: I found this scant description of `StandardDeviationFilter` in the documentation, implying one could use it to generate a moving standard deviation: ![enter image description here](http://i.stack.imgur.com/6nfMi.png) ![enter image description here](http://i.stack.imgur.com/TBagj.png) I've got a need for this sort of thing so it looked interesting. I tried the following comparision:               data = RandomReal[{-10, 10}, 1000];     sd1 = StandardDeviation[#] & /@ Partition[data, 50, 1];     sd2 = StandardDeviationFilter[data, 50];           ListLinePlot[{sd1, sd2[[-Length[sd1] ;;]]}, AspectRatio -> 0.25, ImageSize -> 600]     Length[#] & /@ {sd1, sd2}     sd1==sd2      which gives me the following output: ![enter image description here](http://i.stack.imgur.com/Gy7tB.png) I'd have guessed that the two approaches would give me the same output. Clearly not. Can anyone explain what `StandardDeviationFilter` does or doesn't do and why it differs from the expected? I may have missed something in setting up this comparison (it happens ;-), any ideas appreciated.


title: Green functions for recurrence equations

text: Is it possible to solve recurrence equasions in _Mathematica_ with the use of Green's functions and get a solution as a series?


title: Output format in MatrixForm

text: I have a correlation matrix, which I want to display in the following format:   * 2 decimal places (e.g., -0.56)   * number signs "+" and "-" (e.g., +0.76 or -0.34) I've tried many different things, but I had no success so far... The code I'm using to generate the data is:               randomWalk[x_] := Accumulate[Prepend[RandomVariate[NormalDistribution[0, 1], x], 0]]     exchange = Table[Subscript[asset, i] = randomWalk[500], {i, 1, 5}];      Now the code I'm using to generate the correlation matrix:               N[Correlation[Transpose[exchange][[1 ;; 500, All]]], 2]//MatrixForm      However, the numbers generated are displayed with `$MachinePrecision`, and not 2 decimal places (although I've used `N[#,2]`). I've tried another code:               MatrixForm[Round[Correlation[Transpose[exchange][[1 ;; 500, All]]], 0.01]]      In this case I get the correlation matrix with 2 decimal places, but it's still missing the "+" signal before the number. So I've tried this last code:               NumberForm[Round[Correlation[Transpose[exchange][[1 ;; 500, All]]], 0.01],NumberSigns -> {"-", "+"}]//MatrixForm      In this last case I get the numbers correctly formatted, but I'm not able to put them in `MatrixForm`. Can someone give me a hint to solve this?


title: How to Gather a list with some elements considered unique

text: I have a list of the form:               list={{0,...},{1,...},{1,...},{0,...},{3,...},{3,...},{0,...},{0,...},{5,...},{5,...},{5,...},{0,...},{5,...},{0,...},...}      So when we take all the first elements we get a run of integers:               list[[All,1]]     (* {0,1,1,0,3,3,0,0,5,5,5,0,5,0,...} *)      What I want to do is sort my list based on the first element of each sublist (the integers) by gathering the non zero integers but preserving the zeroes between them. So for this example for the sorted list the list of all first elements would look like this:               {0,1,1,0,3,3,0,0,5,5,5,5,0,0,...}      i.e. the second and subsequent occurrence of "5" get moved to join the earlier occurrences. Likewise for all other occurrences of integers -- they get moved up to join the first occurrence or group of occurrences. I am doing this in a round about way at the moment in which I record a list of positions after the reordering and then return `list[[positions]]`. I can post what I am doing at the moment but am interested to know if anyone has a one or two liner type solution. Also I wasn't quite sure how to title this question to make it easier for searches. Any ideas on that? **Edit** The integers will not necessarily appear in order. So, for example, the first appearance of a non zero integer could be ordered like               3, 1, 5, 4, 6, ...      The function below is what I am using to return the list of positions:               sortedPositions[list_List] :=        Module[{tmp = list[[All, 1]], length, pos, tmp1, tmp2,          tmp3},        length = Length[tmp];        tmp1 = List /@ Cases[Transpose[{tmp, Range[length]}], {0, _}];        tmp2 = DeleteCases[Transpose[{tmp, Range[length]}], {0, _}];        tmp3 = GatherBy[tmp2, First];        tmp2 = Join[tmp1, tmp3];        Flatten[SortBy[tmp2, #[[1, 2]] &], 1][[All, 2]]        ];      But it seems like a lot of code to get the result I need. Here is a test list:               num = 20;     testList = Join[List /@ RandomInteger[{0, 9}, num], RandomReal[{0, 1}, {num, 6}], 2]          (*      {{6,0.456203,0.0900917,0.62677,0.638615,0.227849,0.61252},     {4,0.317069,0.44889,0.456945,0.05121,0.940742,0.495415},     {7,0.573698,0.381817,0.859495,0.517238,0.459022,0.957771},     {5,0.832945,0.867634,0.0843833,0.296803,0.944986,0.563913},     {1,0.598743,0.803861,0.082542,0.138926,0.630364,0.0445202},     {7,0.289183,0.257115,0.358083,0.677393,0.206347,0.987678},     {5,0.947487,0.320408,0.600928,0.0718489,0.976703,0.449376},     {0,0.0996927,0.210278,0.408291,0.861885,0.946081,0.0522955},     {0,0.537572,0.160541,0.212737,0.508406,0.353786,0.479605},     {7,0.0815373,0.0677839,0.388955,0.681041,0.795607,0.404398},     {4,0.18704,0.253819,0.141732,0.43889,0.931269,0.556534},     {2,0.262136,0.110553,0.60296,0.482498,0.693049,0.430039},     {5,0.569696,0.262133,0.397575,0.246202,0.499777,0.073326},     {6,0.487893,0.121165,0.413376,0.874849,0.836484,0.792685},      {0,0.677934,0.543956,0.593967,0.138832,0.896184,0.604194},     {2,0.138691,0.150235,0.614355,0.326924,0.615902,0.900494},     {0,0.0254698,0.258354,0.377134,0.569083,0.0925844,0.672802},     {7,0.354392,0.976598,0.658138,0.124943,0.39485,0.239671},     {2,0.622461,0.195612,0.997663,0.421797,0.130802,0.110463},     {2,0.136431,0.799215,0.698071,0.0599957,0.452992,0.378609}} *)      Find the position order you want in your final list:               positions = sortedPositions[testList]     (* {1, 14, 2, 11, 3, 6, 10, 18, 4, 7, 13, 5, 8, 9, 12, 16, 19, 20, 15, \     17} *)      Make your "sorted" list "sorting" according to an algorithm applied to the first element:               testList[[positions]]     (*      {{6,0.456203,0.0900917,0.62677,0.638615,0.227849,0.61252},     {6,0.487893,0.121165,0.413376,0.874849,0.836484,0.792685},     {4,0.317069,0.44889,0.456945,0.05121,0.940742,0.495415},     {4,0.18704,0.253819,0.141732,0.43889,0.931269,0.556534},     {7,0.573698,0.381817,0.859495,0.517238,0.459022,0.957771},     {7,0.289183,0.257115,0.358083,0.677393,0.206347,0.987678},     {7,0.0815373,0.0677839,0.388955,0.681041,0.795607,0.404398},     {7,0.354392,0.976598,0.658138,0.124943,0.39485,0.239671},     {5,0.832945,0.867634,0.0843833,0.296803,0.944986,0.563913},     {5,0.947487,0.320408,0.600928,0.0718489,0.976703,0.449376},     {5,0.569696,0.262133,0.397575,0.246202,0.499777,0.073326},     {1,0.598743,0.803861,0.082542,0.138926,0.630364,0.0445202},     {0,0.0996927,0.210278,0.408291,0.861885,0.946081,0.0522955},     {0,0.537572,0.160541,0.212737,0.508406,0.353786,0.479605},     {2,0.262136,0.110553,0.60296,0.482498,0.693049,0.430039},     {2,0.138691,0.150235,0.614355,0.326924,0.615902,0.900494},     {2,0.622461,0.195612,0.997663,0.421797,0.130802,0.110463},     {2,0.136431,0.799215,0.698071,0.0599957,0.452992,0.378609},     {0,0.677934,0.543956,0.593967,0.138832,0.896184,0.604194},     {0,0.0254698,0.258354,0.377134,0.569083,0.0925844,0.672802}}      *)      So by "sorting"/"gathering" based on doing something with the first elements you do something like what I have tried to illustrate in the image below: ![enter image description here](http://i.stack.imgur.com/7F9nf.png) and create a new ordering of ultimately the initial list (`testList`) with the new order probably best seen by the new order of the first elements: ![enter image description here](http://i.stack.imgur.com/ULiP8.jpg) * * * As per Mr.Wizards answer what I am wanting to do is gather the list based on the first elements however I don't want to gather the zeros so only non-zero first elements are grouped.


title: Plotting a solution of the Allee Effect

text: I am doing a project on the Allee Effect. I am able to successfully create a stability analysis. That is, I can find the relevant equilibrium points ($y_e = 0,\ y_e = \alpha$ and $y_e=k$) and draw approximation curves. However, I am having trouble plotting the solution. The differential equation is $$ \frac{dy}{dx} = r y \left( 1 - \frac{y}{k} \right) \left(\frac{y}{\alpha} -1 \right) $$               sol = DSolve[y'[x] == r y[x] (1 - y[x]/k) (y[x]/a - 1), y, x]      Will produce the output: > >     {{y -> Function[{x}, >         InverseFunction[ >           Log[#1]/(a k) + Log[-a + #1]/(a (a - k)) + Log[-k + #1]/( >             k (-a + k)) &][-((r x)/(a k)) + C[1]]]}} >   where `a`, `r`, and `k` are constants depending on the population. When I try to plot `sol` using the code               Plot[Evaluate[y[x] /. sol /. {C[1] -> 1}], {x, -7, 7}, PlotRange -> All]      It will output an empty.I was told to use the manipulate function for the constants. Please can someone help.


title: Non-linear integral equation

text: I'm trying to solve with Mathematica an integral equation. I found this excellent answer (How to solve a non-linear integral equation?) solving with a collocation method a problem which can be restated as: $$ \int_a^b f \left( \phi \left(x \right) \right) \mathrm{d} x= 1 $$ for some function $f$, $\phi(x)$ being the unknown. My problem is slightly more complicated: $$ \phi(x) = \int_a^b K \left( x, y \right) f \left( \phi \left( y \right) \right) \mathrm{d} y $$ and the kernel $K(x,y)$ is singular for $x=y$, it behaves as $\sim \frac{1}{\left| x - y \right|}$. I would like to know if it is possible to extend the collocation method to this case, or, alternatively, which other methods can be used to numerically solve my integral equation. Thanks in advance! Edit: some more details: $$ f(\phi(x)) = \frac{\phi(x)}{\sqrt{\phi^2(x) + C^2}} $$ $$ K(x,y) = y \frac{\mathrm{e}^{-\left| x - y \right|}}{\left| x - y \right|} $$


title: How to assign a list of subsript?

text: I want to assign Subscript[C,i] by mapping a specific list. For example, the list is {1,2,3,4}, and I want to assign 1 to C1, 2 to C2, 3 to C3 and 4 to C4. How should I do? Many thanks:)


title: Successful match in Replace but not in Cases?

text: I have a little example that exhibits a successful pattern match in `ReplaceAll` that `Cases` misses and I wonder if the assembled sages would be so kind as to offer me an explanation? This is chopped from an original Prolog emulator by Renan Cabrera circa 2000.               ClearAll[k,s,l,m,j,f,w,g,a,b]      Consider an unordered sequence of _statements`s`_ stored in a _knowledge base`k`_, each being a _predicate`l`_ about some _terms`m`, `f`, `j`,_ and _`w`_ :               k=s[l[m,f],         l[m,w],         l[j,w],         l[j,m]     ];      We wish to search this knowledge base for any predicates such that `l[m,X_]` and `l[j,X_]`, where `X_` matches the same term in both predicates. Our first cut is something like               k /. s[l[m,X_],l[j,X_]] -> a[X]     (* Out[42]:= s[l[m,f],l[m,w],l[j,w],l[j,m]] *)      but this doesn't work until we make _s_ flat and orderless (associative and commutative):               SetAttributes[s,{Flat,Orderless}]      and now               k /. s[l[m,X_],l[j,X_]] -> a[X]     (* Out[43]:= s[a[w],l[j,m],l[m,f]] *)      This is, of course, just the same as `ReplaceAll[k, s[l[m,X_],l[j,X_]] -> a[X]]`. (notice the canonical reordering in the output), and now I can extract my answer with something like               Cases[k /. s[ l[m, X_], l[j, X_] ]->a[X],a[Y_]->Y]     (* Out[44]:= {w} *)      The surprise and the question is why doesn't this work?               Cases[k, s[ l[m, X_], l[j, X_] ] -> a[X]]     (* Out[45]:= {} *)      or even this               MatchQ[k, s[ l[m, X_], l[j, X_] ]]     (* Out[46]:= False *)      It's as though `ReplaceAll`, `Cases`, and `MatchQ` are using different pattern matchers. Will be grateful for advice, clues, discussion, etc.


title: Numeric function not fully evaluating

text: I'm running into an issue where it seems Mathematica is not fully evaluating the output of my function h[t_]. I included the definition of phi[t_] just to demonstrate that it is a numerically defined function in case that is what's causing the problem. This is causing the plot for h[t_] to turn up blank, because I guess the evaluation at each point is not numeric. Does anyone have some idea what's going on? I'm a bit of a Mathematica noob, I just recently switched from Maple which shit the bed so hard on a computation I was trying to do that I had to find an alternative software. Thanks! (Also, m,u,a are all defined as constants at the beginning of the notebook)               phi[t_] =       With[{a = E^-25, b = 1/4},         NDSolve[{x'[t] == (           8/20^4*(x[t])^2*(1 - a*E^(400*(x[t])^2)) - (6*(3/               10)^4*(1/20^2*((x[t])^2 - b^2) -                 1/20^4*(a*E^(400*(x[t])^2) - 1))))/((3/             10)^2*(3*(3/10)^4 - (4/                20^2*(1 - a*E^(400*(x[t])^2))) + (8*(x[t])^2*a*E^(                400*(x[t])^2)))), x[0] == 0}, x[t], {t, -140, 140}]][[1,All,2]]           h[t_] := N[(2*m^2*phi[t])/(3*u^2)*(1 - a*E^(phi[t]/m)^2)]          h[1]          (*  {0.000104884 (1. - 1.01291/e^25)} *)


title: Trying to prove that $x\sin(\frac{\pi}{x})\ge\pi \cos(\frac{\pi}{x})$ for $x\ge 1$

text: Consider the function               f[x_] := x Sin[Pi/x]      I want to prove that this function is increasing for $x\ge 1$. This can be done with the first derivative. We have to prove that $f'[x]\ge 0$ for $x\ge 1$. First I tried               FullSimplify[f'[x] >= 0, x >= 1]     (*Out: x Sin[\[Pi]/x] >= \[Pi] Cos[\[Pi]/x] *)      Then I realized that Mathematica probably doesn't know about the inequality $\tan(x)>x$ for $0<x<\pi/2$. So I tried:               FullSimplify[f'[x] >= 0, x >= 1 && ForAll[y, 0 < y < Pi/2, Tan[y] > y]]     (*Out: x Sin[\[Pi]/x] >= \[Pi] Cos[\[Pi]/x] *)      This inequality seems to be easy, I tried replacing `x >= 1` with `x >= Pi` and I get the same result. How can I properly use Mathematica to prove some theorems like this one? EDIT: The main point of the problem is not trying to prove that the function is increasing (that is the motivation of the problem) , the main point is trying to prove that $x\sin(\frac{\pi}{x})\ge\pi \cos(\frac{\pi}{x})$ for $x\ge 1$ using that $\tan(x)>x$ for $0<x<\pi/2$, i.e. i want to use the proving features of Mathematica.


title: How to plot CDF of a Poisson distribution in Mathematica

text: How to plot the following in Mathematica: $$P = \sum_{k=C+1}^{\infty}\frac{e^{-C^\gamma} (C^\gamma)^k}{k!}$$ I want to plot $P$ versus $C \log{C}$ for a given $\gamma$ with logarithmic scale on Y-axis. In Matlab, I'd calculate it as follows:               gamma = 0.75;     C = 1:1:20;     lambda = C .^ gamma;     p = 1 - poisscdf(C,lambda);     semilogy(C .* log(C), p);


title: Calculate integral in limit of very large coefficient

text: How I can calculate following integrals for large values $\alpha$ in Mathematica: $$ I_1 =\int_{0}^{y} \exp\left(\, -\alpha \sqrt{x(1-x)}\,\right)\, {\rm d}x $$ $$ I_2 =\int_{0}^{y} \exp\left(\, -\alpha \sqrt{x}\,\right)\, {\rm d}x $$


title: Definite Integral, Piecewise, Error

text: I am trying to evaluate the following:               myExpression=Piecewise[{{-c E^(c s)-(E^(-((-s+\[Alpha]+q \[Beta])^2/(2 (\[Beta]^2 \[Sigma]q^2+\[Sigma]s^2)))) v \[Beta])/(Sqrt[2 \[Pi]] Sqrt[\[Beta]^2 \[Sigma]q^2+\[Sigma]s^2]),\[Beta]!=0},{-c E^(c s),\[Beta]==0}}]     Integrate[myExpression,s]      However, when I try to make this Integral definite, by using {s,0,z}, I get the following error:               Integrate::pwrl: "Unable to prove that integration limits {0,z} are real. Adding assumptions may help"      I do not wish to change the expression of this integral, nor do I care for some cheap trick which removes the error message (like `Quiet`). I simply want to know where this error comes from, and what additional information about my variabales _Mathematica_ would like to know. Thanks! Laurens


title: How can I represent this automorphism of Q(i,a)?

text: Let $a$ represent some real irrational number. I am trying to perform computations with an automorphism $f:\mathbb{Q}(i,a)\to\mathbb{Q}(i,a)$ which fixes $\mathbb{Q}(i)$ pointwise and maps $a$ to $i a$. What's the best way to represent $f$? My approach below didn't work, since `f@f` performs a replacement on the symbol `f`:               f[x_] := x /. a -> I a     f[a]          (* I a *)          f@f[a]          (* -a *)          (f@f)[a]          (* I a (* Not the same as f@f[a] ?! *) *)      What's the best way to define `f` so that this does not happen?


title: How to work with large numbers

text: How do I browse very large numbers in mathematica, say $10^{{10}^{{10}^{1.414\ldots}}}$? By browse I mean finding the $k$th decimal place before or after the decimal point. Everything I have tried has given me `overflow[]` or something equally useless.


title: Algebra problem

text: I have recently run into an algebra problem that goes as follows. Using the numbers 1-9               A + B + C + D = EF     E + F + G + H = CJ     B + G + J = ?D     total = B?      where each letter is a different number. I believe when it says `EF` it does not mean `E*F` but more like if answer was `15`, then `E = 1` and `F = 5`. Been working on this for hours, even attempted to write a computer program to help solve but to no avail. Any tips on how to solve (or a work through of it) would be greatly appreciated.


title: Error when using EquationTrekker

text: I just got to know `EquationTrakker` because I need to do phase graphs for my classes. When I load it               << EquationTrekker`      everything works fine with no errors. However when I try to use an example of the documentation, I get:               EquationTrekker[y''[x] + y[x] == 0, y, {x, π/8, 2 π}]      > During evaluation of In[7]:= LinkObject::linkd: Unable to communicate with > closed link > LinkObject['/usr/local/Wolfram/Mathematica/10.0/SystemFiles/Java/Linux-x86-64/bin/java' > -classpath "/usr/local/Wolfram/Mathematica/10.0/SystemFiles… r > -Djava.util.prefs.PreferencesFactory=com.wolfram.jlink.DisabledPreferencesFactory > com.wolfram.jlink.Install -init "/tmp/m000004140851",480,4]. >> > > During evaluation of In[7]:= GUIRunModal::nvalid: The GUI definition > contains invalid content. >> > > During evaluation of In[7]:= LinkObject::linkn: Argument > LinkObject['/usr/local/Wolfram/Mathematica/10.0/SystemFiles/Java/Linux-x86-64/bin/java' > -classpath "/usr/local/Wolfram/Mathematica/10.0/SystemFiles… r > -Djava.util.prefs.PreferencesFactory=com.wolfram.jlink.DisabledPreferencesFactory > com.wolfram.jlink.Install -init "/tmp/m000004140851",480,4] in > LinkWrite[LinkObject['/usr/local/Wolfram/Mathematica/10.0/SystemFiles/Java/Linux-x86-64/bin/java' > -classpath "/usr/local/Wolfram/Mathematica/10.0/Syst… > a.util.prefs.PreferencesFactory=com.wolfram.jlink.DisabledPreferencesFactory > com.wolfram.jlink.Install -init "/tmp/m000004140851",480,4],<<1>>] has an > invalid LinkObject number; the link may be closed. >> >   >   >     $Failed >   How can I fix this? edit: forgot to mention I'm using Ubuntu 14.04. Haven't tried it on Windows 8 (dual boot) edit2: It works properly on Windows 8. It looks like it's a problem with any java package in ubuntu...


title: RegionPlot3D and Texture

text: I'm getting a white solid instead of a solid with texture, I'm not sure what is wrong:               RegionPlot3D[M, {a, -3, 3}, {c, -3, 3}, {d, -3, 3}, PlotPoints -> 100,       PlotStyle -> Directive[Texture[ExampleData[{"Texture", "Bricks2"}]]]      Here M is the solid defined by:               M:= (a < 0 && ((c < 0 && (d < 0 || d > -2 a - c)) || (c >              0 && (d < -c || d > -2 a)))) || (a >          0 && ((c < 0 && (d < -2 a || d > -c)) || (c >              0 && (d < -2 a - c || d > 0))))


title: How to determine three last bindings made to a variable when evaluating an expression?

text: How can I create a list of bindings made to a certain variable when evaluating an expression? I want to determine three bindings made.


title: Define an 'inner product' with AngleBracket

text: I want to define my own little 'Inner Product' function satisfying properties of linearity and commutativity, and I'd like to use the "$\langle$" and "$\rangle$" symbols to output my results. For this I am using `AngleBracket` which has no built-in meaning. I was able to use `SetAttributes[AngleBracket,Orderless]` to give my inner product the property of commutativity. $\langle v,w\rangle=\langle w,v\rangle$. Then I am able to inconsistently get the AngleBracket to distribute over addition using for example `Distribute[AngleBracket[u+v,w]]` But I am at a loss to impose the conditions $\langle a v, w\rangle=a\langle v,w \rangle$ where $a$ satisfies `NumericQ[a]==True`, and especially $\langle 0,v\rangle = 0$. How can do this? Do I need to write my own 'myInnerProductSimplify' function?


title: NonlinearModelFit with multiple parameters

text: I am now trying a slightly more complicated model which actually consists of finding the parameters of 2 particles in an Image (I attached an Plot of an image). Although I put very good initial values and constrains Mathematica wasn’t able to produce a result. Note at the final stage I will need to decompose the location of 4 particles...               J[i_, j_, α_, β_, xpos_, ypos_, clip_] := N[Clip[(β α^2*π)/ 4*((Erf[(j - xpos)/α ] - Erf[(j + 1 - xpos)/α ])*(Erf[(i - ypos)/α ] - Erf[(i + 1 - ypos)/α ])), {0, clip}]];     PixelImage[mat_]:=ArrayPlot[Rescale[mat,{0,Max[mat]},{Max[mat],0}],Epilog->{Red,MapIndexed[Text[#1,Reverse[#2-1/2]]&,Reverse[mat],{2}]},Mesh->True];     MyThreshold = 4043;     model1 = Clip[N[(β1 α1^2*π)/4*((Erf[(j - xpos1)/α1 ] - Erf[(j + 1 - xpos1)/α1 ])*(Erf[(i-ypos1)/α1 ] - Erf[(i + 1 - ypos1)/α1]))], {0,MyThreshold}];     model2 = Clip[N[(β2 α2^2*π)/4*((Erf[(j - xpos2)/α2 ] - Erf[(j + 1 - xpos2)/α2 ])*(Erf[(i -ypos2)/α2 ] - Erf[(i + 1 - ypos2)/α2]))], {0, MyThreshold}];     Model = Clip[(model1 + model2), {0, MyThreshold}];     data1 = Flatten[Table[{i, j, J[i, j, 0.7, 500, 6.5, 6.5, MyThreshold]}, {i, 1, 14}, {j, 1, 14}], 1];     data2 = Flatten[Table[{i, j, J[i, j, 0.6, 300, 4.5, 4.2, MyThreshold]}, {i, 1, 14}, {j, 1, 14}], 1];     Data = Transpose[{data1[[All, 1]], data1[[All, 2]], Clip[data1[[All, 3]] + data2[[All, 3]], {0, MyThreshold}]}];     PixelImage[Round[Partition[Data[[All, 3]], 14]]]          nlm = NonlinearModelFit[Data, {Model,         {0.4 <= α1 <= 0.8, 0 <= β1 <= 6000, 0 <= xpos1 <= 8,           0 <= ypos1 <= 8, 0.4 <= α2 <= 0.8, 0 <= β2 <= 6000,           0 <= xpos2 <= 8, 0 <= ypos2 <= 8}}, {{α1, 0.6}, {β1,           300}, {xpos1, 6.5}, {ypos1, 6.5}, {α2, 0.6}, {β2,           300}, {xpos2, 4.5}, {ypos2, 4}}, {i, j}, Method -> "NMinimize"];     nlm["BestFitParameters"]


title: Getting new symbols into Mathematica

text: What is the easiest way get new symbols into _Mathematica 9_? For example I want to be able to write the Symbol               \mathfrak{A}      that you have in _Latex_. I know that you can simply write an "A" in the notebook and change the font, so you get the right symbol. But this way you have to change between the font- window and the notebook window, and find the right font for your purpose. Favourably I would like to set a new pallet or integrate the symbol in the aliases or set a shortcut like `Cmd`+`Shift`+`A` for the symbol above I already tried to change the fonts of _Mathematica_ generally, so that the Symbol produces by "`Esc` `A` `Esc`" changes to `\mathfrak{A}` in _Latex_ , but did not get any satisfying result.


title: How to find this convolution?

text: How can I use _Mathematica_ to find the convolution $f*f$ for               f[t_]:=Piecewise[             {{t*(Pi - 4*t + t^2), Inequality[0, Less, t, LessEqual, 1]},               {(-t)*(2 + t^2 - 4*Sqrt[-1 + t^2] - 2*ArcCsc[t] + 2*ArcTan[Sqrt[-1 + t^2]]),                 1 < t < Sqrt[2]             }}, 0]      I would need a symbolic expression for the convolution. Thanks for any help.


title: Mathematica Package for Bayesian Networks

text: Are there any packages that allow the simulation of Bayesian Networks with Mathematica? I found what seemed to be a promising package (Dynamics) on a Brown University URL, http://www.cs.brown.edu/research/ai/dynamics/tutorial/Mathematica/ReadMe with an example notebook here http://www.cs.brown.edu/research/ai/dynamics/tutorial/Documents/GraphicalModels.html but unfortunately it seems that it is not included on their public FTP server. Thanks in advance...


title: Export graphics in parallel

text: I run a heavy simulation, using `NDSolve` and the method of lines. This means that the result of `NDSolve` is a list of, say, 400-1000 interpolation functions with many interpolation points. The whole thing can weigh up to 4GB. As it is, this poses no problem. The challenge is when I try to make a movie out the simulation. I do the following: I have a function               snapshot[sol_,t_]:=GraphicsGrid[{Plot[...],Plot[..],...}]      which take the result of `NDSolve` (what I call `sol`) and a specific time `t`, and makes some plots of the simulation at that time. Then, I export these graphics with something like               Table[       Export["~/tmp/" <> IntegerString[k, 10, 4] <> ".png",snapshot[sol, tList[[k]] ],     {k, 1, n}]      where `tList` is a list of times. Then I can make a movie out of the images with an external program (`ffmpeg`). The problem is that exporting the graphics like this takes a lot of time and I want to run it in parallel. Using `ParallelTable` is very bad, because it creates a local copy of the very heavy variable `sol` in all subkernels, and this immediately freezes my computer. I had no luck with `ParallelSubmit` or the like. Any ideas? _**EDIT**_ In response to all the commenters:   1. The plot is indeed local in the time variable.   2. I tried converting the `InterpolatingFunction`s to an numerical array. It saves some memory (a factor of ~50) but that's not enough - Still if you duplicate the data 1000 times (for 1000 frames) you'll be in bad shape. Basically, what I want is to send requests to **multiple processors** , but that will all run **on the same kernel**. This way you don't have to duplicate I thought it was possible because in MATLAB I do that naturally with the `parfor` command (or, at least, I think that's what I'm doing).


title: What's the best way to generate all the upper triangular matrix whose singular values are given?

text: For example, given $\lambda_1 = 1, \lambda_2 = 2, \lambda_3 = 3$, what's the best way to generate all the upper triangular matrix ($3\times 3$) whose singular values are $\lambda_i$? Note:Given a matrix $A$, if the eigenvalues of $A^HA$ are $\lambda_i \geq 0$, then $\sqrt{\lambda_i}$ are the singular values of $A$. $A^H$ is the conjugate transpose of $A$. Generally, If $B = U A V$ where $U,V$ are all unitary matrix, then $B$ have the same singular values of $A$.


title: Order items by closest to the previous

text: I have a list of 2D points (a table, imagine the data of a parametric plot shuffled) I would like to join the points with a line that starts from one of them and always goes to the closest one. I tried therefore to sort the points doing the following:   * take out the first element,   * search the closest in the remaining list   * bring it to the front   * recurse so that I can then use ListLinePlot As a first step I tried to do it in 1D (yes, in this case a simple sorting is sufficient, but not in the 2D case) However,I have a problem, because I do not know how to specify that a variable IS a list. Concretely               BringToFront =       Function[{list, pos}, Prepend[list[[pos]], Drop[list, {pos}]]]          BringClosestToFront =       Fuction[{list, val},        BringToFront[list, Nearest[list ->Automatic, val]]]          Follow[{}] = {};     Follow[list] =       Prepend[list[[1]],        Follow[BringClosestToFront[Drop[list, 1], list[[1]]]]]      And the BringClosestToFront is not accepted, with a               Part::partd: Part specification list[[1]] is longer than depth of object. >>      I am also worried of the speed of this recursive solution. Do you thing there may be a way to specify it in a more procedural way (i.e. implement insertion- sort)?


title: Adding a coordinate label to individual squares in ArrayPlot[...]

text: Can I write text, or add a specific text label to individual squares of an ArrayPlot[...] graphic? Specifically, I would like to assign an two- dimensional integer coordinate label to each square.


title: Inconsistent results of second derivative of inverse fourier transform

text: I am trying to get the Green's function of a toy diffusion equation $$\frac{\partial^2 u(x,t)}{\partial x^2} = \frac{1}{\alpha^2}\frac{\partial u(x,t)}{\partial t}$$ with _Mathematica_ 9. Then solve it by inverse Fourier transform:               u[x_, t_] := InverseFourierTransform[U[k, t], k, x]     D[u[x, t], {x, 2}]       D[D[u[x, t], x], x]           (* 0 *)     (* InverseFourierTransform[-k^2 U[k, t], k, x] *)       But can someone tell me why `Out[4]` and `Out[5]` are different? Thanks for your kindness.


title: Is there a way to print out SQL queries made using DatabaseLink?

text: I have a Mathematica batch script which makes some MySQL queries using DatabaseLink to store parameters of the run in a database. Recently, I had a run where these queries failed, and there was no output to indicate why. In the past, when I was using the SQLite interface, I had much success debugging (or at least recovering from errors) by printing out every SQL query made to the log file, but with functions like `SQLUpdate` and `SQLInsert` I don't get access to the raw queries. Is there a way I can get DatabaseLink to print them out for me, or at least get access to the raw query so I can print it myself?


title: Interpreting text entry and splitting it in a Manipulate text field?

text: I have the following program that plots the number of trigram appearances across a corpus of textual information between 1964 and 1989 (apologies for the messy code):               Manipulate[      viewerCount1 = {};      SetDirectory["/users/ME/desktop/DB/Put/"];      filenames = FileNames["*trigrams-put.txt"];      Do[       input = Get[file];       Clear[trigramHash];       (trigramHash[Sequence @@ #1] = #2) & @@@ input;       count = trigramHash[word1, word2, word3]; trigramHash[___] = 0;        AppendTo[viewerCount1, count];       , {file, filenames}];      DateListPlot[viewerCount1, {1964}, Joined -> True,        PlotLabel -> "Number of Trigram Appearances"], {{word1, "i",         "Word1:"}}, {{word2, "love", "Word2:"}}, {{word3, "you",         "Word3:"}}]      Right now, it looks like so: ![enter image description here](http://i.stack.imgur.com/KAHl4.png) What this is doing is initially seeing how frequent the phrase "i love you" is across files like this:               {{{"i", "don", "t"}, 102}, {{"i", "m", "gonna"}, 67},       {{"wa", "wa", "wa"}, 66}, {{"i", "can", "t"}, 66}, {{"i", "ll", "be"}, 66},       {{"i", "love", "you"}, 62}, {{"you", "don", "t"}, 55},       {{"la", "la", "la"}, 50}, {{"don", "t", "you"}, 49},       {{"don", "t", "know"}, 48}, {{"ain", "t", "that"}, 47},       The problem is that in this version you have to type word1 as `"i"`, word2 as `"love"`, and word3 as `"you"`. Would there be a way for _Mathematica_ to detect `"i love you"` in the `Manipulate` box, and then return responses as if it was `"i" "love" "you"`? So it could just be a phrase box, and it would split them in to three parts. (I have separate programs right now for unigrams, bigrams, trigrams, and quadgrams)


title: Show multiple plots with single variable

text: Using the same example code as in this question, is it possible to show all 10 plots (ie, each step of the manipulation) simultaneously? If a manipulate function is a series of listplots based on a single variable, is it possible to show all list plots simultaneously (ie - to overlay all listplots as one static plot). The only way I can think of doing this is copying & pasting the code n number of times, changing the variable for each one, naming each listplot & using               Show [a,b,c,d...]      but this seems fairly labour intensive!


title: How do I add new menuitems to menus?

text: What are some complete examples of what one would include in a FrontEnd `init.m` that would make use of `FrontEnd`AddMenuCommands` to add commands to the _Mathematica_ system menus (without having to directly edit `MenuSetup.tr`? For example, to do the following:   1. Add an item to the Help menu that brings up the `DocumentationCenter` window for Installed AddOns.   2. Add an item to the `Format > Background Color` sub-menu that would add a new color? Yes, I've already consulted MathGroup threads going back to 2009, and earlier, on modifying the startup menu by editing `MenuSetup.tr` and about evaluating, during a session, an expression to do a `FrontEndExecute`. But those messages don't seem to give a complete example of what I'm asking here.


title: Eigenvalue problem and plotting its eigenfunctions

text: How many different ways can one solve an eigenvalue problem and plot its corresponding eigenfunctions in Mathematica? For example for Harmonic Oscillator? Which one is the most accurate one? Thanks in advance.


title: Speed up manipulate by exporting each step as an image

text: Consider a manipulate function such as:               Manipulate[     per = 12.34;     pdata = Table[Sin[2 \[Pi] x/per], {x, n}] + RandomReal[.1, {n}];     ListPlot[pdata], {n, 100, 200, 10}]      which takes some time to re-evaluate each step of its manipulation. I would like to export each step of the manipulation as an image (rasterized or otherwise) & then create a manipulation that simply scrolls though the images, allowing it to run smoothly and quickly. Is there a way to automate something like this? _(NB The code I am working with takes far longer to re-evaluate each step that the example code above, but it works with much the same idea.)_


title: CycleIndex in v8

text: If I type               ?CycleIndex      I get > Information::notfound: Symbol CycleIndex not found. >> If I then type               Needs["Combinatorica`"]      I get > General::compat: Combinatorica Graph and Permutations functionality has been > superseded by preloaded functionaliy. The package now being loaded may > conflict with this. Please see the Compatibility Guide for details. Is there any good way to get the functionality I need without causing a conflict? The warning is somewhat strong and suggests nonspecific breakdowns further down the line...


title: Can I put tooltips in a Graph?

text: This doesn't work: ![Mathematica graphics](http://i.stack.imgur.com/8Usik.png) Is there a way to do this? My real goal is to identify the second links in the graph below, which shows the results of a webcrawl (using this code). I'm open to another approach. ![Mathematica graphics](http://i.stack.imgur.com/a7pwM.png)


title: Solving the Sine Gordon PDE in mathematica

text: how can i solve this equation in mathematica? this is sine-gordon eq. but the boundary condition can not recognized by mathematica . thank you for you attention.               NDSolve[{∂_(x,x) F[t,x]==(1-ζ)(Sin[F[t,x]]+β∂_t F[t,x]+∂_(t,t) F[t,x]),...     (∂_x F[t,x]==∂_t  F[t,x]/.x→0),(∂_x F[t,x]==∂_t F[t,x]/.x→1)},F,{t,0,10},{x,0,1}]      ## Edit:               \[Beta] = 1;     \[Zeta] = 1;     NDSolve[      {       D[f[t, x], x,          x] == (1 - \[Zeta]) Sin[[t, x]] + \[Beta] D[f[t, x], t] +          D[f[t, x], t, t],       D[f[t, 0], x] == D[f[t, 0], t],       D[f[t, 1], x] == D[f[t, 1], t]            },      f,      {t, 0, 10},      {x, 0, 1}      ]


title: How to get all possible orderings (equal ranks allowed) for given set of $N$ objects?

text: Hope there is a solution besides the tedious generation of nested loops. (Trying to avoid reinventing the wheel.) Here is an example with $N = 3$ objects. There are $13$ needed orderings (first `{}` means first place, second `{}` means second place, ...):               1. {a}, {b}, {c}     2. {a}, {c}, {b}     3. {a}, {b, c}     4. {b}, {a}, {c}     5. {b}, {c}, {a}     6. {b}, {a, c}     7. {c}, {a}, {b}     8. {c}, {b}, {a}     9. {c}, {a, b}     10. {a, b}, {c}     11. {a, c}, {b}     12. {b, c}, {a}     13. {a, b, c}      How can I get all such orderings for a given $N$? **UPD:** I also wonder how to get same orderings in binary relations notation, i.e., considering orderings as sets of ordered pairs (also neglecting here such pairs as $(a,a)$, $(b,b)$, ... since they don't make further difference). I found out that this notation is much easier way to further operating with rankings in _Mathematica_. Here are the above $13$ orderings in new notation:               1. {(a,b), (a,c), (b,c)}     2. {(a,c), (a,b), (c,b)}     3. {(a,b), (a,c), (b,c) (c,b)}     4. {(b,a), (b,c), (a,c)}     5. {(b,c), (b,a), (c,a)}     6. {(b,a), (b,c), (a,c), (c,a)}     7. {(c,a), (c,b), (a,b)}     8. {(c,b), (c,a), (b,a)}     9. {(c,a), (c,b), (a,b), (b,a)}     10. {(a,b), (b,a), (a,c), (b,c)}     11. {(a,c), (c,a), (a,b), (c,b)}     12. {(b,c), (c,b), (b,a), (c,a)}     13. {(a,b), (b,a), (a,c), (c,a), (b,c), (c,b)}


title: How do I find a weighted bipartite graph's minimum edge cover using Mathematica 8?

text: In graph theory, we use the Hungarian Algorithm to compute a weighted bipartite graph's minimum edge cover (a set of edges that is incident to every vertices, the one with the minimum total weight.) I find that in new version 8 of Mathematica, there is a whole new package of functions for Graph Theory, (begin with `Graph[]`.) But I've not found any function that do this job. I do find a function called `FindEdgeCover[]` that can only find a edge cover, not the minimum one.


title: About the number format in ticks

text: I want to `LogPlot` a function, but I have the trouble in the number format in the ticks. For example,               LogPlot[Abs[BesselJ[1, x] Sin[x]^2], {x, -10, 10},        Frame -> True, FrameTicks -> {{Automatic, None}, {None, None}}]      The output is ![Plot output](http://i.stack.imgur.com/NRMnW.jpg) If I use the command               LogPlot[Abs[BesselJ[1, x] Sin[x]^2], {x, -10, 10}, Frame -> True,         FrameTicks -> {         {{#, HoldForm[#]} & /@ {10^0, 10^-1, 10^-2, 10^-3, 10^-4, 10^-5}, None},         {None, None}        }     ]      I can get ![Plot output](http://i.stack.imgur.com/zoMBJ.jpg) Actually, I prefer the all the ticks in the form of `10^n`, and none of the commands shown above works. Is there any simple and clever way to cope with it? I'll be grateful for your reply.


title: how to deal with so many digits in plot ticks

text: the data is as follows               data = {{{25, 0.0000234834`}, {45, 0.0000127008`}, {65,      0.0000104495`}, {85, 9.68187`*^-6}, {105, 9.3519`*^-6}}, {{25,      0.0000210205`}, {45, 0.0000159071`}, {65, 0.0000148415`}, {85,      0.0000144786`}, {105, 0.0000143227`}}, {{25, 1.74304`*^-6}, {45,      1.74268`*^-6}, {65, 1.74261`*^-6}, {85, 1.74259`*^-6}, {105,      1.74258`*^-6}}, {{25, 4.26787`*^-6}, {45, 3.95165`*^-6}, {65,      3.88582`*^-6}, {85, 3.86343`*^-6}, {105, 3.85382`*^-6}}, {{25,      3.29821`*^-6}, {45, 3.1484999999999996`*^-6}, {65,      3.1174400000000003`*^-6}, {85, 3.1069`*^-6}, {105,      3.10239`*^-6}}, {{25, 2.4761199999999996`*^-6}, {45,      2.4761199999999996`*^-6}, {65, 2.4761199999999996`*^-6}, {85,      2.4761199999999996`*^-6}, {105, 2.4761199999999996`*^-6}}}      and               ListLogPlot[data]      gives ![img](http://i.stack.imgur.com/PE3Sp.png) There are some useless digits like "00000" in the tick. How to prevent this situation automatically? **Edit** I found an interesting thing, If you `Shift`+`Enter` the Plot again. Then the 00000 are gone and become scientific form. ![img2](http://i.stack.imgur.com/Zjn7T.png)


title: How can I manipulate the number of decimal places in the frame ticks?

text: Is there any simple way to increase or decrease the decimal places in the frame ticks. I want to make the y axis ticks of the first two and the second two graphs look similar. ![enter image description here](http://i.stack.imgur.com/YwVD5.png)


title: Adding a legend to a MatrixPlot

text: I have produced this MatrixPlot: ![](http://i.stack.imgur.com/OsIlG.jpg) Rows refer to countries and columns to ranks. Row 1 refers to Norway with many 1 ranks, row 15 to Greece with many 15 ranks. Other countries are inbetween. I would like to add a "Legend" to this plot, i.e. the string "Norway" should align (on the right side) with the first row etc. I have no idea how to accomplish this and any help would be appreciated.


title: Create colour with given lightness value

text: **How can I create a colour of my chosen hue with a given fixed lightness level?** For example, how can I create a reddish colour, `col`, so that `ColorConvert[col, "GrayScale"]` will return precisely `GrayLevel[0.6]`? Does Mathematica have something built-in to assist in this, or do I need to read up on how colours are converted between various representations? Note that the `b` value in `Hue[h, s, b]` does not correspond to the `GrayLevel` value. I need to have precise control over what certain colours I use will look like when converted to greyscale.


title: Lazy lists of Tuples and Subsets

text: I'm trying to build a lazy list that evaluates the n'th m-tuple or subset of a given list using Mathematicas ordering without calculating all the Tuples. The purpose is to allow for example the traversal of very large spaces of tuples without fist having to calculate the complete space of tuples. So far I have defined a function that calcluates which elements goes where for the n'th tuple:               tupleIndexes[l_, t_, n_] := Table[Mod[Quotient[n - 1, l^m] + 1, l, 1], {m, t - 1, 0, -1}]       And have used this to define a lazy list by defining a `SubValue` for when Part is applied.               lazyTuple /:Part[lazyTuple[list_, t_], n_Integer] /; 0 < n <= Length[lazyTuple[list, t]]:=        list[[tupleIndexes[Length[list], t, n]]]       The result is that `lazyTuple[{1,2,3,4},2]` remains unevaluted but `lazyTuple[{1,2,3,4},2][[2]]` returns `{1,2}` as expected. For testing I've defined a function to iterate through the list and return them all:               lazyTuple /: Length[lazyTuple[list_, t_]] := Length[list]^t     lazyTuple /: lazyTakeAll[a_lazyTuple] /; (NumericQ@Length@a) := Table[a[[i]], {i, Length@a}]      And it seems to check out:                lazyTakeAll[lazyTuple[Range@6, 3]] == Tuples[Range@6, 3]      > True Now my question is firstly if I'm making any subtle mistakes means this isn't returning the correct order with respect to `Tuples`. But more importantly, how would one go about defining a similar function for `lazySubsets[]`


title: How to clear variables in a manipulate without enabling dynamic content?

text: I have a series of variables that will plot the number of straight segments along a curve, thanks to the help from here on one of my previous questions. I can create a working Manipulate command from the code in Mathematica by varying nSeg and then visually show the number of segments increasing as the slider is raised, similar to the picture below. The number of segments (nSeg) can affect the number of x co-ordinates that I have, so if nSeg = 4 then I will have nSeg+1 x co-ordinates in total. ![Cable Arches](http://farm9.staticflickr.com/8443/7759685258_59e7b503b3.jpg) The difficulty I have is that because I am using subscripted variables for my x co-ordinates, if I try to reset them using the code below or through using Remove[] I invoke dynamic content in my Mathematica file and I'm unable to export as a CDF file that I can embed into a website, although I can get it to execute as a CDF if the user specifically selects to allow dynamic content.               clearSubscript[x_Symbol] := (First /@ Select[DownValues[Subscript],       MatchQ[First[#],         Verbatim[HoldPattern][Subscript[x, _]]] &]) /.      HoldPattern :> Unset;     clearSubscript[x];      I've been hunting around for ways to remove subscripted variables for a few days now, and whilst I've found a few different ways of doing it, I've not managed to work out how this can be done in a way that doesn't invoke Dynamic Content in Mathematica, and without doing this I'm struggling to create a CDF that can be embedded into a webpage. Any suggestions or help, gratefully received... EDIT: Removing all subscripts I still get a similar problem when trying to clear variables, edited to include simplified sample code below which I can't make into CDF file for embedding into a web page due to the Dynamic Content which I think is being invoked by the Clear command.                Manipulate[      nSeg;      f[x_] = (50 x)/41 - x^2/3362;      upVal = 4100;      chordL = Table[Sqrt[(x[i + 1] - x[i])^2 + (f[x[i + 1]] - f[x[i]])^2], {i, 1, nSeg}];      combEqs = # == d & /@ chordL;      Clear[vars, x];      vars = Append[{x[#], #, x[1] + 10^-6, upVal - 10^-6} & /@ Range[2, nSeg], {d, 1}];      x[1] = 0;      x[nSeg + 1] = upVal;      sol = {FindRoot[combEqs, vars]},      {nSeg, 3, 8, 1}      ]      Question updated to reflect the intention is to enable the Manipulate to recreate the graphical images above of the cable-chain arches, whilst I have no problems sharing the full code, I think it would be unfair to throw it all in here, but essentially there is a Plot function that plots the curves once the co-ordinates are calculated via the FindRoot, and the various solutions from the Findroot are also used to plot the links as straight lines. Combined with the proposed Dynamic and TrackedSymbols functions added, the code is something along the lines of:               Dynamic[     Manipulate[nSeg;     f[x_] = (50 x)/41 - x^2/3362;     upVal = 4100;     chordL = Table[Sqrt[(x[i + 1] - x[i])^2 + (f[x[i + 1]] - f[x[i]])^2], {i, 1, nSeg}];     combEqs = # == d & /@ chordL;     vars = Append[{x[#], #, x[1] + 10^-6, upVal - 10^-6} & /@ Range[2, nSeg], {d, 1}];     combEqs = combEqs /. {x[1] -> 0, x[nSeg + 1] -> upVal};     vars = vars /. {x[1] -> 0, x[nSeg + 1] -> upVal};     sol = {FindRoot[combEqs, vars]};     Show[Plot[f[x], {x, 0, 4100}],     Graphics[{Black, Thick,Line[Table[{{x[i], f[x[i]]}, {x[i + 1], f[x[i + 1]]}}, {i, 1, nSeg}] /. sol[[1]]]}],     Graphics[{Black, Dashed,Line[Table[{{x[i], f[x[i]]}, {x[i + 2], f[x[i + 2]]}}, {i, 1, nSeg - 1}] /. sol[[1]]]}],     Graphics[{Red, PointSize[Large],Point[Table[{x[i], f[x[i]]}, {i, 1, nSeg + 1}] /. sol[[1]]]}],     AspectRatio -> Automatic,     Axes -> False],     {nSeg, 3, 8, 1},     TrackedSymbols :> {nSeg}]]


title: Mathematica 10 'Formatting Notebook Contents'

text: Mathematica 10 freezes while 'Formatting notebook contents'. This happens already during the startup of Mathematica and it takes a long time for Mathematica to recover. It can also happen when I am editing a Notebook or browsing the documentation. Especially the documentation is very slow. Is this somehow related to the Mathematica FrontEnd? Is anybody else struggling with problems like this? EDIT: I'm using 64 bit Windows 7


title: Request: Create a planar graph using Mathematica (at least v9)

text: Can someone please copy/paste the planar `Graph` given by _Mathematica_ (at least _v9_ ) for this graph:               Graph[{{1, 7}, {1, 3}, {1, 5}, {1, 6}, {2, 6}, {2, 7}, {2, 4}, {4, 5}, {4, 8},            {8, 5}, {8, 3}, {3, 6}, {3, 7}, {6, 7}}, GraphLayout -> "PlanarEmbedding"]      I would only need the output. I would do it myself but my program keeps crashing. If someone could do this easy copy / paste & a few clicks, I'd be highly appreciative. I'm redownloading _Mathematica_ right now, but it's urgent and the file is 2GB.


title: ContourPlot is slow and unwieldy and generates a large-data graphic

text: I'm constructing a single contour showing the points in a plane that satisfy a function. The general form is               ContourPlot[f[x, y] == 0, {x, 0, .5}, {y, 0.2, .5}]      The function `f` is an explicit but complicated formula that was generated from operations involving analytic integration and differentiation applied to a large algebraic function. It evaluates quite rapidly though, given values of its arguments. My problem is that the plot takes an unduly long time to generate, perhaps 5 to 10 minutes. Also, and this may be related, the graphic object that it produces has a very large amount of data associated with it -- if I copy it as text and paste it into Word, it exceeds 10,000 pages! The text looks like it is describing how the function is evaluated (it includes function calls that are part of the definition of f), rather than a simple list of data points and formatting information. If I try to Show the output, to combine it with other graphics, it takes a long time to generate, as if it is recomputing the graph again. Also, I get a "Reformatting notebook" message any time I touch the object (e.g., to select it), and this takes maybe 15 or 20 seconds to go away. The plot itself isn't particularly complicated: ![contour plot](http://i.imgur.com/Up78AsX.png) I can make a ContourPlot of a simple function (e.g., `x^2+y^2==1`) and it plots quickly, and cut/paste it as text into Word occupies less than two pages.


title: Why does Mathematica not simplify this expression?

text: Consider this simple example:               mytrans[expr_] :=       expr /. Ω1^2 + Δ^2 :> Ω^2          f =        FullSimplify[Sqrt[-Δ^2 - Ω1^2],         TransformationFunctions -> {Automatic, mytrans}, Assumptions -> #] &;          f /@ {{Δ > 0, Ω1 > 0, Ω > 0},           {Δ > 0, Ω1 < 0, Ω > 0},           {Δ < 0, Ω1 > 0, Ω > 0},           {Δ < 0, Ω1 < 0, Ω > 0},          {Δ ∈ Reals, Ω1 ∈ Reals, Ω > 0}}               (* {I Ω, I Ω, I Ω, I Ω, Sqrt[-Δ^2 - Ω1^2]} *)      Isn't the last assumption equivalent to the first four? Why doesn't it work? Or why does it work in the first four cases?


title: Manipulating lists with uneven amounts of entries

text: So I have a list like so               list={{a},{b,c},{d,e,f},{g,h}}      and the basic logic I want is to be able to manipulate each of the nested lists individually. So If I wanted to take the average of each list I would do something like               avglist=Table[(1/3) Sum[list[[n,j]],{j,3}],{n,4}]      But the problem with this is when the program would call `list[[1,2]]` So the gist is I am trying to write a program that could average/in general manipulate each of the nested lists of uneven lengths without having to know how many entries are in the list with the most entries. I can't just add zeroes into the nested lists with fewer entries because if I want to manipulate them first then average it would affect the average. Thanks


title: Find components which have intersections with designated lines

text: I have an image with several disconnected components, and I want to find all the components which have intersections with some designated lines which I generated previously. The image: ![enter image description here](http://i.stack.imgur.com/Pq6JZ.png) And the line is `{{{37.7754, 1001.}, {38.862, 0.}}, {{0., 442.679}, {832., 437.26}}}` The combined image looks like this: ![enter image description here](http://i.stack.imgur.com/8wUem.png)


title: Combining two plots which are in two regions

text: I want to combine two plots which are in two regions. For an example, I want to plot following two figures in the same plot.               a = Plot[Cos[x], {x, 0, 60}]     b = Plot[Sin[x], {x, 60, 90}]      Could anyone please tell me how to do this without using Piecewise function?


title: Generating a list of all factorizations

text: What is the best way to generate a list of all factorizations of some number $n$? I'm quite new to Mathematica so this might be obvious. I have been trying some basic stuff with `For`-loops and `FactorInteger` and `Divisors` but I'm not really getting anywhere. There must be some elegant way of doing this. An example of the result I'm after, for $n=60$: $$\{\{2,2,3,5\}, \{4,3,5\}, \{2,6,5\}, \{2,3,10\}, \{2,2,15\}, \{12,5\}, \{2,30\}, \{3,20\}, \{4,15\}, \{6,10\}, \{60\}\}.$$


title: Executing a .m file from the Linux command line

text: I have some code in a file named `Demo-3.m`, It can be evaluated in Mathematica 9. The final expression in the file is               Export[NotebookDirectory[] <> "fintempimg.jpg", fintempimg];      How can I execute `Demo-3.m` in Linux using the command-line? Please give me a solution with an example.


title: Learning Resources for Data Science in the Wolfram Language

text: I'm delivering an upcoming course on Data Science with the programming/analysis done predominantly in the Wolfram Language. I created the following table to leverage students' familiarity with Lists by way of introducing Associations by way of introducing Datasets. Juxtaposing the various invocations one can't help but be struck with the foresight or "naturalness" of the original language design and subsequent integrations - (IMO an extraterrestrial would be hard-pressed to predict the chronology of sequentially added features, and in particular, to note that all three didn't emerge simultaneously). My sense is that programming expertise in the Wolfram Language starts with an awareness of its existing (or "likely") functionality followed by inculcating and memorising its basic functional forms. While the documentation is essential for understanding all the details and an overall coherency, for quick reference/comparison/contrast, I think _cheatsheets_ could be more commonly deployed (with no doubt improved visual design - the code follows which could potentially be improved/combined with other users' cheatsheets into a larger, more powerful "Demonstration"?) At any rate, while an introduction involves becoming familiar with the basic syntax and manipulating structured datasets, the next stage involves applying these to some real-life examples. While there are good texts/datasets available (e.g. Luís Torgo's Data Mining with R: Learning with Case Studies) I'm wondering if anyone has found useful, available datasets from a variety of contexts (health, business, economics, ecology, physics, learning analytics) that might be particularly suitable for showcasing some of the benefits of data science in the Wolfram Language (this might be due to their size, unusual analysis, parallelizability, integration with curated data etc). ![](http://i.stack.imgur.com/YraKE.gif)               SetAttributes[{IOCells, DefCells, InsertIOCells, InsertDefCells},        HoldAll];               DefCells[Set[lhs_, rhs_]] := Row[{         ExpressionCell[Defer@lhs, "Input", ShowStringCharacters -> True,           FontSize -> 16],         ExpressionCell[" = ", ShowStringCharacters -> False,           FontSize -> 16],         ExpressionCell[lhs = rhs, "Input", ShowStringCharacters -> True,           FontSize -> 16]}];          (* Need to split in this way since a Defer wrapper seems to produce \     unexpected formatting - compare:     ExpressionCell[Defer[lhs=<|"a"\[Rule]8,"b"\[Rule]9,"c"\[Rule]10|>],\     "Input"]      ExpressionCell[Defer[lhs=\[LeftAngleBracket]"a"\[Rule]8,"b"\[Rule]9,\     "c"\[Rule]10\[RightAngleBracket]],"Input"]      *)          DefCells[R : Set[dataset, Dataset[{_}]]] := (R; Row[{          ExpressionCell[Defer@dataset, "Input",            ShowStringCharacters -> True, FontSize -> 16],          ExpressionCell[" = ", ShowStringCharacters -> False,            FontSize -> 16],          ExpressionCell["Dataset"[HoldForm[{assoc}]], "Input",            ShowStringCharacters -> False, FontSize -> 16]}]);          IOCells[expr_] /; !          FreeQ[Hold@expr,           Histogram | ListPlot | ListLinePlot | BarChart3D | BarChart |            PieChart | SmoothHistogram] := Grid[{         {ExpressionCell[Defer@expr, "Input",            ShowStringCharacters -> True]},         {ExpressionCell[expr, "Output", Magnification -> 0.41]}         }, Frame -> True, Alignment -> Left,         Background -> {None, {1 -> GrayLevel[.9], 2 -> White}}];               IOCells[expr_] := Grid[{         {ExpressionCell[Defer@expr, "Input",            ShowStringCharacters -> True]},         {ExpressionCell[expr, "Output"]}         }, Frame -> True, Alignment -> Left,         Background -> {None, {1 -> GrayLevel[.9], 2 -> White}}];          (* For the same reason above need a specific definition when <|  |> \     notation is in input *)          IOCells[R : KeySelect[assoc_, assoc2_]] := With[        {t = ToExpression@ToBoxes[assoc2]}, Grid[{          {ExpressionCell[HoldForm@KeySelect[assoc, t], "Input",             ShowStringCharacters -> True]},          {ExpressionCell[ReleaseHold@R, "Output"]}          }, Frame -> True, Alignment -> Left,          Background -> {None, {1 -> GrayLevel[.9], 2 -> White}}]];          IOCells[R : Dataset[expr_][op_]] := Grid[{         {ExpressionCell["Dataset"[HoldForm@assoc][op], "Input",            ShowStringCharacters -> False]},         {ExpressionCell[ReleaseHold@R, "Output"]}         }, Frame -> True, Alignment -> Left,         Background -> {None, {1 -> GrayLevel[.9], 2 -> White}}];          (* Since Dataset outputs as grid in the input - means copying \     expression from the grid and evaluating won't work *)               InsertDefCells[defs_List] :=        ReleaseHold@With[{t = Hold@defs}, Map[DefCells, t, {2}]];     InsertIOCells[exprLs_] :=        Sequence @@         Map[Row,          ReleaseHold@With[{t = Hold@exprLs}, Map[IOCells, t, {4}]], {2}];          ColumnHeadStyle[cheads_List] :=        ExpressionCell[#, Style[#, {Bold, 18}],           ShowStringCharacters -> False] & /@ cheads;               Block[{$PlotTheme = "Minimal"}, Grid[{        {"List", "Association", "Dataset"} // ColumnHeadStyle,        {ls = {7, 8, 9}, assoc = <| "a" -> 7, b -> 8, "c" -> 9 |>,           dataset = Dataset[{assoc}]} // InsertDefCells,        {          {{ls[[All]]}, {Values[assoc], Keys[assoc], Normal[assoc],             Lookup[assoc, "b", "No-b"]}, {dataset[1, Values],             dataset[1, Keys]}},          {{(Query@1)[ls], ls[[1]], ls[[2]]}, {assoc[["a"]], assoc["a"],             assoc[[Key@b]], assoc@Key@b,             Query["a"][assoc]}, {Query[1, Key["a"]][dataset],             dataset[1, Key["a"]]}},          {{ls[[3]], ls[[-1]]}, {assoc[[3]], assoc[[-1]], assoc[a],             assoc["b"]}, {dataset[1, 3], dataset[1, -1],             dataset[1, Key["d"]]}},          {{ls[[1 ;; 3]], ls[[1 ;; 3 ;; 2]], Take[ls, {1, 3}],             Query[Take[{1, 3}]][ls]}, {assoc[[1 ;; 3]],             assoc[[1 ;; 3 ;; 2]], Take[assoc, {1, 3}],             Take[assoc, {1, 3, 2}],             Query[1 ;; 3][assoc]}, {dataset[1, 1 ;; 3],             Query[1, 1 ;; 3][dataset]}},          {{Query[{1, 3}][ls], ls[[{1, 3}]]}, {Query[{1, 3}][assoc],             assoc[[{1, 3}]], assoc[[{"a", "c"}]],             KeyTake[assoc, {"a", "c"}]}, {dataset[1, {1, 3}],             dataset[1, {"a", "c"}]}},          {{Cases[ls, _?OddQ], Cases[_?OddQ][ls]}, {Cases[assoc, _?OddQ],             Cases[_?OddQ][assoc]}, {dataset[1, Cases[_?OddQ]]}},          {{Query[Select[OddQ]][assoc], Select[ls, OddQ],             SelectFirst[ls, OddQ]}, {Select[assoc, OddQ],             Select[OddQ][assoc],             SelectFirst[assoc, OddQ]}, {dataset[1, Select[OddQ]],             dataset[1, SelectFirst[OddQ]]}},          {{Position[ls, _?OddQ],             FirstPosition[ls, _?OddQ]}, {Position[assoc, _?OddQ],             Position[_?OddQ][assoc],             FirstPosition[assoc, _?OddQ]}, {dataset[1, Position[_?OddQ]],             dataset[1, FirstPosition[_?OddQ]]}},          {{PositionIndex[ls],             Query[PositionIndex][ls]}, {PositionIndex[assoc],             Query[PositionIndex][assoc]}, {dataset[1, PositionIndex]}},          {{Select[Keys@assoc, MemberQ[{"a", "c"}, #] &]}, {KeySelect[             assoc, MemberQ[{"a", "c"}, #] &],             KeySelect[assoc, <| "a" -> True, "c" -> True |>]}, {dataset[1,              KeySelect[(# == "a" \[Or] # == "c") &]]}},          {{f[ls[[3]]], Query[3, f][ls]}, {f[assoc[["c"]]],             Query["c", f][assoc]}, {dataset[1, "c", f],             dataset[1, 3, f]}},          {{f /@ ls, Map[f][ls], Query[Map[f]][ls]}, {f /@ assoc,             Map[f][assoc]}, {dataset[1, Map@f], dataset[1, All, f]}},          {{MapIndexed[f, ls], MapIndexed[f][ls]}, {MapIndexed[f, assoc],             MapIndexed[f][assoc]}, {dataset[1, MapIndexed[f]]}},          {{MapAt[f, ls, 2], MapAt[f, 2][ls]}, {MapAt[f, assoc, 2],             MapAt[f, 2][assoc],             MapAt[f, Key[b]][assoc]}, {dataset[1, MapAt[f, Key@b]]}},          {{MapAt[f, Normal@assoc, {All, 1}]}, {KeyMap[f, assoc],             KeyMap[f][assoc]}, {dataset[1, KeyMap[f]]}},          {{Reverse /@ Normal@assoc,             Association[f /@ Normal@assoc]}, {AssociationMap[Reverse,              assoc], AssociationMap[f, assoc]}, {dataset[1,              AssociationMap@Reverse], dataset[1, AssociationMap[f]]}},          {{Sort@ls, Sort[ls, Greater],             Query[Sort[#1, Greater] &][ls]}, {Sort@assoc,             Sort[assoc, Greater],             Query[Sort[#1, Greater] &][assoc]}, {dataset[1, Sort],             dataset[1, Sort[#, Greater] &]}},          {{Total[ls]}, {Total[assoc], Query[Total][assoc],             Query[Values /* Total][assoc]}, {dataset[1, Total],             dataset[1, All /* Total], dataset[1, Total@*Values]}},          {{Through[{Min, Max, Total, Variance, Median}@              ls]}, {Query[{Min, Max, Total, Variance, Median}][             assoc]}, {dataset[1, {Min, Max, Total, Variance, Median}]}},          {{Through[{Histogram, BarChart, SmoothHistogram, PieChart,                ListLinePlot[#, Filling -> Axis] &}@ls]},           {Query[{Histogram, BarChart, SmoothHistogram, PieChart,                ListLinePlot[#1, Filling -> Axis] &}][             assoc]}, {dataset[              1, {Histogram, BarChart, SmoothHistogram, PieChart,                ListLinePlot[#1, Filling -> Axis] &}] // Normal}},          {{Thread[Keys[assoc] -> ls]}, {AssociationThread[             Keys[assoc] -> ls],             AssociationThread[Keys[assoc],              ls]}, {dataset[              1, {AssociationThread[Keys@#,                  Values@#] &, (Keys@# -> Values@#) & /*                 AssociationThread}] // Normal}},          {{Thread[Keys[assoc] -> f /@ Keys[assoc]]}, {AssociationMap[f,              Keys[assoc]],             Query[AssociationMap[f]@*Keys][assoc]}, {dataset[1,              Keys /* AssociationMap[f]]}},          {{(f[#1, #2, #3] &)[Sequence @@ ls]}, {(f[#a, #1[Key[b]], #c] &)[             assoc], (f[#1["a"], #1[Key[b]], #1["c"]] &)[assoc]}, {dataset[             1, All /* (f[#a, #1[Key[b]], #c] &)],             dataset[1, (Apply@f)@*Catenate]}},          {{(f[##1] &)[Sequence @@ ls], (f[##2] &)[             Sequence @@ ls]}, {((f[##] &)[Sequence @@ Values@#] &)[             assoc]}, {dataset[1,              Values /* (Sequence @@ # &) /* (f[##] &)],             dataset[1, (f[##] &)@*(Sequence @@ # &)@*Values]}}          } // InsertIOCells        }, Frame -> True,        Dividers -> {Thick, {Thick, {None}, Thick}, {3 -> Thick, 8 -> Thick,           13 -> Thick, 19 -> Thick, 23 -> Thick, 25 -> Thick}},        Alignment -> {Center, Center},       Background -> {Automatic, {ColorData[17, 4],           LightBrown, {LightBlue, LightGreen}}},        ItemStyle -> {Automatic, {19}}, Spacings -> {1, {1, 1, 1, {0.5}}}]]


Zeta[-13] == Zeta[-1] == -1/12        Why do these two different zetas produce the same value?


title: Histogram3D using sums instead of counts

text: I'm trying to create a 3d histogram/ matrix plot pair. My data is in the form               {{TTR1,TBF1},{TTR2,TBF2},....}      What I would like is to modify the Histogram3D so instead of having the counts of each bin on the z axis I would have the sum of TTR in that bin. I would also like the modify the matrix plot in the same way. I've hacked an example in the help to get this far;               hist := Histogram3D[Log[10, dateFilter[[All, 2]]], {-4, 4, 0.25},      Function[{xbins, ybins, counts}, Sow[counts]],      AxesLabel -> {Style["TTR (log(hours))", 16],      Style["TBF (log(hours))", 16]}, ImageSize -> Large,      PlotLabel -> Style["Dryer 1 TBF and TTR Counts", 18],      ChartStyle -> RGBColor[27/255, 121/255, 169/255],      ViewPoint -> {Pi, Pi, 2}];     {g, {binCounts}} = Reap[hist];     mPlot := MatrixPlot[First@binCounts, ImageSize -> Large]     Row[{g, mPlot}]      In this case my data list is               dateFilter[[All, 2]]={{TTR1,TBF1},{TTR2,TBF2}....}      I would also like to fix this axis on the MatrixPlot so it has the same range labels as the histogram. Also is there a better way to do the log axes on the Histogram? I've just taken the Log of the data but it would be better if I could just modify the axes to show 1,10,100,.... ![enter image description here](http://i.stack.imgur.com/iKfOC.png) **Edit** I've re-plotted by data using kgulers code. The function I used was               Histogram3D[Log[10, dateFilter[[All, 2]]], {-4, 4, 0.25},      heightF[dateFilter[[All, 2]]][Total, First], styles,      AxesLabel -> {Style["TTR (log(hours))", 16],      Style["TBF (log(hours))", 16], Style["Sum TTR (hours)", 16]},      ViewPoint -> {Pi, Pi, 2}]       ![enter image description here](http://i.stack.imgur.com/oTIUD.png) It looks like my data has stratified into 3 groups of TTR (which may be what is really going on). I was kind of expecting the same plot with different z values but if that's what's going on then that's what's going on. Thanks kguler and belisarius. Give me a day to check that this is all ok and I'll tick this one off.


title: Plotting many tables in a single plot

text: I have several lists.               HeapSort = {6046.315617631054, 10120.421973039713, 20443.896966227818, 39888.26738991704, 409953.65081967216, 822796.7730263158, 1668210.1566666667, 3417061.523809524, 7231431.842857143, 1.58387906875*10^7, 3.3356646333333332*10^7, 6.99283795*10^7};     InsertSort = {1271.5641210832696, 2687.027971840069, 7428.082168377579, 26163.114593689497, 3480848.111111111, 1.7492152862068966*10^7, 7.876655514285715*10^7, 4.397160115*10^8, 2.19177605*10^9, 9.608922293*10^9, 4.5711371557*10^10,  2.88336011071*10^11};     MergeSort = {705.8025660136586, 757.6872519529326, 712.2989003537274, 712.1736108341547, 1059.3028590671972, 1497.1111723262381, 2410.7281094659293, 4422.600003538069, 10639.153797050876, 21691.320766994926, 45971.68456375839, 91827.67235996327};     QuickSort = {780.2510673824163, 899.0357995655863, 1229.733878841987, 2115.2551030336876, 46303.74590239837, 115050.7630004602, 271829.77228260867, 603560.328106152, 1342529.6916890081, 2965269.349112426, 6622509.02631579, 1.5045565676470589*10^7};     SelectionSort = {1626.7971290340422, 5189.992121652481, 17446.351430565246, 63880.23454266735, 6390999.493670886, 2.6850240684210528*10^7, 1.068697138*10^8, 4.399030115*10^8, 1.784892424*10^9, 7.214766123*10^9, 3.0060269881*10^10,  1.35096492432*10^11};     Num = {10, 25, 50, 100, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000};      They are tests I have performed with different sorting algorithms. I have the following code to put all of them in a single plot.               ListLinePlot[      {       Table[{Num[[i]], HeapSort[[i]]}, {i, 12}],       Table[{Num[[i]], InsertSort[[i]]}, {i, 12}],        Table[{Num[[i]], MergeSort[[i]]}, {i, 12}],       Table[{Num[[i]], QuickSort[[i]]}, {i, 12}],        Table[{Num[[i]], SelectionSort[[i]]}, {i, 12}]       },      PlotLegend -> {"Heap Sort", "Insertion Sort", "Merge Sort",         "Quick Sort", "Selection Sort"}, LegendPosition -> {1, -0.25},      PlotMarkers -> Automatic,      PlotLabel -> "Average Time of Heap Sort",       AxesLabel -> {"Test Number", "Nano Seconds"},      ImageSize -> Large      ]      For some reason, I can't get the plots to show up correctly. The x axis only goes up to around 80000. This is fixed when I remove all but one of the Table lists in the above code. If you guys could help me debug this code and figure out what's wrong.


title: How can I speed up this code with multiple sum？

text: There are 4 variables in this multiple sum, therefore it may take a long time. I have run this program for _12 hours_ , but no result untill now. I want to know how to speed up this code. Any help or suggestion will be highly appreciated! the code is bellow:               data = Table[Exp[-((i + j - 100.)/10)^2] Exp[-((i - j)/10)^2], {i, 100}, {j, 100}];     data = Chop[data, 0.00001];     data = data/Sqrt[Sum[(data[[i, j]])^2, {i, 1, 100}, {j, 1, 100}]];     ListDensityPlot[data, InterpolationOrder -> 0, Mesh -> All,       PlotRange -> All, ColorFunction -> (Blend[{Hue[2/3], Hue[0]}, #] &)]      ![Mathematica graphics](http://i.stack.imgur.com/dg7nv.png)               S1[i_, j_, k_, m_,         t_] := (data[[i, k]] data[[j, m]])^2 + (data[[j, k]] data[[i,             m]])^2 -         2 data[[i, k]] data[[j, m]] data[[j, k]] data[[i,            m]] Cos[(2 \[Pi]*(3*10^8)/(1584 - 5 + j*0.1 - 0.05) -              2 \[Pi]*(3*10^8)/(1584 - 5 + i*0.1 - 0.05)) t];     S2[t_] := 1/4*\!\(     \*UnderoverscriptBox[\(\[Sum]\), \(i = 1\), \(100\)]\(     \*UnderoverscriptBox[\(\[Sum]\), \(j = 1\), \(100\)]\(     \*UnderoverscriptBox[\(\[Sum]\), \(k = 1\), \(100\)]\(     \*UnderoverscriptBox[\(\[Sum]\), \(m = 1\), \(100\)]S1[i, j, k, m, t]\)\)\)\);     ListPlot[Table[S2[i], {i, -0.01, 0.01, 0.0001}], Joined -> True,       PlotRange -> All, Frame -> True]


title: Creating new functions using the names of existing ones

text: I have a list of functions                 {G[x_, y_], F[x_, y_], C[x_, y_]}       how I can create the list of new functions such as                 {dG[x_, y_], dF[x_, y_], dC[x_, y_]}


title: Wolfram Workbench 2.0 on Xubuntu 14.04 LTS trusty

text: I'm trying to install Wolfram Workbench on Xubuntu 14.04 but the apptication doesn't start. Knowing that WWb is a 32 bit application, I installed the i386 requrements:               ii  gcc-4.8-base:i386                         4.8.2-19ubuntu1                        i386         GCC, the GNU Compiler Collection (base package)     ii  gcc-4.9-base:i386                         4.9-20140406-0ubuntu1                  i386         GCC, the GNU Compiler Collection (base package)     ii  libc6:i386                                2.19-0ubuntu6                          i386         Embedded GNU C Library: Shared libraries     ii  libc6-i386                                2.19-0ubuntu6                          amd64        Embedded GNU C Library: 32-bit shared libraries for AMD64     ii  libgcc1:i386                              1:4.9-20140406-0ubuntu1                i386         GCC support library     ii  libgpm2:i386                              1.20.4-6.1                             i386         General Purpose Mouse - shared library     ii  libncurses5:i386                          5.9+20140118-1ubuntu1                  i386         shared libraries for terminal handling     ii  libstdc++6:i386                           4.8.2-19ubuntu1                        i386         GNU Standard C++ Library v3     ii  libtinfo5:i386                            5.9+20140118-1ubuntu1                  i386         shared low-level terminfo library for terminal handling      but when I run /usr/local/bin/WolframWorckbench the process start and stop after 1 second ! So checked with ldd:               root@lua:/opt/WolframWorkbench/2.0# ldd WolframWorkbench         linux-gate.so.1 =>  (0xf777d000)         libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf774a000)         libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf7745000)         libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7595000)         /lib/ld-linux.so.2 (0xf777e000)      If I check the execution with strace I can see a lot of errors on some system call:               root@lua:/usr/local/bin# strace -c /usr/local/bin/WolframWorkbench      [ Process PID=18919 runs in 32 bit mode. ]     % time     seconds  usecs/call     calls    errors syscall     ------ ----------- ----------- --------- --------- ----------------      26.56    0.000192          21         9           clone      14.11    0.000102           6        18           read      13.42    0.000097          11         9           wait4      11.48    0.000083           4        21           close       5.67    0.000041           5         9           pipe       4.84    0.000035           5         7           mmap       4.01    0.000029           3         9           rt_sigreturn       2.77    0.000020           5         4           mprotect       2.63    0.000019           6         3           open       2.35    0.000017           2         7           rt_sigaction       2.07    0.000015           5         3         3 access       1.94    0.000014           5         3           brk       1.80    0.000013           4         3           stat       1.11    0.000008           8         1           munmap       1.11    0.000008           4         2           chdir       0.83    0.000006           3         2           fstat       0.83    0.000006           3         2           fcntl       0.83    0.000006           3         2           geteuid       0.55    0.000004           4         1           faccessat       0.41    0.000003           3         1           getpid       0.41    0.000003           3         1           arch_prctl       0.28    0.000002           2         1           getppid       0.00    0.000000           0         2           execve     ------ ----------- ----------- --------- --------- ----------------     100.00    0.000723                   120         3 total     System call usage summary for 32 bit mode:     % time     seconds  usecs/call     calls    errors syscall     ------ ----------- ----------- --------- --------- ----------------      43.11    0.034557           3     10561           gettimeofday      15.03    0.012050           4      2803           read      12.63    0.010124           3      3004           _llseek       8.84    0.007088          12       583        19 futex       5.88    0.004711           4      1103       197 stat64       4.77    0.003821           6       693       513 open       1.46    0.001173           5       255        11 close       1.18    0.000944           6       154           mmap2       1.10    0.000879           4       222           fstat64       1.00    0.000798          13        60           getdents64       0.97    0.000774           4       173         1 lstat64       0.96    0.000767          24        32           getdents       0.57    0.000458           7        63           munmap       0.57    0.000454           6        74           brk       0.41    0.000325           7        50         3 openat       0.23    0.000186          19        10           clone       0.22    0.000177          20         9         3 unlink       0.20    0.000157           7        23           mprotect       0.17    0.000140           5        30        27 access       0.17    0.000137           4        34           fcntl64       0.14    0.000111           4        28           rt_sigaction       0.06    0.000050          25         2           write       0.04    0.000035           5         7           dup2       0.04    0.000034           4         9           rt_sigprocmask       0.04    0.000029          10         3           socket       0.03    0.000021           5         4           getcwd       0.02    0.000020          10         2         2 connect       0.02    0.000019           5         4           uname       0.02    0.000018          18         1           ftruncate       0.02    0.000018           4         5           getrlimit       0.02    0.000016          16         1           execve       0.01    0.000010          10         1           socketpair       0.01    0.000009           5         2           set_robust_list       0.01    0.000008           4         2           set_thread_area       0.01    0.000008           4         2           set_tid_address       0.01    0.000007           4         2           clock_gettime       0.01    0.000006           6         1           sched_yield       0.01    0.000005           5         1         1 mkdir       0.01    0.000005           5         1           getuid32       0.00    0.000004           4         1           setrlimit       0.00    0.000004           4         1           geteuid32       0.00    0.000004           4         1           gettid       0.00    0.000004           4         1           clock_getres       0.00    0.000003           3         1         1 getsockname     ------ ----------- ----------- --------- --------- ----------------     100.00    0.080168                 20019       778 total      Perhaps I'm missing something? Do I need to install others i386 library? Please can someone help me?


title: Why are graphics rendered as MathML when I set $PrePrint = MathMLForm?

text: For external usage, I set output in `MathMLForm` by using `$PrePrint=MathMLForm` Everything goes well but makes graphics rendered in `MathMLForm` as well. How could I make graphics rendered as image? > ![enter image description here](http://i.stack.imgur.com/WClu4.png) * * * New added: Thanks for @Kuba, But I am facing another problem when execute script like:               Table[Plot[f[x], {x, -2 Pi, 2 Pi}, Exclusions -> {1/f[x] == 0}],            {f, {Tan, Cot, Csc, Sec}}]      The final result is not a type of graphics, but it contains graphics. So it rendered in MathML finally. > ![enter image description here](http://i.stack.imgur.com/qOMsT.png)


title: Fitting data using a differential equation

text: I have data generated from two functions given below. How can I go about finding a fit of the form:               y'[x] == -(a + b/(c + d  y[x] + e F[x] ))      where a,b,c,d,e are to be determined?               F[x_] := If[x < 37.5, 2.80 + 0.0036 x, 117.86 - 6.314 x + 0.0865 x^2]          s = NDSolve[{y'[x] == -(0.0595 + 3716/(11780 + y[x])) y[x],         y[0] == 650000}, y, {x, 0, 60}]               data = Table[{x, Evaluate[y[x] /. s], F[x]}, {x, 0, 60, 1}]


title: FindRoot to find numerical solution of a given index

text: I want to find solutions of a system of multivariate nonlinear equations of a specific index (i.e., the no. of positive eigenvalues of the Jacobian evaluated at the solution). I know the FindRoot command can find numerical solutions. But it doesn't restrict the search to specific index of the solution.


title: Mapping a function of two arguments where the 2nd arg has a fixed value

text: I create three random images:               i1 = Image[RandomReal[1, {8, 12, 3}]];     i2 = Image[RandomReal[1, {8, 12, 3}]];     i3 = Image[RandomReal[1, {8, 12, 3}]];      I can scale a single image with               ImageResize[i1, Scaled[50]]      How can I map `ImageScaled` to all of them               ImageResize /@ {i1, i2, i3}      using the `Scaled[50]` argument?


title: How to create .ico file in Mathematica?

text: How to create .ico file in Mathematica? I mean the favicon images used for web sites. Directly using `Export["file.ico", <some graphical expression>]` does not seem to work.


title: How to set magnification of image to 75%

text: Right click on an output image, choose magnification. There are 25%, 50%, 100% etc. But how can I set to 75%?