title: Argmax in a List

text: I have a sequence of 100 lists. A sample list, list[1], looks like this:               list[1]=Table[{N[i/10], 25 - (i - 2)^2, 25 - (i - 8)^2}, {i, 1, 10}]          {{0.1, 24, -24},       {0.2, 25, -11},      {0.3, 24, 0},      {0.4, 21, 9},      {0.5, 16,16},      {0.6, 9, 21},      {0.7, 0, 24},      {0.8, -11, 25},      {0.9, -24,24},      {1., -39, 21}}      I would like to see where the 3rd column, $list[1][[*, 3]]$ is maximized. The 8th Row in this example. Then I want to note the value of the first column in the 8th row, namely $list[1][[8,1]]=0.8$. Then I would like to delete all records where the 1st column is > 0.8, i.e. where $list[1][[*,1]]>list[1][[8,1]]$ . In this example, since the numbers are monotonic, that means the last two rows get deleted. I'll be left with:                   {{0.1, 24, -24},       {0.2, 25, -11},      {0.3, 24, 0},      {0.4, 21, 9},      {0.5, 16,16},      {0.6, 9, 21},      {0.7, 0, 24},      {0.8, -11, 25}}      Then, I would like to see where the 2nd column, $list[1][[*, 2]]$ is maximized. The 2nd Row in this example. Then I want to note the value of the first column in the 2nd row, namely $list[1][[2,1]]=0.2$. Then I would like to delete all records where the 1st column is < 0.2, i.e. where $list[1][[*,1]]<list[1][[2,1]]$ . In this example, since the numbers are monotonic, that means the first row get deleted. I'll be left with:                   {       {0.2, 25, -11},      {0.3, 24, 0},      {0.4, 21, 9},      {0.5, 16,16},      {0.6, 9, 21},      {0.7, 0, 24},      {0.8, -11, 25}}      I guess both transformations are identical so if I know how to do one, I can do the other. I just mentioned both simply because it might be feasible to do both in one shot and that code might teach me more than learning the code for a single transformation. Also, I have a hundred different lists and I'd like to be able to do this transformation to all 100 of them in one shot, using Table or something. Thanks, PS: I have read advanced help but I can't seem to figure out how to get the shaded grey background on certain text so I have instead put $$ to get things like $ list[1][[*, 2]] $ as latex math above in my question to appear distinguished from the rest of the text.


title: Use Mathematica to do a network analysis of Mathematica.SE

text: Recently Wolfram|Alpha announced that you could use it to analyze your Facebook site. How could I do a network analysis of questioners and answers here on Mathematica.SE?


title: How to display docked cell (defined in stylesheet) in *.nb only (and not in *.cdf)?

text: I have a docked cell in a stylesheet (with shortcuts for editing the notebook). Is there an option I can set so that this cell is not displayed in CDF? **Edit** Based on answer by @MikeHoneychurch and the reference provided, here is the code I ended up using. Note this code deploys a notebook to a CDF removing any docked cells and cells tagged with "delete me". It will also ensure that styles embedded in the notebook are copied over to the CDF. Further changes may be required if the notebook inherits a stylesheet (refer to answer and link provided by @MikeHoneychurch).               Button["Save as CDF",      (*Get the directory/name of the current notebook and change the .nb to .cdf; use this as the default path for the deployed CDF*)      tmp = EvaluationNotebook[];      cdfDefaultName = NotebookFileName[EvaluationNotebook[]];      cdfDefaultName = StringReplace[cdfDefaultName, ".nb" -> ".cdf"];      cdfFileName =        SystemDialogInput["FileSave", {cdfDefaultName, {"CDF Files" -> {"*.cdf"}}}];      (*Get a copy of the private stylesheet a.k.a child and delete the docked cell*)      child = Options[tmp, StyleDefinitions];      childstyles = Cases[child, Cell[StyleData[_, ___], __], \[Infinity]];      modchildstyles = DeleteCases[childstyles, Rule[DockedCells, _], \[Infinity]];      (*Remove specified cells from the notebook *)      tmp1 = First@NotebookGet[EvaluationNotebook[]];      tmp1 = tmp1 /. CellGroupData[{Cell[_, "Input", ___, CellTags -> "delete me", ___], ___}, ___] :> Sequence[];      (*Deploy the CDF*)      CDFDeploy[cdfFileName, Notebook[tmp1, StyleDefinitions ->          Notebook[modchildstyles, StyleDefinitions -> "PrivateStylesheetFormatting.nb"]]],       ImageSize -> 100, Method -> "Queued"]


title: LevelScheme for ListPlot Joined->False exceeds the size of the Panel

text: In two side by side panels, using LevelScheme, I output the same data using ListPlot. In the first panel I use option Joined-> **False** , while in the second Joined-> **True**. The data in the second panel is properly limited by the size of the panel, while in the first panel it goes beyond the panel limits. So, my question is: how to make objects being displayed be cut exactly by the size of the panel, if even explicitly specifying the PlotRange in ListPlots doesn't make any difference?               << "LevelScheme"`     Figure[{       Multipanel[{{0, 1}, {0, 1}}, {1, 2}, XGapSizes -> {.5}],            FigurePanel[{1, 1}, PlotRange -> {{0, 10}, {0, 1}}],       RawGraphics[        ListPlot[Table[{.1 x, Sinc[.1 x]}, {x, Range@200}],          PlotRange -> {{0, 1}, {0, 1}},Joined->False]        ],            FigurePanel[{1, 2}, PlotRange -> {{0, 10}, {0, 1}}],       RawGraphics[        ListPlot[Table[{.1 x, Sinc[.1 x]}, {x, Range@200}],          PlotRange -> {{0, 1}, {0, 1}}, Joined -> True]        ]            },                PlotRange -> {{-0.1, 1.1}, {-0.1, 1.1}}]      results in ![result of the aforementioned code execution in Mathematica 9](http://i.stack.imgur.com/1Mvs4.png)


title: Strange response with dynamic texture and MousePosition

text: I built a cubic, then use `MousePosition` together with `GUIScreenShot` to take a floating region with fixed size (200*200) on the screen, and use it as dynamic texture on the cubic. My code is               Needs["GUIKit`"];     $HistoryLength = 1;          DynamicModule[{mpp},      Dynamic@{       Refresh[        ClearSystemCache[];        g = GUIScreenShot[With[{mp = MousePosition[]}, mpp = {mp - 100, mp + 100}]];        Graphics3D[{Texture[g], Polygon[coords, VertexTextureCoordinates -> Table[vtc, {6}]]}, Lighting -> "Neutral"],        UpdateInterval -> .5],       mpp, g},      Initialization :> (       vtc = {{0, 0}, {0, 1}, {1, 1}, {1, 0}};       coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}, {{0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}}};)]      You can see the result by executing the code then moving your mouse around. Like this, ![enter image description here](http://i.stack.imgur.com/4rNof.png) But there are two strange problems, 1) the size of the floating area taken should be always 200*200, however it will actually change. 2) the memory usage will constantly grow as we move our mouse, but I have already used `$HistoryLength=1` and `ClearSystemCache[]`. Any suggestion?


title: Creating functions from output of other calculations

text: Apologies in advance if the title is vague, I'm not really sure what to call this. I have a function (call it 'foo') that generates a largeish polynomial, and it is natural to make the variables be               x[1],x[2],x[3]      and so on, so I get a polynomial, e.g.               x[1]^2 x[2]+x[3]      Now, I'd like to store this as a function               bar[x[1]_,x[2]_,x[3]_]:=foo[whatever]      This doesn't work, of course, but if the variables were e.g.               x1,x2,x3      etc. instead, I could do               bar[x1_,x2_,x3_]:=foo[whatever]      and that would work. I figured some replacement rule would work, e.g.               rule={x_[i_] :> ToExpression@(ToString[x] <> ToString[i])}      which looks like it should work:               x[1]^2 x[2]+x[3]/.rule      gives output               x1^2 x2 + x3      but if I define               bar[x1_,x2_,x3_]:=foo[whatever]/.rule      then               bar[1,2,3]      outputs               x1^2 x2 + x3      instead of 5, which it should. Obviously, there is something I don't really understand about the way Mathematica handles variable names, and what I'm trying to do to fix this is probably too naive. Is there some better way to get around this problem? Thanks in advance for any help.


title: Weighted Kirchhoff Matrix?

text: I have a weighted graph and I want its graph Laplacian matrix (what Mathematica calls the Kirchhoff matrix in the unweighted case). Is there an easy way to get this? For example, the command:               WeightedAdjacencyMatrix[Graph[{0 \[UndirectedEdge] 1},EdgeWeight -> {3}]]//MatrixForm      returns the matrix               0   3     3   0      and               KirchhoffMatrix[Graph[{0 \[UndirectedEdge] 1}, EdgeWeight -> {3}]] //MatrixForm      returns               1 -1     -1 1      whereas I would like               3 -3     -3 3      I can do it in an ugly way, but I am wondering if there is a beautiful way to do it. * * * ### Edit I wrote a small function to do this, and it works.                    WeightedKirchhoffMatrix[G_] :=          (M = WeightedAdjacencyMatrix[G];          n = Length[M];          e = Table[1, {i, n}];          DiagonalMatrix[e.M] - M)


title: How to calculate definite integral when boundary is a limit?

text: Integrate[Log[x]/(1-x)^2,{x,eta,Infinity}]      The conditions are `eta>0`, and `eta->1`, how to incorporate the conditions?


title: Using Part rather than Extract

text: In my work I found that I needed the `Extract` function. However I was wondering if there was a way to use `Part`. Assume that `mList` is a 4-dim array. I did the following, which worked.               x = {2, 10, 3, 4};     y = Extract[mList, x];      I found that I can't do this.               y = mList[[x]]      Is there a way to convert the list `x`, into a sequence of integers that I can use in `Part`? I tried enclosing it in `Sequence`, but that seemed to have no effect. As I said, I'm fine without this, I was just wondering.


title: Solving two-component two-dimensional differential Equation with NDSolve (Brusselator Model)

text: I'm trying to solve a two-component two-dimensional reaction-diffusion differential equation system with Mathematica. The background of the model is the so called "Brusselator Model" where one can find a nice outline online from the Institute of Theoretical Physics in Münster, Germany. The model is given by the differential equation system: $$u_t=D_u\Delta u+a-(b+1)u+u^2 v$$ $$v_t=D_v\Delta v+b u-u^2 v$$ with u,v as the solution variables depending on x,y and t, $\Delta$ as the Laplace operator $D_u$ and $D_v$ as the diffusion constants and a,b as positive reaction rate constants. This system exhibits a transition from small fluctuations around the uniform steady state solution of the model into a high-amplitude stripe pattern as shown in Fig. 8.6 of the online reference, when the parameterset $D_u$, $D_v$, a and b is in the instability region. Based on stability analysis (see reference) the system is unstable when e.g. using the parameter set $D_u=5$, $D_v=12$, a=3 and b=9. The steady state solution of the system is: $$u_0=a=3, v_0=\frac{b}{a}=1/3$$ In Mathematica we define a small fluctuation (e.g. $\pm2\%$) on the steady state solutions $u_0$ and $v_0$ as initial values (at t=0) of the differential equations               u0 = Interpolation[Flatten[Table[{{x, y}, 3 + If[x == 0 || y == 0 || x == 50 || y == 50,             0,             RandomReal[{-a/50, a/50} /. a -> 3]], {0, 0}}, {x, 0,50}, {y, 0, 50}], 1],             InterpolationOrder -> 2];     v0 = Interpolation[Flatten[Table[{{x, y}, 9/u0[x, y], {0, 0}}, {x, 0,50}, {y, 0, 50}], 1],             InterpolationOrder -> 2];      here I restricted the initial value boundaries to the steady state without random fluctuation and enforced that the first derivate of the interpolation function is zero at the boundaries too, to keep the boundary and initial conditions in the differential equation consistent. One can plot the initial condition $u_0$ with the following statements               GraphicsRow[{       ContourPlot[u0[x, y], {x, 0, 50}, {y, 0, 50},          PlotLegends -> Automatic,          ColorFunction -> "SolarColors",          FrameLabel -> {"x", "y"},          ImageSize -> Medium],        Plot3D[u0[x, y], {x, 0, 50}, {y, 0, 50}, PlotRange -> {2.9, 3.1}]}]      My approach to solve this system for a x-y space interval of 50x50 units and the mentioned parameters, I tried out the following statement               NDSolve[Evaluate[{       D[u[x, y, t], t] == Du (Derivative[2, 0, 0][u][x, y, t] + Derivative[0, 2, 0][u][x, y, t]) + a - (b + 1) u[x, y, t] + v[x, y, t] (u[x, y, t])^2,       D[v[x, y, t], t] == Dv (Derivative[2, 0, 0][v][x, y, t] + Derivative[0, 2, 0][v][x, y, t]) + b u[x, y, t] - v[x, y, t] (u[x, y, t])^2,       u[x, y, 0] == u0[x, y],       v[x, y, 0] == v0[x, y],       Derivative[1, 0, 0][u][0, y, t] == 0, Derivative[1, 0, 0][u][L, y, t] == 0,       Derivative[0, 1, 0][u][x, 0, t] == 0, Derivative[0, 1, 0][u][x, L, t] == 0,       Derivative[1, 0, 0][v][0, y, t] == 0, Derivative[1, 0, 0][v][L, y, t] == 0,       Derivative[0, 1, 0][v][x, 0, t] == 0, Derivative[0, 1, 0][v][x, L, t] == 0,     } /. {L -> 50, Du -> 5, Dv -> 12, a -> 3, b -> 9}],      {u, v}, {x, 0, 50}, {y, 0, 50}, {t, 0, 0.05 4000}, MaxSteps -> {15, 15, Infinity}]      but get the following error: NDSolve::ibcinc: Warning: boundary and initial conditions are inconsistent. which is strange since I enforced the Neumann boundary conditions through the interpolation function derivate. Finally NDSolve runs forever, yielding no result even with the rather low setting of 15 for MaxSteps in x and y direction. Any proposal for improvements?


title: RDPStruct.exe: what is it and why are there so many?

text: I have an old (v7) webMathematica system running and it seems to generate a lot of RDPStruct.exe processes. First, what does this "Converter" do? GIF.exe and JPEG.exe are obvious, but "RDPStruct" doesn't mean anything to me. Does it make sense for there to be more than one running at a time? Does it make sense for there to be like 20 running at a time? Are they being orphaned somehow? If so, how can I figure out which ones are no longer in use? They seem to be causing system problems. I also have some command-line Mathematica processes that stop functioning properly sometimes and I find that killing off the RDPStruct processes will make them start working again. I don't yet have a lot of detail around this yet.


title: Alternative ways to AppendTo and Delete in a While loop

text: Is there an alternative way to do `AppendTo` and `Delete` and also replace `k0` during every update? I want to avoid the 3- `CopyTensor`s in the following code which probably are the reason behind the memory and performance problems for large values of `n`.               f = Compile[{{n, _Integer}},        Module[{Fk = Table[RandomReal[{0, 1}], {5}, {n}], k0 = Table[RandomReal[{0, 1}], {n}], TT = 0.1, ksum, i = 0},         While[TT > 0 ,          ksum = Total@Fk;          k0 = MapThread[Min[#1, #2 RandomReal[{0, 1}]] &, {k0, ksum}];          TT = Round[Total@k0, 0.01]; i++;          Fk = Delete[Fk, {1}];          AppendTo[Fk, k0];         ]; i        ]       ]


title: Odd edge-case behavior of Block

text: In this example, `Block` is used to localize the variable cache as used in the function `g` when called from the function `f`. In `f`, the cache symbol to use is passed in as the second parameter `z`:               f[a_, z_] := Block[{cache = z}, g[a]];     g[a_] := (Print["hash" -> Hash[cache]]; cache[1] = a; cache[1]);      Everything works as expected:               Hash[z]      2065959314 (your number may be different)       Calling `f`:               f[1, z]      hash->2065959314 (same)      1       The symbol `z` now has a single downvalue:               DownValues[z]      {HoldPattern[z[1]] :> 1}       However, what if I use the **actual symbol cache** as the cache symbol (say. by accident; not knowing that is the symbol name used inside `Block`):               Hash[cache]      1028301578 (your number may be different)       Calling `f`:               f[1, cache]      hash->1028301578 (same)      1       But nothing stored in the cache this time?               DownValues[cache]      {}       My (partial) theory is that `Block[{cache = cache}, ...]` may have used a temporary variable `cache$xxx` after `cache=cache` collapses, but that doesn't explain why we still see the correct hash for the symbol inside `g`. This is an awkward, but OK situation **if** you know the name of the variable used inside `Block`, but could conceivably lead to some very puzzling bugs (as it did for me) if you chance upon the same symbol name.


title: Strange behavior on very large numbers

text: I want to test the value of a differential equation by replacing a solution and setting random values for r and z variables:               sol = ψ -> Function[{r, z}, Sinh[2 (r + z)^2] + Tan[4/3 + r] + 5 (-r + Tanh[1/r])];          de2 = 1/(4*r^2) - D[ψ[r, z], z]^2 + D[ψ[r, z], z, z] + D[ψ[r, z], r]/(2 r)+ D[ψ[r, z], r]^2 +  D[ψ[r, z], r, r];      If I set for example:               N[de2 /. sol /. r -> -9 /. z -> 4]==0      I get a false result. The value is a very large negative number (-3.16913*10^29). If I set:               N[de2 /. sol /. r -> -90 /. z -> 4]      I get 0.*10^12836 in red, and a message saying "No significant digits are available to display." If I compare this last command to zero:               N[de2 /. sol /. r -> -90 /. z -> 4]==0      I get True! What's happening? How could I prevent this from occurring? Not using PZQ because it is too slow for the number of tests I want to do.


title: How to Export the current graphic state of a dynamic module?

text: After manipulating the graphics in a dynamic module like this: Synchronizing manual rotations for multiple Graphics3D outputs? How do I get at the current graphic so that I can Export the image? The answer might be burried in here Using DynamicModule variables outside the DynamicModule someplace but i am unable to decipher it..


title: How can I program the RiemannR function using the LogIntegral command?

text: I would like to program the `RiemannR` function using the `LogIntegral` command because I would like to later experiment with a double integral instead of the `LogIntegral` function. I have tried to program the `RiemannR` function starting with the `LogIntegral` command as defined in the Stein-Mazur paper called "Primes": ![RiemannR function as in Stein Mazur paper on primes](http://i.stack.imgur.com/uHKVF.png) That agrees almost completely with the definition given in the _Mathematica_ help page about the `RiemannR` command: $$R(x)=\sum_n^\infty \mu(n)\mathrm{li}(x^{1/n})/n$$ The only differences I see are that the summation limit $n=1$ is given in the Stein-Mazur paper while in the _Mathematica_ help page it is not. Also the Stein-Mazur paper uses $\mathrm{Li}$ for the logarithmic integral while the _Mathematica_ help page uses $\mathrm{li}$. However in the _Mathematica_ help page for the `LogIntegral` command the lower case $\mathrm{li}$ is used. My problem is that when I enter the following lines:               N[RiemannR[1000]]     N[Sum[MoebiusMu[n]*LogIntegral[1000^(1/n)]/n, {n, 1, Infinity}]]      in _Mathematica_ , I get different numerical values:               168.359     168.341      What am I doing wrong?


title: How to create InterpolatingFunction from data?

text: If I have a function at a number of non-uniformly spaced data points:               youtReal[7.8]=2.0332;, youtReal[8.54]=6.24352354;..................      ......... and the imaginary parts:               youtImag[7.8]=2.54345345; youtImag[8.54]=-5.2434;.................      Is there an easy way to generate an InterpolatingFunction from this data consisting of complex values i.e. so I have yout[7.8]=2.0332+2.54345345I; and can also just get an interpolated value for say yout[8.12] and so on. To make this more concrete, the initial data is read in from a text file that looks like               youtReal[39.983881559265192985] =0.003175121157662356963;      youtImag[39.983881559265192985] =-0.025570345562818877981;      youtReal[39.945803445544929806] =0.0030816430773355882379;      youtImag[39.945803445544929806] =-0.025607948113924885628;      youtReal[39.907725331824666628] =0.0029879382430246325535;      youtImag[39.907725331824666628] =-0.025645261479980185081;      youtReal[39.869647218104403449] =0.0028940073645911109315;      youtImag[39.869647218104403449] =-0.025682284691974913792;       youtReal[39.831569104384140271] =0.0027998511548903118804;       youtImag[39.831569104384140271] =-0.025719016782491712295;       youtReal[39.793490990663877092] =0.0027054703297639490629;      youtImag[39.793490990663877092] =-0.025755456785713930289;      youtReal[39.755412876943613914] =0.0026108656080328711776;      youtImag[39.755412876943613914] =-0.025791603737433792661;     youtReal[39.717334763223350736] =0.00251603771148972405;      youtImag[39.717334763223350736] =-0.025827456675060525123;      .      .      .      and so on all the way down to around youtReal[~29]. So I read this in then have a function with quite arbitrarily defined value points, and lots and lots of them. I don't have a nice list of points I can just feed into `ListInterpolation` ab initio, I need to somehow generate this.


title: Plotting array of vectors with conditions

text: Given data in the form               list={{{1,2},{3,4},{5,6}},{{7,8},{9,10},{11,12}},...}      a matrix where elements are 2-element vectors, what is a efficient way to plot this as a spatial grid? As I understand               ArrayPlot[array,ColorFunction->(If[#>3,Red,White]&), ColorFunctionScaling->False]      can only be "fed" with normal array (no 2-vector like above), if you want to use Colorfunction If condition. I want that a cell of the ArrayPlot mesh gets Red, when in {x,y} vector `1<x<2 AND y>3`, otherwise White. I know I could recreate the list into a {{1,0,1},{0,1,0},...} like normal array so ArrayPlot could read it, by using Table and Take, 1 and 0 representing the Red and White Case:               If[1<First[Flatten[Take[list,i]]]<2,1,0]      Then rebuild that list with Table and Join. But as far as I know MM, there has to be easier way, simply reading list and replacing a 2-vector with 1 or 0 1-vector under above conditions. Or do I really have to build the list completely new, problem is it has some million elements. Thanks for any tips to improve this


title: How to visualize slope fields of differential equations without vectors?

text: I'm looking to visualize slope fields of differential equations for my differential equations course. Every example I see draws them as vectors, adding unnecessary "arrows" that, to me, are visually distracting. Is there a way to plot these slope fields without the "arrows" that get in the way?


title: Is it possible to treat starting values as variables?

text: I have a problem where I am using FindRoot a gazillion times over a grid of parameters. I need to allow the starting values to vary a bit with the parameters to get it to converge. Here is a simple example in the spirit of my much bigger problem:               f[a_] := x /. FindRoot[x^2 - 1 == a, {x, a - 1, a + 1}]     NIntegrate[f[z], {z, 0, 5}]      NIntegrate actually gives an answer (I think it's even right), but it also gives the following errors: > FindRoot::srect: Value -1.+z in search specification {x,z-1,z+1} is not a > number or array of numbers. >> > > ReplaceAll::reps: {FindRoot[x^2-1==z,{x,z-1,z+1}]} is neither a list of > replacement rules nor a valid dispatch table, and so cannot be used for > replacing. >> It looks like it doesn't like treating the starting values for x as variables. For some reason, the actual numbers between 0 and 5 in the integral are not being passed to the starting values in FindRoot. Any suggestions?


title: Symbol created in unevaluated second argument of If

text: Apologies for the long question title, but I couldn't come up with something shorter to describe the following. Starting with a clean session, there are no symbols in, let's say, `myContext`:               Names["myContext`*"]     (* {} *)      But if I now evaluated this If statement,               If[False, myContext`mySymbol = "value"]      all of the sudden `mySymbol` has been created in `myContext`:               Names["myContext`*"]     (* {"myContext`mySymbol"} *)      but, as expected, `mySymbol` doesn't have a value:               myContext`mySymbol     (* myContext`mySymbol *)      My question is twofold: why has `mySymbol` been created, and how can I prevent this from happening?


title: Error invoking Information on functions containing Legended

text: In adapting some plotting functions to utilize the `PlotLegends` option of version 9, I came across the following errors:               f[x_] := Legended[Plot[Sin[t], {t, 0, Pi}], x]     f[1];     Information[f]      > `TextForm[First::first: StandardForm[Short[Shallow[HoldForm[{}], {10, 50}], > 5]] has a length of zero and no first element. >>]` This is just a toy example for a more complex situation where I can't directly use the `PlotLegends` option but have to use `Legended` explicitly. What is the best way to catch this error when a user invokes the above or types `?f` to see the code for this function. It seems the output of `Definition` works as expected (it formats the `Legended` contents, and that happens for other constructs such as `Framed` too).


title: How to execute kernel command from Front End?

text: Documentation for Yuri E. Kandrashkin's OptionsExplorer package says to add the following menu commands in MenuSetup.tr:                  Item["Options &Explorer", KernelExecute[ToExpression["OptionsExplorer[]"]],        MenuKey["o", Modifiers->{Control,Command}], MenuEvaluator->Automatic]      And I want to accomplish the same thing by a corresponding `FrontEnd`AddMenuCommands...` expression in an `Autoload`PacletManager`Configuration`FrontEnd`init.m`. But I don't find any `KernelExecute` function. How to do it?


title: Formatting All Appropriate Output as Desired Automatically

text: I want to output in `MatrixForm` whenever I have a list/vector/matrix, but I do not want to have to type out the command each time. How can I write one command at the beginning of the notebook so that all output is so formatted? (Also: generalization to any formatting would be better, with additional specific detail included for this case.)


title: solving a cubic equation

text: I need to find the minimum $r$ and the maximum $k$ of the following cubic equation for which there does not exist three distinct real roots. $rx^3-rkx^2+(r+k)x-rk=0$. Is it possible to find such $r$ and $k$ analytically? Or if you can provide me help using mathematica, that would be fine too.Thanks.


title: Accessing the Options of the parent Cell

text: From within the Kernel, it is possible to access a `Cell`'s options using `CurrentValue`. For instance, in a `Cell` tagged `{"Bob", "Frank"}`, executing this               CurrentValue[CellTags]     (* {"Bob", "Frank"} *)      But, how would one go about accessing the options of the parent cell in the hierarchy? One difficulty is that the `Cell` knows nothing about the `CellGroup` it finds itself in, so attacking the problem from that direction seems difficult. However, the current executing `Notebook` can be accessed via `EvaluationNotebook`, so traversing the tree from that direction seems plausible, if not efficient.


title: generating pdf using UseFrontEnd

text: I run mathematica on a remote server and run it in batch mode using /math -noprompt -script 'scriptname.m' & Now, I use ssh -X to connect to the server. The server is linux based and my computer is a mac. I use x11 forwarding. I would like to generate PDFs in the above mentioned 'script.m'. In my code, how should I incorporate UseFrontEnd? should I invoke it first using ConnectToFrontEnd[] ? Should I use UseFrontEnd[Export["blah.pdf",fig]] or is it a one time thing? Also, when using the UseFrontEnd command, is it required that I do ssh -X/Y or is it sufficient if I do ssh? I greatly appreciate your help. Thanks. P.S - I am using mathematica 8


title: Plotting a path in a vector field

text: I am trying to make a visual representation of the curve $y=x^{2}$, with $x\in\left[0,1\right]$ in the vector field defined by $\vec{F}=\left[-y,x\right]$. However, as far as I can tell there does not seem to be any facility which allows me to do this in Mathematica (I've looked through as much of the documentation as I could find which seemed pertinent). I know how to do each of these separately, e.g.               Plot[x^2,{x,0,1}]     VectorPlot[{-y,x},{x,-3,3},{y,-3,3}]      However, I am unsure how I can combine these two plots (or plot them both at the same time). Thanks in advance!


title: Choose partition of a set with Manipulate

text: Suppose I have a set represented by an array of strings, like > set = { "A", "B", "C", "D", "E", "F" } I would like to create a Manipulate which allows the user to build repartitions of the set. To be clear, I'd like the user to be able to build, for instance, the following repartitions:               repa1 = { {"A", "B", "C"}, {"D", "E", "F"} }      and               repa2 = { { "A" }, { "B", "C" }, { "D", "E", "F" } }      $$ $$ Is this possible? * * * Even better, I would like to be able to use labels for the manipulate command. I mean, let's say the set is > set = { {"A", 26}, {"B", 33}, {"C", 69}, {"D", 2}, {"E", 16} } then the selector should look like part1 : [ A, B, C, D, E ] part2 : [ A, B, C, D, E ] part3 : [ A, B, C, D, E ] and, supposing I choose the following combination, part1 : [ **A** , B, **C** , D, E ] part2 : [ A, **B** , C, **D** , E ] part3 : [ A, B, C, D, **E** ] the result should be > repa = { { {"A", 26}, {"C", 69} }, {{"B", 33}, {"D", 2}}, {{"E", 16}} }


title: V10 interface problems

text: Has anyone noticed the following?   1. Sometimes when I bring up the Help->Wolfram Documentation there is no text field to type into.   2. When I bring up Find and Replace there are two text fields for Find: and Replace with: but no other controls or buttons (No buttons Find Next, Find Previous, Replace etc). In this case on my system - win7-64 - the dialog box is unnaturally tall (whole height of screen).   3. Syntax highlighting seems somewhat erratic - defined symbols stay the wrong color for a while. Symbols that are part of a function signature, say f[x_]:=... stay the wrong color for a while as well. Restarting Mathematica restores these.


title: How to suppress automatically generated header in packages?

text: At the top of the `.m` file which is automatically generated from initialization cells in a notebook there appears a header:               (************************************************************************)     (* This file was generated automatically by the Mathematica front end.  *)     (* It contains Initialization cells from a Notebook file, which         *)     ...      Is there any way to suppress generating this header?


title: Why is Neptune missing from AstronomicalData?

text: An old notebook I've recently started working with has a strange error: Prior to version 8, a figure I generated using `Drop[AstronomicalData["Planet"],-1]` to display all of the currently recognized planets, along with some other data, worked fine, but in version 8, Neptune is missing. Is this a bug in 8, or am I missing something?


title: Plotting a matrix in 3D With specific ticks

text: I have matrix and I want to plot it in 3D               ListPlot3D[{{3.98765, 3.9805722621093267`, 3.6669734993637384`,         3.547140513657327`}, {4.00978, 6.841217936322747`,         3.664440739410208`, 5.55098}, {4.094896872960633`, 4.36315,         6.327539411775844`, 3.962204146812651`}, {3.983216682983883`,         6.26917, 4.7494476017929514`, 16.1384}, {4.04999, 4.79856,         3.659365327920453`, 4.156261830970234`}, {4.059789950180353`,         4.014186008147935`, 4.722610902483124`,         5.748447432928523`}, {4.2315454107761665`, 3.76239, 3.94495,         3.9403001696511617`}, {4.06719, 5.18322, 4.0810431833309`,         3.83299}, {4.01151, 3.9015086486265798`, 20.185861947480277`,         5.08127}}, MeshStyle -> Opacity[0.4], InterpolationOrder -> 3,       ColorFunction -> "SouthwestColors"]       the result is as below where mathematica assumes the ticks to be natural numbers starting from one while they should be different. {1,2,3,4} should be {2,3,4,5} and {1,2,3...,8} should be {1.1,...,1.8} any suggestions? ![enter image description here](http://i.stack.imgur.com/T5F6f.jpg)


title: Correct way to handle mysterious NaN` result from MathLink function

text: I have a Mathematica expression that is mapped onto an external `C` function via `MathLink`. The external function passes a `double` array (using `MLPutReal64List[]`), which Mathematica interprets as a list of `Real`'s. Sometimes the external function sends values for which the `C` math library function `isnan(value)` returns `1` (say from division by zero, or `log(0)`). Mathematica reads these values as `NaN``. For example,               In[1]:= result = externalFunction[<some input>]     Out[1]= {NaN`, 0.18225}      Evaluating {NaN`, 0.182255} gives a syntax error:               In[2]:= {NaN`, 0.182255}     Syntax::tsntxi: "{NaN`,0.182255}" is incomplete; more input is needed.     Syntax::sntxi: Incomplete expression; more input is needed.      which makes sense, since a variable name is expected to follow the ```, giving some variable in the `NaN` context. But mathematica accepts `result[[1]]` as a number:               In[3]:= NumericQ[result[[1]]]      Out[3]= True     In[4]:= NumberQ[result[[1]]]     Out[4]:= True      !! Yet I haven't been able to find a pattern that matches `NaN`` and not all other numbers (for use in `Position`, `Cases`, etc.). So what are ways of a) passing NaN's from c into Mathematica so that Mathematica interprets them as `Indeterminate`, or b) handling these `NaN`s inside mathematica (with a pattern match to replace them with `Indeterminate`, for example). Is it possible to construct the first element of `result` using keyboard input? Note that `InputForm[result[[1]]]` gives `NaN`, and `NumericQ[InputForm[result[[1]]]]` gives `False`.


title: How to simplify expressions containing derivatives

text: Is there a way to reverse the application of derivative rules in order to simplify expressions including derivatives? e.g. in Mathematica code: Want to go from               (g[x, y]*Derivative[1, 0][f][x, y])/h[x, y] + (f[x, y]*Derivative[1, 0][g][x, y])/h[x, y] -      (f[x, y]*g[x, y]*Derivative[1, 0][h][x, y])/h[x, y]^2      to               D[f[x, y]*g[x, y]/h[x, y], x]


title: Transformation of a simple logic statement

text: I'm designing a logic circuit and I was wondering if the following two things are equivalent: (x <= y) and (x < (y + 1)) I can't think of any set of numbers that would make these two things not equivalent. Only real integers are allowed. Thank you.


title: Problem with NonlinearModelFit

text: I'm having trouble with a non-linear fit: `fit = NonlinearModelFit[data, y0 + A Sin[\[Pi] (x - xc)/w], {y0, xc, A, w}, x]` where `data` has about 15 thousand points and looks like this: ![data](http://i.stack.imgur.com/QOe5a.png) **The data can be downloadedhere.** Mathematica gives the following adjusted parameters: `{y0 -> 30.4428, xc -> 1.54318, A -> -0.000528519, w -> 0.999975}` However, this is a terrible fit: ![enter image description here](http://i.stack.imgur.com/Xvok3.png) I wouldn't complain, except that there is an obviously better fit: ![enter image description here](http://i.stack.imgur.com/Cnu4l.png) with the parameters: `{y0 -> 30.45775, w -> 752.71185, A -> 3.62443, xc -> 872.72035}` This best fit is returned by Origin without effort. What can I do to achieve the same with Mathematica? (I like Mathematica!)


title: Make duplicate string then join two strings together in a table

text: I have two lists of `data`, `dataA` and `dataB`.               dataA = {100169}     dataB = {0001,Olivine,Process},{0002,Olivine,Process},{0003,Olivine,Process}      I don't know how to write a function that would give me a data table that looks like this.               {100169,0001,Olivine,Process}     {100169,0002,Olivine,Process}     {100169,0003,Olivine,Process}


title: How to find the complex number has least and greatest modul satisfying a given condition?

text: Let be given the complex number $z$ satisfying the condition $|z-2+2i|=2\sqrt{2}$. I want to find the complex numbers $z$ so that their modul obtain least and greatest value. I tried. Put $z = x + y i$. From $|z-2+2i|=2\sqrt{2}$, we have $$|(x-2) + (y+2)i|=2\sqrt{2}.$$ Therefore, $$(x-2)^2 + (y+2)^2=8.$$ And then, I used               Maximize[{x^2 + y^2, (x - 2)^2 + (y + 2)^2 == 8}, {x, y}]      > {32, {x -> 4, y -> -4}} and               Minimize[{x^2 + y^2, (x - 2)^2 + (y + 2)^2 == 8}, {x, y}]      > {0, {x -> 0, y -> 0}} I dont know why I can not use the command               Abs[(x - 2) + (y + 2) I]      to find the modul of `(x - 2) + (y + 2) I` and how to tell _Mathematica_ to get the result $$(x-2)^2 + (y+2)^2=8$$ when I have $$|(x-2) + (y+2)i|=2\sqrt{2}.$$


title: SDE boundary condition

text: I have a simple SDE with white noise:               mysde[q_, I_, n0_, sd_] :=        ItoProcess[         \[DifferentialD]n[t] ==            ( I - q n[t]) \[DifferentialD]t + sd \[DifferentialD]w[t], n[t],          {n, n0}, t, w \[Distributed] WienerProcess[]]      I want to impose a condition that n[t] cannot fall below zero. At below zero, or an arbitrarily low value of n[t], it is considered zero. I am not sure how to implement this in the ItoProcess function and/or in the numerical solution:               sol[q_, I_, n0_, sd_] := RandomFunction[mysde[q, I, n0, sd], {0, 100, 0.1}, 1]      The variable drops below zero many times, which is not a desired behaviour:               With[{q = 2, I = 0.1, n0 = 1, sd = 0.1},        Show[ListLinePlot[sol[q, I, n0, sd]], ImageSize -> 400]]      What are some ways to implement such a condition? I have tried various functions on `n[t]` within the `ItoProcess[]`, to attempt to re-set negative values of `n[t]` to zero, like `If[]`, `Max[]`, `Clip[]`, and `Piecewise[]` to no avail. Any reasons why these functions do not dynamically work within the solver? Also is there a way to extract the values of the noise, `w[t]`, in a particular simulated path of the temporal data timeseries object? One potential solution, which is not confirmed to be correct, is to write the equation for the log of my variable, `ln[t]` and to use the Geometric Brownian motion random process formulation, obtaining:               logsde[q_, I_, ln0_, sd_] :=        ItoProcess[         \[DifferentialD]ln[t] ==            ( I - q ln[t] - sd^2/2) \[DifferentialD]t + sd \[DifferentialD]w[t], ln[t],         {ln, ln0}, t, w \[Distributed] GeometricBrownianMotionProcess[I - q ln[t], sd, n0]]          logsol[q_, I_, ln0_, sd_] := RandomFunction[logsde[q, I, ln0, sd], {0, 100, 0.1}, 1]      Then I extract the simulated values, and exponentiate them to obtain the time series or path in the original scale:               td = With[{q = 0.1, I1 = 0.1, ln0 = 1, sd = .1},        logsol[q, I1, ln0, sd]];     ListLinePlot[Exp[td["States"]]]      However I have lost the stochastic signal in this model; the simulation smooths out and looks continuous with no noise, except at the beginning of the simulation. This is obviously an incorrect formulation. What did I do here? How might I formulate this properly? Are there other approaches? So overall I have three questions:   1. How to implement a boundary condition in `ItoProcess[]` for one of the state variables?   2. How to recover the simulated values of the random variable? <\- self-answered below   3. How to properly specify a log-transformed version of the `ItoProcess[]`?


title: How can I solve precision problem

text: I want to set 2 decimal places, whether it's real Number or anything.for that purpose I wrote the following function.                decimalPlaces[number_]:=SetPrecision[number, 3]      case 1: If you pass `3`as a argument,it should returns `3.00`. case 2: if you pass `3.98967465684` as a argument,it should returns `3.98`. case 3: if you pass `394` as a argument,it should returns `394.00`.But it returns `394`. case 4: if you pass `394.985674` as a argument,it should returns `394.98`.But it returns `394`. finally,my function was not satisfying the case 3,4 testcases How can I solve this. Fell free,If you want to edit my question. Thank you.


title: How do I get Mathematica to show a number in non-exponential form?

text: Sometimes I make a calculation in Mathematica that produces a big number, which Mathematica shows like so:               -1.52522*10^7      This is annoying to me, because I want to see the number normally, without exponential notation, something like this:               -15,252,264.7448716      How can I make Mathematica show the number normally?


title: How do you force a decimal output?

text: I have some very small values such as 2.601519253*10^-8. I'd like to output these values to CSV for another program to work with. I've tried N[value, 50], but Mathematica still insists on producing scientific notation (which my program can't read). How can I force Mathematica to output values in decimal form? EDIT: AccountingForm seems to be the answer to my question. AccountingForm[2.601519253458693*10^-8, 30] gives a nice decimal format I can use. –


title: Representation of negative exponents

text: > **Possible Duplicate:**   >  Way to improve "show me this decimal number to M places, don't use > scientific notation"? How can I expand e.g. number 1.*10^-8 so that there would be no exponents? It should look like 0.00000001.


title: Way to improve "show me this decimal number to M places, don't use scientific notation"?

text: The best way I can come up with to say "show me this fraction as a decimal number to M places, don't use scientific notation" is:               NumberForm[N[1/998001,2994],ExponentFunction->(Null&)]      It seems like that's an awful lot of typing for a very simple request. Is it possible say it more concisely?


title: Incorrect results for elementary integrals when using Integrate

text: There is a rather simple integral ($K_0$ is the 0-th order MacDonald function) $$\int_0^\infty e^{-x \cosh\xi}\, d\xi = K_0(x)$$ which mathematica cannot solve. This even though the documentation claims that Integrate can give results in terms of many special functions. In fact it can solve the integral obtained by substituting $r=\cosh \xi$, $$\int_1^\infty \frac{e^{-x r}}{\sqrt{r^2-1}}\,dr=K_0(x).$$ In fact it also failed in solving the more general integral $$\int_0^\infty e^{-x \cosh\xi} \cosh(\alpha \xi)\, d\xi = K_\alpha(x).$$ I am using "8.0 for Mac OS X x86 (64-bit) (October 5, 2011)". Are there more recent or older versions of Mathematica which can solve this class of integrals? * * * **Edit:** I want to stress that this is not an arbitrary integral but can be thought of as a definition of $K_0$ (the corresponding integral $\int_0^{2\pi} \\!e^{i x \cos \xi}\,d\xi$ for $J_0$ mathematica handles very well). I am just curious how it can happen that a system as developed as Mathematica cannot handle this "elementary" integral. Here is the Mathematica code for those who want to test:               Integrate[Exp[-x Cosh[ξ]],{ξ,0,Infinity}]      Now I found a related integral which indeed is a bug in mathematica. If you try to evaluate ($x \in \mathbb{R}$) $$\int_0^\infty \cos(x \sinh \xi)\,d\xi = K_0(|x|)$$ then Mathematica claims that the integral diverges.


title: Is Abs[z]^2 a bad way to calculate the square modulus of z?

text: For a numerical quantity `z`, `Abs[z]` returns the square root of the sum of the squares of the real and imaginary parts of `z`. If we then square it, do we lose numerical accuracy because we are squaring after taking a square root?   Is it better to use `Re[z]^2+Im[z]^2`?


title: Why does ++++x return an increment of 2 when the value of x is only incremented by 1?

text: This line returns `3`:               x = 1; ++++x      ![enter image description here](http://i.stack.imgur.com/80WEy.png) However, the value of `x` after the increment is only 2. Similarly, this line returns `5`, while the value of `x` is again only 2.               x = 1; ++++++++x      ![enter image description here](http://i.stack.imgur.com/rTYeU.png) Why does it return `3` and `5` respectively in the above examples? * * * (This question is intended as a puzzle, and to encourage people to think through an opaque evaluation chain.)


title: Applying Some Kind of Timing Function to AutoRunSequence

text: Ok, so I'm exporting a video to MOV format that is coming from a manipulate function (I'm demonstrating CLT to a class that doesn't have calculus as a pre-req, if anyone is curious). Anyhow, I'm mostly happy with it, but ideally I'd like it to not generate the frames of the video linearly, but rather spend more frames on the front section and decrease as it approaches the max boundary. Is this possible? This is the current code:               manr = Manipulate[        Resample = Table[Mean[RandomChoice[SetAll, Length[SetAll]]], {Samples}];        Histogram[Resample, Axes -> {False, False}, ImageSize -> Large], {Samples, 100, 100000},         AutorunSequencing -> {Automatic, 30}];     Export["~/desktop/sam.mov", manr]


title: How to make the animation rate lower in an exported GIF

text: I have a ".gif" figure exported from the following codes. 6 separated figures (frames) constitute a ".gif" figure. But the default time interval between each frame is less than 1 second. I hope to increase the time interval to 3 seconds, so the speed can be lower. Any one can help me? Thank you all in advance!               g1[a_, b_] := Graphics[{Red, Disk[{a, 0}, 1], Green, Disk[{1, 1}, 1], Blue, Disk[{b, 2}, 1]}];     f1 = Table[Show[g1[a, b] , PlotRange -> {{-2, 12}, {-2, 4}}  ], {a, 1, 8, 4}, {b, 0, 10, 5}];     f1 = Flatten[f1]     Export["f1.gif", f1]      ![enter image description here](http://i.stack.imgur.com/Bf8JZ.jpg) ![enter image description here](http://i.stack.imgur.com/Qdinm.gif)


title: Making a movie with specific frame-rate out of ListPlot outputs?

text: > **Possible Duplicate:**   >  Is it possible to prerender animation in Wolfram Mathematica?   >  Does Mathematica support variable frame rate for any video format, in > analogue of GIF-style “DisplayDurations”? I would like to make a movie that shows a series of `Plot`/`ListPlot` outputs as frames for `s` seconds of time each. Is there a simple way to do this?


title: Exporting as GIF

text: I want to export a simple animation as GIF. I had a look at here but could not understand what was being described. Any help would be appreciated. For instance, how do I export the following animation as an GIF.               u[x_, t_] = -(1/2) Cos[x - t]^2 + 1;          Animate[Plot[u[x, t],{x, -10, 10},PlotRange->{0, 1.5},PlotStyle->{Red, Thickness[0.005]}],{t, 0, 10, 0.02}]      Thanks, Radz.


title: Is it possible to prerender animation in Wolfram Mathematica?

text: I have a `DensityPlot` which is evaluated for a long time. I wish to use it with animation, but it is absolutely inapropriate. Is it possible to render animation first and then run it smoothly?


title: How to Export this animation as a gif file for powerpoint presentation

text: Animate[     Manipulate[     ParametricPlot[     Evaluate[{x[t], v[t]} /.      Quiet@NDSolve[        {x'[t] == v[t],         v'[t] == μ (1 - x[t]^2) v[t] - x[t] + A*Cos[ω*t],         x[0] == xv0[[1]],         v[0] == xv0[[2]]},        {x[t], v[t]},        {t, 0, tt}]],     {t, 0, tt},     ImageSize -> {450, 450}, PlotRange -> 4,      AxesLabel -> {TraditionalForm[x[t]], TraditionalForm[v[t]]},     PlotStyle -> PointSize[.5]],     {{μ, 0.75, "parameter μ"}, 0, 3, 0.01,      Appearance -> "Labeled"},     {{ω, 0.75, "parameter ω"}, 0, 3, 0.01,      Appearance -> "Labeled"},     {{A, 0.75, "parameter A"}, 0, 3, 0.01, Appearance -> "Labeled"},     {{xv0, {1, 1}}, {-4, -4}, {4, 4}, Locator}], {tt, 0, 200},      AnimationRate -> 3, AnimationRepetitions -> 3,      AnimationRunning -> True]


title: Creating a .gif file from a complex Manipulate function

text: I am trying to create a .gif file from the following manipulate functions (sorry for the poor formatting but I couldn't figure how to do it better) :               manipulateGraph =      Manipulate[     parametersManipulate = {dK -> dKValue, d -> dValue, y -> yValue, dI -> dIValue,                              p -> pValue, a -> aValue, κ -> κValue, kp -> kpValue,                              dR -> dRValue, kon -> konValue, koff -> koffValue};     (* Define parameters such that they can be manipulated. *)     solutionManipulate = NDSolve[{Kk'[t] == -dKValue*Kk[t],        Nn'[t] == dValue*(1 - Nn[t]) + yValue*dIValue*(1 - Nn[t]) + pValue*Kk[t]*(1 - Nn[t]) - aValue*Nn[t]*Ii[t],        Ii'[t] == dValue*(1 - Nn[t]) - κValue*pValue*Kk[t]*Ii[t] - aValue*Nn[t]*Ii[t] + kpValue*Rr[t] - dIValue*Ii[t],        Rr'[t] == dRValue*(Gg[t] - Rr[t]),        Gg'[t] == konValue*Nn[t]*(1 - Gg[t]) - koffValue*Ii[t]*Gg[t],        Kk[0] == 1, Nn[0] == 0.0204896, Ii[0] == 0.728553,        Rr[0] == 0.0138668, Gg[0] == 0.0138668} /.       parametersManipulate, {Kk[t], Nn[t], Ii[t], Rr[t], Gg[t]}, {t, 0,       50}, MaxSteps -> Infinity];           (* Substitute the parameters in the NDSolve function such that they     can be manipulated. *)     Plot[Evaluate[{Kk[t], Nn[t], Ii[t], Rr[t], Gg[t]} /.       solutionManipulate], {t, 0, 50},      AxesLabel -> {"Time (Hours)", "Non-Dimensionalized Amount Present in Cell"},     PlotRange -> All,      PlotLegends -> LineLegend[{"K", "N", "I", "R", "G"}],      PlotStyle -> {Magenta, Green, Red, Cyan, Blue},      PlotLabel -> Style["Manipulate Graph", "Subsection"],      LabelStyle -> Medium, ImageSize -> 750],           (* Plot the solution. *)     {{dKValue, 0.15, "Rate of IKKa inactivation following an initial stimulus - dK"},      0.015, 1.5},      {{dValue, 3, "Rate of IκBα - NF-kB complex degradation - d"},      0.3, 30},     {{yValue, 0.2, "Rate factor by which the IκBα in the IκB\     α - NF-kB complex can spontaneously degrade - y"},      0.2*(10^(-0.25)),      0.2*(10^0.25)},      {{dIValue, 0.24, "Rate of IκBα spontaneous degradation - dI"}, 0.24*(10^(-0.25)),      0.24*(10^(0.25))},      {{pValue, 9, "Rate of IκBα - NF-kB complex degradation induced by IKKa - p"}, 9*(10^(-0.5)), 9*(10^(0.5))},      {{aValue, 200, "Rate of IκBα - NF-kB complex formation - a"}, 20, 2000},     {{κValue, 0.2, "Rate factor by which free IκBα can be degraded by IKKa - κ"}, 0.2*(10^(-0.25)), 0.2*(10^(0.25))},      {{kpValue, 16, "Rate of IκBα mRNA translation - kp"},      16*(10^(-0.5)),      16*(10^(0.5))},      {{dRValue, 2.7, "Rate of IκBα mRNA degradation - dR"}, 2.7*(10^(-0.25)), 2.7*(10^(0.25))},      {{konValue, 7.5, "Rate of gene expression activation by NF-kB - kon"}, 7.5*(10^(-0.5)),      7.5*(10^(0.5))},      {{koffValue, 15, "Rate of gene expression inactivation by IκBα detaching NF-kB from the promoter - koff"}, 15*(10^(-0.5)), 15*(10^(0.5))}]      (* Define the initial values of each variable      their name and their range of values. *)      I have tried using the `ManToGif` function (http://community.wolfram.com/groups/-/m/t/86994) but my computer with 12gb of ram runs out of memory before finishing. Any help? I absolutely need the result to be a .gif animated picture. I've tried many methods and none seem to be working...


title: Creating a matrix from the output of a variable inside a for loop

text: I would like to enter the results of the following loop inside a matrix as its elements:               p=1;     q=4;          For[i = 0, i < p, i++,       For[j = 1, j < q + 1, j++,        For[h = 0, h < p, h++,         For[k = 1 , k < q + 1, k++,          Subscript[wtotal, m, i, j, h, k] =            Subscript[w, m, i, j, h, k  ] + Subscript[w1, m, i, j, h, k]          ; Print[Subscript[wtotal, m, i, j, h, k]]]]        ]       ];      This matrix gives 16 values, so I would like to enter those 16 values inside a 4X4 matrix. So how should I do it... Further how should i convert the 4x4x4x4 table into a 16x16 matrix so that i can take its inverse.?


title: Is it possible to substitute tick labels with alternative text?

text: > **Possible Duplicate:**   >  Labelling ArrayPlot Charts I am making a `MatrixPlot`. For example, consider the following:               list = {{1, 1, 0, 1}, {0, 0, 1, 1}, {1, 0, 1, 0}};     MatrixPlot[list]      which yields: ![MatrixPlot](http://i.stack.imgur.com/QXRcu.gif) But now suppose I want to label the axes with other numbers. For example, I would like to label the ticks on the horizontal axis as 101, 167, 188, 205 (as they are not now), and the ticks on the vertical axis as 1, 2, 3 (as they already are). I know this is a strange request, but it is because I would like to label the horizontal axis according to "particle number" (which is an integer in my application). Or maybe a better way to phrase the question is, is it possible to label axis/frame ticks with _any_ arbitrary string (for example, labeling the horizontal axis with `"Alice"`, `"Bob"`, `"Carla"`, and `"David"`)? One possibility seems like `FrameTicks`, but I can't seem to figure out if it can be used to map strings. If I use               list = {{1, 1, 0, 1}, {0, 0, 1, 1}, {1, 0, 1, 0}};     MatrixPlot[list,       FrameTicks -> {{{1, 2, 3}, None}, {{101, 167, 188, 205}, None}}]      I get: ![MatrixPlot](http://i.stack.imgur.com/EGt5n.gif) because, of course, `FrameTicks` thinks I'm referring to which discrete values to label. Also, if I try:               list = {{1, 1, 0, 1}, {0, 0, 1, 1}, {1, 0, 1, 0}};     MatrixPlot[list,       FrameTicks -> {{{1, 2, 3}, None}, {{"101", "167", "188", "205"},          None}}]      I get "Not a valid tick specification." Do you have any other ideas?


title: Custom FrameTicks not working

text: I would like to have a custom ticks on x-axis on my `ListPlot`, but nothing is showing, what am I doing wrong?               data = {{1, 2}, {2, -2}, {3, -1}, {4, 0}, {5, -3},      {6, -2}, {7, -1}, {8, -1}, {9, -1}, {10, 0}};          ListPlot[data,       FrameTicks -> {{"ττ", "τr", "τθ",          "\τφ", "rr", "rθ", "rφ",          "θθ", "θφ",          "φφ"}, {-5, 5}}, Frame -> True,       PlotMarkers -> {Automatic, Medium}, Axes -> False,ImageSize -> 500]      And I get ![enter image description here](http://i.stack.imgur.com/czANt.jpg)


title: Debugging graphics

text: All the examples I am seeing on internet are related to normal functions that carry out loops and assignments but I have not seen one example where I can see a graphics based program being debugged. can someone who has used debugging extensively shed some light on this please? Edit: I meant to say that like in `Manipulate`, I can see the graphics dynamically, in the same way suppose I have completed a loop once than can I see the update in graphics successively or I will have to wait for the final values to arrive. In a way can I debug programs that include `Graphics` or `Graphics3d` in them? And thanks for such warm welcome. :) Example:               fun[x_]:= Graphics[... parameters]      So, can I step into this `Graphics` inbuilt function?


title: How to define a non-standard algebra in Mathematica?

text: I want to define an algebra, where there are three elements: 0, 1 and $\infty$ and two operations, addition and multiplication defined, both commutative: $$\begin{align*} 0+0&=0\\\ 0+1&=1\\\ 0+\infty&=\infty\\\ 1+1&=1\\\ 1+\infty&=\infty\\\ \infty+\infty&=\infty\\\ 0\times0&=0\\\ 1\times0&=0\\\ 1\times1&=1\\\ 0\times\infty&=1\\\ 1\times\infty&=\infty\\\ \infty\times\infty&=\infty \end{align*}$$ I want Mathematica to simplify expressions in this system.


title: Resources for beautiful Mathematica Stylesheets

text: When the Wolfram Demonstrations were introduced and the Documentation-Center was redesigned, I remember it was the first time I thought someone had put some effort into creating a beautiful stylesheet. I don't like most of the other styles and in fact, I think _PrimaryColor_ is so ugly that I cannot believe it is included in the standard templates. On the other hand, I have seen some quite nice things when I spoke on a _Mathematica_ -day and we used a common stylesheet for the slides. That's why I wonder whether there are other styles out there which are worth sharing. **Question:** Does someone know resources where people shared their stylesheets? I'm especially interested in things one can use for talks.


title: How to see a long output expression

text: I often run into long expressions in the process of solving equations. To go forward I need to be able to eye-ball the expressions to make some substitutions or use some existing relations I know to cancel stuff out etc to reduce the expression to as small as possible so I can prove certain properties about the expressions, such as positivity, monotonicity etc. However, many times I am not able to do much because I can't even see the expression properly. Is there a way to present the expression in some rational fraction or something that would make it easy to see.. So something like this: $ \frac{F(x,y,z)}{G(x,y,z)+H(x,y,z)}+\frac{F_2(x,y,z)+G_2(x,y,z)}{G_3(x,y,z)+H_4(x,y,z)}+...\\\ $ instead of something that just spills across lines so it's hard to track what the thing looks like: $ (( x + ((f(x) +g(y)/(......\\\ ..... ))))+ ...\\\ ....\\\ (((((....\\\ ...))$ Below is an actual expression that I have:               x->-(-((2 H0D^p (-1+p) p)/(-2 delta p+2 p r-2 rho+(-1+p) p sigma^2))+(H0D^((2 delta-2   r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) H0S^(-((2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))) (2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]) (-1+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) ((F (c0-rho) (2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(2 rho σ^2)-(2 H0S^p (p-(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(-2 (delta p-p r+rho)+(-1+p) p sigma^2)-(H0S (r-rho) (-1+(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(delta-r+rho)))/(2 σ^2 ((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)-(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))+(H0D^((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) H0S^(-((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))) (2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]) (-1+(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) ((F (c0-rho) (2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(2 rho σ^2)-(2 H0S^p (p-(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(-2 (delta p-p r+rho)+(-1+p) p sigma^2)-(H0S (r-rho) (-1+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(delta-r+rho)))/(2 σ^2 (-((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))))/(H0D^2 ((H0S^(-1-(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)-(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) (H0D^((2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) H0S^((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))-H0D^((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) H0S^((2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))) ((F (-c0+rho) (2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]) (2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(4 rho σ^4)-(2 H0S^p (p-(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) (p-(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(-2 (delta p-p r+rho)+(-1+p) p sigma^2)+(H0S (r-rho) (-1+(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) (-1+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(delta-r+rho)) (-((2 H0D^p (-1+p) p)/(-2 delta p+2 p r-2 rho+(-1+p) p sigma^2))+(H0D^((2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) H0S^(-((2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))) (2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]) (-1+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) ((F (c0-rho) (2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(2 rho σ^2)-(2 H0S^p (p-(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(-2 (delta p-p r+rho)+(-1+p) p sigma^2)-(H0S (r-rho) (-1+(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(delta-r+rho)))/(2 σ^2 ((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)-(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))+(H0D^((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) H0S^(-((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))) (2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]) (-1+(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) ((F (c0-rho) (2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(2 rho σ^2)-(2 H0S^p (p-(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(-2 (delta p-p r+rho)+(-1+p) p sigma^2)-(H0S (r-rho) (-1+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(delta-r+rho)))/(2 σ^2 (-((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))))/(H0D^2 ((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)-(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))-(H0S^(-1-(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)-(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) ((H0D^((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) H0S^((2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) (2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(2 σ^2)-(H0D^((2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) H0S^((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) (2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(2 σ^2)) (delta/(delta-r+rho)-(2 H0D^(-1+p) p)/(-2 delta p+2 p r-2 rho+(-1+p) p sigma^2)+(H0D^(-1+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) H0S^(-((2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))) (2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]) ((F (c0-rho) (2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(2 rho σ^2)-(2 H0S^p (p-(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(-2 (delta p-p r+rho)+(-1+p) p sigma^2)-(H0S (r-rho) (-1+(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(delta-r+rho)))/(2 σ^2 ((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)-(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))+(H0D^(-1+(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) H0S^(-((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))) (2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]) ((F (c0-rho) (2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(2 rho σ^2)-(2 H0S^p (p-(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(-2 (delta p-p r+rho)+(-1+p) p sigma^2)-(H0S (r-rho) (-1+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(delta-r+rho)))/(2 σ^2 (-((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))) (-((2 H0S^p (p-(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) (p-(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))/(-2 delta p+2 p r-2 rho+(-1+p) p sigma^2))+1/(rho (delta-r+rho))(-((c0 F (delta-r+rho) (2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]) (2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(4 σ^4))+rho ((delta F (2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]) (2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(4 σ^4)+(r-rho) (-((F (2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]) (2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2]))/(4 σ^4))+H0S (-1+(2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)) (-1+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))))))/(H0D (-((2 delta-2 r+σ^2-Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2))+(2 delta-2 r+σ^2+Sqrt[8 rho σ^2+(-2 delta+2 r-σ^2)^2])/(2 σ^2)))))      I tried to copy as Latex and compile it but Latex is giving me something that goes off the page. I guess I can break it into many lines at random places and see what that gives me. I was wondering if there is some automatic way of accomplishing this.


title: Simplify assumes Boolean 1 and 0 in logical expressions

text: Per this chat discussion and this previous question where I encountered the strange behaviour:               Simplify[1]          ==> 1            And[0, 1]            ==> 0 && 1     Simplify[And[2, 3]]  ==> 2 && 3     Simplify[Not[0]]     ==> !0     FullSimplify[Not[0]] ==> True   (* expected !0, thanks Jens *)     Simplify[And[0, 1]]  ==> False   (* expected 0 && 1 *)     Simplify[And[1, 2]]  ==> 2       (* expected 1 && 2 *)     Simplify[Or[0, 1]]   ==> True    (* expected 0 || 1 *)      `Simplify` and `Fullsimplify` assume `0 -> False, 1 -> True` in some logical expressions. Only `Or` and `And` are affected but not `Not`. This is certainly undocumented (or underdocumented), and I would say rather inconsistent. Please decide on whether it is a bug or not. Present in versions 8 and 9 but not in version 7 (or before).


title: Method that can be used to collect the variables of a function

text: Suppose we have a function `f[x, y, z]` and we want to get all its variables `Sequence[x,y,z]`, what method can we use then? The only one that I can come up with is like this:               f[x, y, z] /. func_[vars___] -> Sequence[vars]      But it is not very elegant from my point of view. Is there any more suitable method? Thanks!


title: Non Commutative sorting in Mathematica

text: I have been trying to do some oscillator algebra in _Mathematica_ and having troubles with sorting and simplifying expressions. I am using the NCAlgebra package which helps to improve the properties of `NonCommutativeMultiply` in _Mathematica_. However I have to create a huge list of rules to replace terms using the algebra. This quickly becomes impractical since I get these enormous expressions and I have to sift through the terms to see what simplifies and add more rules. I have been wondering if there is a way to write a sorting function that would take an elementary expression and change it to a list and then permute the elements of list to sort the expression. I am fairly new to Mathematica but I would eventually like to write a small package which would allow me to these kind of manipulations. For example, I have terms like $a**b**c**a^\dagger$ where $a$, $b$, $c$, etc. commute with each other but $a**a^\dagger-a^\dagger**a =1$. So I would like to sort things such that all dagger operators are to the left and have _Mathematica_ use the fact that $a$, $b$, $c$ commute to rewrite the expressions. Right now I am assigning rules for every type of term that appears in my calculation but the number of terms has become unmanageable.


title: tricky memoization

text: Let's say I have the NDSolve example for documentation involving splitting 2nd order into set of 1st order ODEs:               NDSolve[{x'[t] == y[t], y'[t] == -x[t], x[0] == 1, y[0] == 0}, {x,      y}, {t, 0, 10}]      I need to solve my second order system like this for various reasons. My ODE is more complicated, and depends on some other parameters call them $(a,b)$, and so when I solved it as a second order system I used memoization in the form below, so that if a solution for a given parameter set had already been computed, Mathematica wouldn't redo it all again. I would like to do this, or something like it for the first order system and where NDSolve is giving the two variables $x[a,b],y[a,b]$.               x[a_,b_]:=      x[a,b] = x /.NDSolve[{eq[a,b],x[0]== init[a,b],x'[0]==dinit[a,b],x,{r, 0, 10}][[1]];


title: Are there any offline tutorials for Mathematica?

text: As can be seen from my questions, I am struggling to make Mathematica do something useful. The amount of tutorials on the Wolfram web site is a bit overwhelming, especially that I don't have too much time to read them. However, I am commuting for about 90 minutes per day, and having the Mathematica documentation (even just the one that comes with the software) in Kindle-friendly format (I'd even accept pdf) would be a great thing for me. Can I find a downloadable version of Mma docs (in pdf, or even better, in epub/mobi) anywhere?


title: Map Input A B C to MyProduct[A,B,C] (NOT to Times[A,B,C])

text: In writing my own (noncommutative) product I want to avoid typing redundant symbols like `A.B.C` or `A**B**C`, I just want to type `A B C` and have that mapped to my own `Product[A,B,C]`. (call me a purist) 1\. Is there a clever way to avoid `A B C` being mapped to `Times[A,B,C]` (besides `ClearAll[Times]`)? 2\. Is there any documentation about the inner workings of (Pre-)Parsing and `Times`?


title: Does Mathematica use the Elliptic Curve Method (ECM) in FactorInteger[]?

text: I'm not a mathematician, and I'm not even going to pretend that I understand anything of the ECM. But I know it can be a fast method for factorization. I benchmarked the factorization of $$798645312654798147285393218574111453126547981472185139328574111781$$ by Mathematica against this online applet, where the applet was 75 % faster (16 seconds versus 65 for Mathematica). Other factorizations were up to 6 times faster. Does Mathematica use ECM for factorization of certain cases? If yes, how comes performance is so different? **Additional information** We can investigate in the above problem by calling `FactorInteger[..,Automatic]` on the large number:               FactorInteger[       798645312654798147285393218574111453126547981472185139328574111781,        Automatic] // AbsoluteTiming          (* {5.647210,      {{61, 1}, {67, 1}, {74729, 1},     {2614930428035201342411278280525965452621044417207937542347, 1}}}      *)      This takes only a fraction of the time, but finds only _simple_ factors. So it seems the rest of the time Mathematic tries to factor the last big number. And in fact:               FactorInteger[2614930428035201342411278280525965452621044417207937542347] // AbsoluteTiming          (*      {43.717204,       {{97913387938680010938335707, 1}, {26706566722753457593818813677521, 1}}}     *)      _(feel free to edit tags if needed)_


title: How to solve a system of equations of the Vietnamese Mathematical Olympiad?

text: This is a system of equations of the Vietnamese Mathematical Olympiad 2013, the first day. Solve the system of equations $$\begin{cases} \sqrt{\sin^2 x + \dfrac{1}{\sin^2 x}} + \sqrt{\cos^2 y + \dfrac{1}{\cos^2 y}} = \sqrt{\dfrac{20y}{x+y}},\\\ \sqrt{\sin^2 y + \dfrac{1}{\sin^2 y}} + \sqrt{\cos^2 x + \dfrac{1}{\cos^2 x}} = \sqrt{\dfrac{20x}{x+y}}. \end{cases}$$ I tried               Reduce[{Sqrt[ Sin[x]^2 + 1/Sin[x]^2] + Sqrt[ Cos[y]^2 + 1/Cos[y]^2] ==         Sqrt[ 20 y/(x + y)],        Sqrt[ Sin[y]^2 + 1/Sin[y]^2] + Sqrt[ Cos[x]^2 + 1/Cos[x]^2] ==         Sqrt[ 20 x/(x + y)]}, {x, y}, Reals]      My computer runs more than ten minutes, but I have not received results.


title: Fitting data to an ARProcess using FindProcessParameters

text: I have 50 data points that I would like to represent as an AR(4) process. I'd like to over-plot the behaivor of the estimated process model with that of the original (raw) data before I use the model to predict 10 days into the future.               Remove[a1, a2, a3, a4, v]     processdata = {{1, 5.0}, {2, 9.0}, {3, 8.0}, {4, 10.0}, {5, 6.1}, {6,      10.4}, {7, 9.1}, {8, 11.6}, {9, 7.5}, {10, 12.1}, {11, 10.4}, {12,      13.5}, {13, 9.0}, {14, 14.1}, {15, 11.9}, {16, 15.7}, {17,      10.8}, {18, 16.4}, {19, 13.7}, {20, 18.3}, {21, 12.9}, {22,      19.0}, {23, 15.8}, {24, 21.2}, {25, 15.3}, {26, 22.1}, {27,      18.3}, {28, 24.6}, {29, 18.1}, {30, 25.8}, {31, 21.2}, {32,      28.6}, {33, 21.4}, {34, 30.0}, {35, 24.6}, {36, 33.2}, {37,      25.2}, {38, 35.0}, {39, 28.6}, {40, 38.5}, {41, 29.6}, {42,      40.7}, {43, 33.3}, {44, 44.7}, {45, 34.8}, {46, 47.4}, {47,      38.8}, {48, 52.0}, {49, 40.9}, {50, 55.2}};     plot1 = ListPlot[processdata, Joined -> True, Frame -> True,      FrameLabel -> {"Time (days)", "Temperature"}, AxesOrigin -> {0, 0},      PlotRange -> All, PlotStyle -> {Thick, Red},      PlotLabel -> "Plot 1: Raw Process Data"]      Here I use FindProcessParameters to estimate the four coefficients and the variance. Then I use these values to see how well the model matches the raw data.               params = FindProcessParameters[processdata,      ARProcess[{a1, a2, a3, a4}, v]]     a1 = params[[1, 2]];     a2 = params[[2, 2]];     a3 = params[[3, 2]];     a4 = params[[4, 2]];     v = params[[5, 2]];     sigma = Sqrt[v];     y = Table[0, {50}];     y[[1]] = 5.0;     y[[2]] = 9.0;     y[[3]] = 8.0;     y[[4]] = 10.0;     dist = NormalDistribution[0, sigma];     t = 4;     Do[{     t = t + 1,     If[t > 50, Break[]],     whitenoise = RandomVariate[dist],     y[[t]] = whitenoise/(     1 - (a1*y[[t - 1]]) - (a2*y[[t - 2]]) - (a3*y[[t - 3]]) - (a4*        y[[t - 4]]))},     {100}];     modeldata = Transpose[{Range[Length[y]], y}];     plot2 = ListPlot[modeldata, Joined -> True, Frame -> True,      FrameLabel -> {"Time (days)", "Temperature"},      AxesOrigin -> {0, -40}, PlotRange -> All,      PlotStyle -> {Thin, Black}, PlotLabel -> "Plot 2: Model Data"];     plot3 = Show[plot1, plot2,      PlotLabel -> "Plot 3: Raw Process Data(Red) vs AR Model(Black)",      AxesOrigin -> {0, -80}]      The above model performance is not very good. Am I doing something wrong here ? I then tried specifying MaximumLikelihood as the process estimator in the hope of getting better parameter estimates but get a FindArgMax error message which I also don't understand.               Remove[a1, a2, a3, a4, v]     params = FindProcessParameters[processdata,      ARProcess[{a1, a2, a3, a4}, v],      ProcessEstimator -> "MaximumLikelihood"]      FindArgMax::nrnum: "The function value {-Log[PDF[ARProcess[{0.746727,0.814726, . . . I'm not a Mathematica power user or time-series expert so relatively gentle answers would be much appreciated. Thanks. Edit 1: Now that I have more than 10 reputation points (I'm a first time stackexchange user) I'm now able to show a plot of the AR model performance. ![plot3](http://i.stack.imgur.com/vVNXF.png) Since the AR model has a probabilistic component (the white noise), a plot that you may generate will in all likelihood look different than above, nonethless I would expect the fit to still be poor. The question is why ?


title: How to test for Indeterminate values?

text: I need something like this               a = 101010/0;     If[a == ComplexInfinity, True, False]      But if I use `ToString`, I get what I want.               a = 101010/0;     If[ToString[a] == "ComplexInfinity", True, False]      Does someone know a better way to do this?, I can't belive that transforming to a string is the only way.


title: Sorting String Date in Asceding Order

text: How do I order string dates (month/year format) in ascending order, e.g., from 11/2011 to 07/2012: > 02/2012 > > 04/2012 > > 07/2011 > > 08/2013 > > 08/2011


title: Label both sides in BarChart

text: I have labeled the name(A,B,C) of each row on the left and value of each item , is there any way to put the total number(6,7,5) of each row on the right side without changing other labels?               BarChart[{{1, 2, 3}, {2, 4, 1}, {3, 1, 1}}, BarOrigin -> Left,       ChartLayout -> "Stacked", BarSpacing -> 0.5,       ChartLabels -> {Placed[{"A", "B", "C"}, Before], None},       LabelingFunction -> (Placed[#1, Center] &)]      ![enter image description here](http://i.stack.imgur.com/Zb8jN.png)


title: Fix the size of vertices and arrow in graphs

text: I defined an option to draw nicely the graph. But I have a problem with the different size obtained. For example, the layout of the first graph is what I want to have for all other graphs I will define later. But for smaller graphs, their vertices look biger and biger. It seems that there is a way to control this using `Scale`, but I don't want to adjust this for each graph I will have. Is there a way to specify the size of vertices and edges once for all?               ef2[el_, ___] := {RGBColor[0, 0, 1], Thickness[1/200], Arrowheads[1/16], Arrow[el, 0.2]}          options = Sequence[VertexStyle -> Black, VertexSize -> 1/2,     VertexLabels -> Placed["Name", {Center, Center}], VertexLabelStyle -> Directive[16, White],      GraphLayout -> "CircularEmbedding", EdgeShapeFunction -> ef2, ImageSize -> 400];          g = Graph[{1 -> 2, 2 -> 7, 8 -> 7, 3 -> 4, 5 -> 6, 5 -> 9}, options]     g = Graph[{1 -> 2, 2 -> 7, 3 -> 7, 3 -> 1, 5 -> 6, 5 -> 9}, options]     g = Graph[{1 -> 2, 2 -> 7, 3 -> 7}, options]     g = Graph[{1 -> 2}, options]      ![enter image description here](http://i.stack.imgur.com/XBkCE.png) ![enter image description here](http://i.stack.imgur.com/rAh0g.png) ![enter image description here](http://i.stack.imgur.com/mtlCL.png) ![enter image description here](http://i.stack.imgur.com/GaC6z.png)


title: Can Mathematica 9 peacefully coexist with Mathematica 8 on Windows?

text: I am running Windows XP Professional (Service Pack 3). I am a graduate student, and my institution has a license for _Mathematica for Students_. Back when Mathematica 8 was released, I was worried that (for whatever reason) I would not like it or that it would not run properly on Windows XP Professional, which is quite old by Windows standards. So, I tried to install Mathematica 8 in addition to Mathematica 7 which was also on the same computer. As it turned out, this worked fine; Mathematica 7 and Mathematica 8 simply peacefully coexist in different installation directories (`$InstallationDirectory` gives `"C:\\Program Files\\Wolfram Research\\Mathematica\\7.0"` in Mathematica 7, and `$InstallationDirectory` gives `"C:\\Program Files\\Wolfram Research\\Mathematica\\8.0"` in Mathematica 8; these are the default installation directories). Now Mathematica 9 for Students is out and offered by my institution, and I am eager to try it because of the `PlotLegends` feature that has supposedly been much improved. But I would be very, very sad if installing Mathematica 9 somehow corrupted my existing Mathematica 8 installation, because there is a chance that my computer will be too slow to handle Mathematica 9, especially its supposedly "beefed up" front end, and I will need to revert to 8. Do you have any experience with installing version 9 on the same computer as version 8? This previous question by another user discusses problems with installing a trial version of 9 next to genuine 8, which was apparently due to a bug. I am just curious if you have experience with installing genuine 9 next to genuine 8, and whether there is likely to be any overlap between system files/directories used by these two versions. (I'm really only interested in version 9 because of the new `PlotLegends`, and that is the only reason I would like to try it. I would like to use Mathematica to generate publication-quality plots, but I can't really do this without some reasonably easy-to-use and easily reproducible `PlotLegends`.)


title: Reverse after ImageData?

text: Why should we do a `Reverse` on the image data after an `ImageTake` ? For example:               OIcut = ImageTake[OIBW, {80, 160}, {90, 170}]      ![](http://i.stack.imgur.com/7tKLC.png)               OIrev = Reverse[ImageData[OIcut]];     ListDensityPlot[OIrev, ColorFunction -> GrayLevel]      ![](http://i.stack.imgur.com/tI98g.png) I see the image gets a little smoother and probably brighter. Any idea why this happens after an `ImageTake`?


title: Thread over list in different levels

text: I have these two lists, both with the same length in the first dimension:               l1={{a1,a2},{b1,b2},{c1,c2}};     l2={{{1,2,3},{4,5,6}},{{10,11,12},{13,14,15},{16,17,18}},{{19,20,21}}};      And I need mix both to get into this result:               {{a1,a2,1,2,3},{a1,a2,4,5,6},{b1,b2,10,11,12},{b1,b2,13,14,15},     {b1,b2,16,17,18},{c1,c2,19,20,21}}      I have done this code that do the job:               Flatten[MapThread[Function[{a,b},Join[a,#]&/@b][#1,#2]&,{l1,l2}],1]      But I think it could be simpler. Some clue?


title: How to embed "Share content" button into a CDF?

text: I want to have a button present in a CDF that, when pressed, shares some content material e.g. via Facebook. Is it possible or would the restrictions of the CDF format prevent anything from happening? Can it be done outside of CDF then? I don't have the slightest clue how to solve this... built-in? JLink? .NET/Link? My ridiculously simple example code is this:               data = {"title", "URL", "summary", "image"};     Button["Share", shareOverFacebook[data]]


title: PlotLegends -> "Expressions" not working when Plot given one function

text: I don't get a legend when I use the option `PlotLegends -> "Expressions"` when the first argument to Plot is a single function. It works OK when I give `Plot` a list of functions. Test cases:               Plot[Sin[x], {x, 0, 2 Pi}, PlotLegends -> "Expressions"]     ContourPlot[x^2 + y^2 == 1, {x, -2, 2}, {y, -2, 2}, PlotLegends -> "Expressions"]      ![enter image description here](http://i.stack.imgur.com/CV7oF.png) **===================================** ![enter image description here](http://i.stack.imgur.com/tdpBY.png)


title: List of squareful, cubeful, etc. numbers

text: The following works:               list = {6, 7, 8, 9};     FreeQ2[n_Integer] := FreeQ[Last@Transpose@FactorInteger[n], _?(# >= 2 &)]     FreeQ3[n_Integer] := FreeQ[Last@Transpose@FactorInteger[n], _?(# >= 3 &)]     FreeQ4[n_Integer] := FreeQ[Last@Transpose@FactorInteger[n], _?(# >= 4 &)]     a = FreeQ2 /@ list /. {True -> 1, False -> 0};     b = FreeQ3 /@ list /. {True -> 2, False -> 0};     c = FreeQ4 /@ list /. {True -> 3, False -> 0};     Transpose[{a, b, c}] /. {{1, 2, 3} -> 1, {0, 2, 3} -> 2, {0, 0, 3} -> 3}      but of course is very inefficient coding. I was wondering what approach I should really be taking here.


title: How to use ForAll in Reduce

text: I was wondering: how does one use the `ForAll` function in `Reduce`? In particular, I am looking for the set $\\{w\in \mathbb{R}^2 | \forall x \in \mathbb{R}^2 : \left<w,x\right> \leq f(x)\\},$ where $\left<,\right> $ is the inner product and $f: \mathbb{R}^2\rightarrow\mathbb{R}^1$. Thank you!


title: Finding minimal region with padding and linear map to circle

text: Suppose I have n ordered points. I would like to find a simple region that contains all the points and is close to the smallest region that contains the points except it is smooth and has some "padding"(as if the points were disks with some radius). One way to to think about it is if the points were fixed "marbles" and one were to use shrink wrap around them all. It would sort of be the type of region I'm looking for(although I sort of want it to be "locally" convex). Another way to think about it is a sort of concave hull but with some control parameter that changes how convex it is locally. Take two disks A and B some distance apart. The convexity parameter would control how much the region "dipped" in the middle between the points. On one hand it might look like an ellipse and on the other it might look like a figure 8. The ability to control "how much" is what I'm looking for I would then like to have a linear map from the circle(or convex hull) to this curve so I can "morph" the circle into this region. For example, with such an algorithm I would create a slider and on one end it will show the convex hull or circle and as the slider moves to the other side the region starts to "shrink" around the points reducing the area but always containing the "disks" and staying rather smooth and simple. Since the convex hull should contain this "minimal" region I'm looking for it should be easy to morph between them with just linear interpolation and still have a valid region(not minimal but smooth and containing the disks).


title: ReplaceAll inside an Iterator

text: I'd like to apply a set of rules to an expression defining the iterators of the table, like this:               ExampleParameters = {x0 -> 0, xp -> 1}     Table[x,{x, x0 - 3*xp, x0 + 3*xp, xp} /. ExampleParameters]      The kernel returns the following error:               Table::itform: Argument {x, x0 - 3 xp, x0 + 3 xp, xp} /. ExampleParameters      at position 2 does not have the correct form for an iterator.      Any ideas on how to generalize the table expression? Explicitly using               Table[x,ReplaceAll{x, x0-3*xp, x0+3*xp, xp}, ExampleParameters]]       leads to the same error.


title: Numerical-Symbolical Integration (Calculus)

text: I created a simple numeric-symbolic integration. Here you can use symbolical and numerical techniques at the same time. You can also interpolate numerical integrals. The problem with my function is the use of `TimeConstrained` for testing if the integral can be done fully symbolically. This wastes time; without it the result is much much faster. How can it be optimized? Maybe there is some other implementation like this I haven't found? Note: It can easily be extended to `Sum`-s, just exchange `Integrate` for `Sum` :)               Options@NSIntegrate = {         InterpolationVariable -> {}     };          (* Linearity *)     NSIntegrate[f_ + g__, s_, options___] := NSIntegrate[f, s, options] + NSIntegrate[+g, s, options]     NSIntegrate[α_*f_, {x_, limits__}, options___] /; FreeQ[α, x] := α*NSIntegrate[f, {x, limits}, options]          (* Constant Function *)     NSIntegrate[α_, {x_, limits__}, options___] /; FreeQ[α, x] \[And] α =!= 1 := α*NSIntegrate[1, {x, limits}, options]          (* Exponentials *)     NSIntegrate[α_^(f_+g__), {x_, limits__}, options___] /; FreeQ[f, x] := α^f*NSIntegrate[α^g, {x, limits}, options]     NSIntegrate[α_^(f_+g__)*h_, {x_, limits__}, options___] /; FreeQ[f, x] := α^f*NSIntegrate[α^g*h, {x, limits}, options]          (* Some Basic Integrals - Polynomials *)     NSIntegrate[1, {x_, a_, b_}, ___] := b - a     NSIntegrate[x_, {x_, a_, b_}, ___] := (b^2 - a^2)/2     NSIntegrate[x_^-1, {x_, a_, b_}, ___] /; If[NumericQ@a \[And] NumericQ@b, Sign@a === Sign@b, True] \[And] a =!= b := Log[b/a]     NSIntegrate[x_^n_, {x_, a_, b_}, ___] /; n =!= -1 := (b^(n+1) - a^(n+1))/(n + 1)          (* Some Basic Integrals - Exponentials *)     NSIntegrate[α_^(A_*x_), {x_, a_, b_}, ___] /; α =!= 0 \[And] α =!= 1 := (α^(A*b) - α^(A*a))/(A*Log@α)     NSIntegrate[α_^x_, {x_, a_, b_}, ___] /; α =!= 0 \[And] α =!= 1 := (α^b - α^a)/Log@α     NSIntegrate[0^x_, s__, ___] := 0          (* Scaling and offset *)     NSIntegrate[f_[α_*x_ + β_, args___], {x_, a_, b_}, options___] /; (And @@ (FreeQ[#, x] & /@ Flatten@{args, α, β})) :=          NSIntegrate[f[x, args]/α, {x, a*α + β, b*α + β}, options]     NSIntegrate[f_[α_*x_, args___], {x_, a_, b_}, options___] /; (And @@ (FreeQ[#, x] & /@ Flatten@{args, α})) :=          NSIntegrate[f[x, args]/α, {x, a*α, b*α}, options]     NSIntegrate[f_[x_ + β_, args___], {x_, a_, b_}, options___] /; (And @@ (FreeQ[#, x] & /@ Flatten@{args, β})) :=      NSIntegrate[f[x, args], {x, a + β, b + β}, options]          (* Interpolation *)     NSIntegrate[f_, {x_, a_, b_}, options1___, InterpolationVariable -> varRange_List, options2___] /; Length@varRange != 0 := Module[{         vars, range = varRange, table         },         If[Depth@varRange == 2, vars = varRange[[{1}]]; range = List@range, vars = varRange[[All, 1]]];              table = Table[{vars, NSIntegrate[f, {x, a, b}, options1, options2]}, ##1] & @@ range;         InterpolatingPolynomial[table, vars] /. s_Real :> Chop[s, 10^-6] // Expand     ]          (* If not in database, use NIntegrate *)     NSIntegrate[f_, s:{x_, a_, b_}, opts___] /; ExpandAll@f =!= f := NSIntegrate[ExpandAll@f, s, opts]     NSIntegrate[f_, s:{x_, a_?NumericQ, b_?NumericQ}, opts___] := NIntegrate[f, s, opts]      *Usage:               NSIntegrate[Cos[a*x], {x, 0, 1}, InterpolationVariable -> {a, 1, 5, 1/2}]      `InterpolationVariable` work just like in a `Table`. In case or more than 1 interpolation use in the form `{{a, 1, 5}, {b, 1, 10, 0.3}}` ** Added `(* Scaling and offset *)` section.


title: Exporting a CDF to HTML

text: I'm using _Mathematica for Students_ on a Mac. How do I export a CDF document to HTML? According to the Wolfram website I should click on `File > Deploy > Export as HTML`. But I do not see the `Deploy` contextual menu item in my File menu. Has it been moved on the Mac version?


title: How to solve a problem in relative motion?

text: I have a project due tomorrow that I have been struggling with for a month. I am utterly stumped, any help would be appreciated. The problem is: > There is a ferris wheel, 30m in radius, set 80m above water level. There is > a boat 150m away from the center of the ferris wheel, and is moving toward > the wheel at 10m/s. The wheel is turning at 0.2rad/s. Assuming no initial > velocity and no friction, write a Mathematica program that will give the > range for a person to successfully jump off the wheel and land in a boat, > which is 1m in length. I solved this analytically, but the assignment requires recursive programming. What I want to do is output the range of X coordinates when the person lands in the water and the corresponding location of the boat, and if they match, output the time value; otherwise go to the next increment. Here's what I have:               Clear[n, h];     Vx[0] = 0; Pyi[0] = 110; h = 300; t[0] = 0; Vyf[0] = 0;     t[n_] := t[n] = t[n - 1] + h     Vx[n_] := Vx[n] = 6 Cos[-0.2 t[n]]     Vy[n_] := Vy[n] = 6 Sin[-0.2 t[n]]     Pxi[n_] := Pxi[n] = 30 Cos[0.5 Pi - 0.2 t[n]]     Pyi[n_] := Pyi[n] = 80 + 30 Sin[0.5 Pi - 0.2 t[n]]     Pyf[n_] := Pyf[n] = Pyi[n - 1] + Vy[n] h - 4.9 h^2     Pxf[n_] := Pxf[n] = Pxi[n - 1] + Vx[n] h     Sxf[n_] := Sxf[n] = 150 - 10 t[n]     Do[If[Pxf[n] == Sxf[n], Print[t[n]*0.2], " "], {n, 0, 10}]      Execution yields no output. What should I do? For reference:               t - time     Vx - initial x velocity (yielded from Vi Cos[theta])     Vy - initial y velocity     Pxi - location at which the person leaves the wheel (x)     Pyi - the same as above, y direction     Pyf - final location, y direction (should equal 0, don't know if I need to set that)     Pxf - final location, x direction     Sxf - location of boat      I executed `t[14]` and got `0.0014`. I'm not sure why. EDIT: I've fixed the `Do[If[Pxf[n] == Sxf[n], Print[t[n]*0.2], " "], {n, 0, 10}]` to `Do[If[Pxf[n] - Sxf[n] < 0.1, Print[t[n]*0.2], " "], {n, 0, 20}]`. It produces an output now, but the answer is wrong (does not output the range of 9.6 to 9.91). I think I'm having two problems: -I don't know when to put `[n-1]` and when to just use `t[n]` -Since the velocity equations for initial velocity and the free-fall velocity are different, I don't get how to tie them in. Here is my new code:               Clear[Vx, Vy, Pxi, Pyi, n, h, Sxf];     Vx[0] = 0; Pyi[0] = 110; h = 0.001; t[0] = 0; Vyf[0] = 0;     t[n_] := t[n] = n h     Vx[n_] := Vx[n] = 6 Cos[-0.2 t[n]]     Vy[n_] := Vy[n] = 6 Sin[-0.2 t[n]]     Pxi[n_] := Pxi[n] = 30 Cos[0.5 Pi - 0.2 t[n]]     Pyi[n_] := Pyi[n] = 80 + 30 Sin[0.5 Pi - 0.2 t[n]]     Pyf[n_] := Pyf[n] = Pyi[n - 1] + Vy[n] h - 4.9 h^2     Pxf[n_] := Pxf[n] = Pxi[n - 1] + Vx[n] h     Sxf[n_] := Sxf[n] = 150 - 10 t[n]          Do[If[Pxf[n] - Sxf[n] < 0.1, Print[t[n]*0.2], " "], {n, 0, 20}]


title: MatchQ-ing Associations (MMA 10)

text: Consider               {x->1}      which has `FullForm`               List[Rule[x, 1]]      and, therefore,               MatchQ[{x->1}, List[___Rule]]      produces `True`. Now consider               <|x->1|>      which has `FullForm`               Association[Rule[x, 1]]      but               MatchQ[<|x->1|>, Association[___Rule]]      produces `False` In fact,               MatchQ[<|x->1|>, Association[___]]      produces `False`. Any ideas? (I'm trying to make some MathLink xxxxxxxx WSTP functions for serializing C structs as Associations, and this lacuna is messing me up).


title: why head Association cannot be replaced by head List

text: Consider replacing head of List by head Association:               {a -> x, b -> y, c -> z} /. List -> Association     (*<|a -> x, b -> y, c -> z|>*)      The opposite cannot be performed:               <|a -> x, b -> y, c -> z|> /. Association -> List     (*<|a -> x, b -> y, c -> z|>*)      Any idea why?


title: Plotting multivalued function using ParametricPlot

text: I'm having a bit of trouble making a ParametricPlot from two curves. I defined two functions p and g as:               Clear[p, g];     g[t_] := t*(1000 - t)/(500^2);     solns[t_] :=      Solve[((1 + 1*(.33)*.05*p^2 +            11*.33*(.05^2)*.66*p^4)/(1 + (.33)*.05*            p^2 + .33*(.05^2)*.66*p^4 + .008*.33*.33*(.05^3)*.66*p^6))/       g[t] - p == 0, p];     p[t_] := p /. solns[t];      Notice that the function $p$ can take on 1-3 values for certain t:                 Plot[{g[t], p[t]}, {t, 0, 1000}]      However, using the command                 ParametricPlot[{g[t], p[t]}, {t, 0, 1000}]      gives some random curve on an x-axis from 3-9 that doesn't have these values. The x-axis should also be going from 0 to 1 for $0\leq t\leq 1000$ because the x-component is defined by $g$. Could anybody tell me what's going on here, and show me how to make an actual parametric plot? Thanks in advance.


title: WolframAlpha queries unevaluated despite internet connectivity?

text: `WolframAlpha` is a built-in symbol in MMA8, yet expressions with `WolframAlpha` and the equal sign operator remains unevaluated despite the internet connection.               WolframAlpha["2+1"]          (* WolframAlpha["2+1"] *)           = heart disease risk 50yo male          (* AlphaIntegration`ExtrusionEvaluate["heart disease risk 50yo male", TextForm] *)           ?AlphaIntegration          (* Information::notfound: Symbol AlphaIntegration not found. >> *)      ?


title: Problem with Fourier and InverseFourier function

text: I have the following code               Image[img, ImageSize -> 300]     data = ImageData[img];     fdct = Fourier[data]     tdata = InverseFourier[fdct];     Image[tdata]      but it seems to **fail when doing the inverseFourier function**. The error I get is:               Image::imgarray: The specified argument {{{1. -2.0236*10^-17 I,1. -9.36654*10^-17 I,1. -3.45228*10^-17 I},<<49>>,<<330>>},{<<1>>},<<47>>,{{1. +4.61893*10^-17 I,<<19>> +<<24>> I,1. +7.44929*10^-17 I},<<49>>,<<330>>},<<330>>} should be an array of rank 2 or 3 with machine-sized numbers. >>      I'm actually not sure what I'm doing wrong as I've checked the "discrete fourier transforms" (http://reference.wolfram.com/mathematica/tutorial/FourierTransforms.html) and the output of fourier was just used in the inverseFourier to get the inverse... Any ideas what is wrong here?


title: How can I export numerical data in a calculation-favorable format?

text: I am exporting some data into the txt file but since the values exported to this txt file expresses 10^6 to be *^6, I cannot use these numbers in calculations in other programs.. For instance, when I do,                AA= {-292., -5., -9036., -1.162*10^6, -1.555*10^6, \          -1.85*10^6, -2.146*10^6, -2.401*10^6, -2.736*10^6, \          -2.91*10^6}      Export["C:/data output1.txt", AA]      May I ask how I can deal with this problem..? Thank you.


title: Change Header By Page

text: I would like to display the following header on of each page of an exported pdf                                                         specificTitle XXX      XXX should be the page number while **specificTitle** should be a custom title that I would like to be able to set in the Front End Cells. Currently I am using the following code to the add the Page header. Unfortunately I can't seem to figure out a way to set the title while in the notebook front end. EDIT: **To help clarify I am looking to not necessarily have separate titles on each page, but have a way to set different titles for each group of pages.**               SetOptions[EvaluationNotebook[],       PrintingOptions -> {"FirstPageHeader" -> True},       PrintingStartingPageNumber -> 1,       PageHeaders -> {         {Cell[TextData[{CounterBox["Page"]}], "PageNumber"], None, None},         {None, None, Cell[TextData[{CounterBox["Page"]}], "PageNumber"]}         },       PageFooters -> {{None, None, None}, {None, None, None}}       ];      Originally I planed to use Dynamic cell inside the PageHeaders like so               Cell[BoxData[       DynamicBox[ToBoxes[$CellContext`a, StandardForm]]], "Output"]      And then I planned to set `a` at different points throughout the notebook. It becomes clear if you render this that each page of the pdf isn't rendered separately but instead the entire notebook is rendered(and executed) then the notebook is converted to a pdf. This makes sense but makes my current approach impractical.


title: Exporting data to a new excel sheet of a pre-existing excel file

text: m = Table[i - j, {i, 5}, {j, 6}]     n = Table[i - j, {i, 3}, {j, 7}]     o = Table[i^j, {i, 3}, {j, 7}]     Export["mfile2.xls", {"m Data" -> Transpose[m],"n Data" -> Transpose[n]}]      The above code creates a spreadsheet with two sheets named "m-data" and "n-data". Now I would like to be able to add more data to the existing spreadsheet. But when I do this:               Export["mfile2.xls", {"o Data" -> Transpose[o]}]      The earlier data is deleted and now my `mfile2.xls` just has the one sheet names "o-data" containing o-data. Is it possible for me to `Export` data into some particular existing sheet and maybe even a specific cell of some pre-existing excel file and/or maybe get MMA to create a new sheet in addition to the existing ones.


title: Solving for variables that satisfy an equation

text: I have the following               p[c1_, c2_, w_] := Exp[(-2*ω/(σ^2))*(c2^2 + ω^2*c1^2)]*                        Exp[(-1/(2*Σ))*(w - α*c2 - β*c1)^2]          SolveAlways[-D[c2*p[c1, c2, w], c1] +                   D[((2*ω)*c2 + ((ω)^2)*c1)*p[c1, c2, w], c2] +                  (1/2)*(σ^2)*D[p[c1, c2, w], {c2, 2}] -                  D[(c2*(1 - 2*Sqrt[3]) - c1*(Sqrt[3]*ω))*p[c1, c2, w], w] +                  (3/2)*((σ/ω)^2)*D[p[c1, c2, w], {w, 2}] == 0, {c1, c2, w, σ, ω}]      I am trying to solve for any `α, β, Σ` (in terms of `c1, c2, w, σ, ω`) that satisfies the previous equation. However, nothing results.


title: Rectangular output for ListContourPlot

text: The Function ListContourPlot generates by default an output which has a square size. I would like to produce a rectangular output for example {1000,100}. ImageSize doesn't work because it shapes only the frame (the plot still has size {100,100}). Thx, rainer