title: Domain Coloring

text: My next project I'd like to start working on is Domain Coloring. I am aware of the beautiful discussion at: How can I generate this "domain coloring" plot? And I am studying it. However, a lot of the articles on domain coloring refer back to Hans Lundmark's page at: http://www.mai.liu.se/~halun/complex/domain_coloring-unicode.html So, I would like to begin my work by using Mathematica to draw these three images based on Hans' notes. I'd appreciate if anyone can provide some code that will produce these images, as I could use it to start my study of the rest of Hans' page. ![arg](http://i.stack.imgur.com/FuqMb.jpg) ![abs](http://i.stack.imgur.com/9S0I6.jpg) ![blend](http://i.stack.imgur.com/8cqhp.png) A very small adjustment. Still learning.               g[{f_, cf_}] :=        DensityPlot[f, {x, -1, 1}, {y, -1, 1}, PlotPoints -> 51,         ColorFunction -> cf, Frame -> False];          g /@ {{Arg[-(x + I y)], "SolarColors"},       {Mod[Log[2, Abs[x + I y]], 1], GrayLevel}}          ImageMultiply @@ %      ![scheme-blend-1](http://i.stack.imgur.com/115CH.png) Not sure where to put my current question, so I'll update here. Just came back to visit and discovered some wonderful answers at the bottom of this list. I do understand the opening code:               f[z_] := (z + 2)^2*(z - 1 - 2 I)*(z + I)          paint[z_] :=       Module[{x = Re[z], y = Im[z]},        color = Blend[{Black, Red, Orange, Yellow},          Rescale[ArcTan[-x, -y], {-Pi, Pi}]];       shade = Mod[Log[2, Abs[x + I y]], 1];       Darker[color, shade/4]]      But then I encounter difficulty with the following code:               ParametricPlot[{x, y}, {x, -3, 3}, {y, -3, 3},       ColorFunctionScaling -> False,       ColorFunction -> Function[{x, y}, paint[f[x + y I]]], Frame -> False,       Axes -> False, MaxRecursion -> 1, PlotPoints -> 50, Mesh -> 400,       PlotRangePadding -> 0, MeshStyle -> None, ImageSize -> 300]      I'm good with the first few lines. Looks like ParametricPlot is plotting points, where x and y both range from -3 to 3 (correct me if I am wrong). I also understand the ColorFunctionScaling and the ColorFunction lines. I understand Axes, PlotRangePadding, MeshStyle, and ImageSize. Where I am having trouble is with what PlotPoints->50 and Mesh->400 are doing. First of all, my image size is 300. What does PlotPoints->50 mean? Does that mean it will sample and array of 50x50 points out of 300x300 and scale the results to fit in the domain [-3,3]x[-3,3]? My next question is, then those points get colored? And if so, how are the remainder of the points in the image colored? For example, I tried:               Table[ParametricPlot[{x, y}, {x, -3, 3}, {y, -3, 3},        ColorFunctionScaling -> False,        ColorFunction -> Function[{x, y}, paint[f[x + y I]]],        PlotPoints -> n, MeshStyle -> None], {n, 10, 50, 10}]      And the images got a little sharper as the PointPlots->n increased. Here's another question. What does Mesh->400 do in this situation. For example, I tried lowering the mesh number:               ParametricPlot[{x, y}, {x, -3, 3}, {y, -3, 3},       ColorFunctionScaling -> False,       ColorFunction -> Function[{x, y}, paint[f[x + y I]]], Frame -> False,       Axes -> False, MaxRecursion -> 1, PlotPoints -> 50, Mesh -> 100,       PlotRangePadding -> 0, MeshStyle -> None, ImageSize -> 300]      And was completely surprised that it had an effect on the image, particularly when MeshStyle->None. Here's the image I get: ![today](http://i.stack.imgur.com/4jqEj.png) Why does setting Mesh->100 decrease the sharpness of the image? One final question I have regards adding the mesh lines. Simon suggested   For the mesh you could do something like Mesh->{Range[-5,5],Range[-5,5]}, MeshStyle->Opacity[0.5], MeshFunctions->{(Re@f[#1+I #2]&),(Im@f[#1+I #2]&)} and cormullion added them to produce a beautiful result, but I tried this:               ParametricPlot[{x, y}, {x, -3, 3}, {y, -3, 3},       ColorFunctionScaling -> False,       ColorFunction -> Function[{x, y}, paint[f[x + y I]]], Frame -> False,       Axes -> False, MaxRecursion -> 1, PlotPoints -> 50,       Mesh -> {Range[-5, 5], Range[-5, 5]}, PlotRangePadding -> 0,       MeshStyle -> Opacity[0.5],       MeshFunctions -> {(Re@f[#1 + I #2] &), (Im@f[#1 + I #2] &)},       ImageSize -> 300]      And got this resulting image. ![today2](http://i.stack.imgur.com/zamAO.png) So I am clearly missing something. Maybe someone could post the code that gives cormullion's last image? OK, just purchased and installed Presentations package. Tried this:               With[{f = Function[z, (z + 2)^2 (z - 1 - 2 I) (z + I)],        zmin = -2 - 2 I, zmax = 2 + 2 I,        colorFunction = Function[arg, HotColor[Rescale[arg, {-Pi, Pi}]]],        imgSize = 400},       Draw2D[{ComplexDensityDraw[Arg[f[z]], {z, zmin, zmax},          ColorFunction -> colorFunction, ColorFunctionScaling -> False,          Mesh -> 50, MeshFunctions -> {Function[{x, y}, Abs[f[x + I y]]]},          PlotPoints -> {50, 50}]}, Frame -> True, FrameLabel -> {Re, Im},        PlotLabel -> Row[{"Arg coloring and Abs mesh of ", f[z]}],        RotateLabel -> False, BaseStyle -> 12, ImageSize -> imgSize]]      But got this colorless image. ![today3](http://i.stack.imgur.com/xSlX8.png) Any thoughts on how to fix this?


title: How to replace Do loops by Inner

text: I need to replace `Do` loops by something else because it takes forever with big programs. I have been hinted towards `Inner`, but even though I tried, I did not manage to get what I need. Here's a toy example of my actual problem: Input:               u = {{u1a, u1b}, {u2a, u2b}, {u3a, u3b}, {u4a, u4b}};     v = {{v1a, v1b}, {v2a, v2b}, {v3a, v3b}, {v4a, v4b}};     f = {f1, f2, f3, f4};      The output I am looking for:               d = {{u1a*v1a*f1 + u2a*v2a*f2 + u3a*v3a*f3 +u4a*v4a*f4},         {u1b*v1b*f1 + u2b*v2b*f2 + u3b*v3b*f3 + u4b*v4b*f4}}      It is important not to have any loop constructs; only `Inner`, `Table`, etc. which are generally faster than loops


title: Substitution to write out powers of expressions

text: I am looking for a substitution command which will write out powers of expressions like this: $$\frac{a ~b^3~ c}{d~ e^{3/2}~ f^2}\to \frac{a ~b~b~b~ c}{d~ e^{1/2}~ e^{1/2}~ e^{1/2}~ f~f}$$ mathematica code to experiment with:               (a b^3 c)/(d e^(3/2) f^2)      Please note, this is needed to carry out substitutions on very large expressions, so that a `ComplexityFunction` is not an option since a `Simplify` will take forever to evaluate. **EDIT** I want to do this since I plan to apply substitutions for expressions like $$\frac{a b}{e^{1/2}}\to q ~~~\text{ and } ~~~\frac{b}{e^{1/2}f}\to p$$ which do not get recognized while all the terms are cluttered into one heap. **EDIT2** Maybe, as some point to start with, I should ask how to make mathematica take some literate input without performing any kind of simplification to it. Such that an input $b+b$ would still display as $b+b$ instead of the automatic $2b$? Is this possible?


title: How to deal with zero in NDSolve in mathematica?

text: I would like to solve the following ODEs $$\begin{cases} x'(t)&=y\\\ y'(t)&=-y(t)/t-e^{x(t)},\\\ x(0)&=1,\\\y(0)&=0, \end{cases}$$ ### (EDIT : The second equation _used_ to be $y'(t) = -x(t)/t - e^{x(t)}$). with the following code:               NDSolve[{       {x'[t] == y[t], y'[t] == -y[t]/t - Exp[x[t]]},        {x[0] == 1, y[0] == 0}}       ,       {x, y}, {t, 0, 1}]       I get the warning:               Power::infy: "Infinite expression 1/0. encountered."      How do I fix it? Note that, in some cases, a "small" change of the initial values will make a "large" change in in the solution, so substituting $0$ with a very small number, say $10^{-100}$ is not "good" enough. Are there other ways to fix this?


title: Specifying coordinates for Inset on a LogPlot

text: If I use `Epilog->Inset` within a `Plot`, the coordinates specified within that `Inset` match those of the plot's axis and scale:               Plot[y = 2 x, {x, 0, 5}, Epilog -> Inset["Text", {3, 3}]]      ![Plot Epilog Inset](http://i.imgur.com/0pKPcAO.png) Note that "Text" is placed at x=3, y=3. Different thing happens for when `Inset` is used within `LogPlot`:               LogPlot[y = x^x, {x, 0, 5}, Epilog -> Inset["Text", {3, 3}]]      ![LogPlot Epilog Inset](http://i.imgur.com/nt4vqNv.png) The coordinates are still (3,3) but "Text" is positioned at what appears to be (3,20) with respect to the on-axis coordinates. What is it about and how do I counter it? Thanks in advance, r.


title: Using PutAppend to write large data files

text: I have a loop which computes a table, `tab`, of results at each iteration. This table is usually very large and I would like to use `PutAppend`or anything of the sort to save the data in a file and therefore saving memory. An example would look like the following:               Put["test.csv"];          Do[tab=RandomReal[{0,1},10];PutAppend[tab, "test.csv"],{5}]      When I import the data in `test.csv` for later use I do this via `data=Flatten[Import[".../test.csv","Data"],1]`. However, the list `data` is not ready to use because typical elements look e.g. like               In[45]:= data[[1]]          Out[45]= "{0.3105121460958056"          In[43]:= data[[2]]          Out[43]= 0.0657094          In[44]:= data[[4]]          Out[44]= " "      Which is a mixture of strings and reals. So my question is: how can I append the table `tab` at each iteration of the loop to a file which later is ready to use as a list of rank two of reals? Thanks for your help.


title: How to set a function as a parameter?

text: In case I want to know whether a given function $f(t)$ have some property, I tried to write something like this:               IsSuppFun[f_[t_]] := Resolve[     ForAll[t, 0 <=t <= 2&&t\[Element] Reals,      f[t] + D[f[t], {t, 2}] >= 0]]      Which means, if the given function satisfies the condition: $f(t)+f''(t)\geq 0$ for all $0\leq t\leq 2$, then return TRUE, else return False. The problem is that it is not work as I supposed, for example, if I define               F[t_]:=t^2-3      then the output is:               IsSuppFun[-3 + t^2]      If I separate the code as               Resolve[ForAll[t, 0 <= t <= 2 Pi && t \[Element] Reals, F[t] + F''[t] >= 0]]      Which will get the Right Answer! Where did I go wrong? Solution is use the HoldAll attribute for the function IsSuppFun, Please see below for the answer! * * * there is my another problem in the same line: If I have tried to add another condition as:               SetAttributes[IsSuppFun, HoldAll]     IsSuppFun[f_[t_]] :=      Resolve[ForAll[t, 0 <= t <= 2 && t \[Element] Reals, (f[t] + D[f[t], {t, 2}] >= 0)&&(f[0]==f[2])]]      then with the same test function:               F[t_] := t^2 - 3      the output is not as desired True or False, but as:               \!\(\*SubscriptBox[\(\[ForAll]\), \(t\)]\(! \((0 <= t <= 2 &&  t \[Element] Reals)\)\)\)      * * * May be I should change the last question as (to make things clear and simple):               SetAttributes[{IsSuppFun}, HoldAll]     IsSuppFun[f_[t_]] := Resolve[     ForAll[t,     0<= t <= 2 && t \[Element] Reals,     f[1] >= 0]     ]      with the test function as:               F[t_] := Sin[t]      then the output of               IsSuppFun[F[t]]      is True; But if I have change it as               SetAttributes[{IsSuppFun}, HoldAll]     IsSuppFun[f_[t_]] := Resolve[     ForAll[t,     0<= t <= 2 && t \[Element] Reals,     f[1] <= 0]     ]      Then the same test function gives neither True nor False. (I Suppose it False!) Why?


title: Calculate inverse laplace transform by integration with four singular points?

text: I have a function U[s,x] to do inverse Laplace transform for analytical solution, as following               -((km (kp + la + (     E^(-((Sqrt[(-kp + KE la + KE la s)/KE] x)/Sqrt[       la])) (km - kp) (km (kp + la) + la (kp - KE la (1 + s))))/(     KE Sqrt[(-km + KE la + KE la s)/      KE] (km Sqrt[(-km + KE la + KE la s)/KE] -         kp Sqrt[(-kp + KE la + KE la s)/KE]))))/((-km + kp) (-(kp/KE) +      la + la s)))      Where               kp = 1/2 (-1 + KE la - KE s + KE la s + Sqrt[     4 la KE + (1 + KE s - KE la (1 + s))^2])          km = 1/2 (-1 + KE la - KE s + KE la s - Sqrt[         4 la KE + (1 + KE s - KE la (1 + s))^2])      KE and la are positive constants, say KE=100,la= 0.05 Since it contains nested square roots, the direct use of InverseLaplaceTransform was failed. Then I tried Apart followed by direct integration. I have difficulties when calculating residue of the following term:               KE/(2 (-1 + la + la s) Sqrt[4 KE la + (1 + KE s - KE la (1 + s))^2])      It seems have three singular points:               (1 - la)/la,          (-KE + KE la + KE^2 la - KE^2 la^2 -       2 Sqrt[-KE^3 la + 2 KE^3 la^2 - KE^3 la^3])/(KE^2 - 2 KE^2 la +       KE^2 la^2),          (-KE + KE la + KE^2 la - KE^2 la^2 +       2 Sqrt[-KE^3 la + 2 KE^3 la^2 - KE^3 la^3])/(KE^2 - 2 KE^2 la +       KE^2 la^2),       Is there any hints how to calculate the residue with nested square root? Thank you.


title: How can I avoid label collisions?

text: > **Possible Duplicate:**   >  How can I influence the spaces between labels on a BarChart How can I avoid label collisions in plot ticks and labels? For example, here is a histogram with colliding frame tick labels:               BarChart[{Labeled[{196}, Row[{"Jan", "Feb 23"}, "-"], Below],        Labeled[{349}, Row[{"Feb 23", "Apr 15"}, "-"], Below],        Labeled[{333}, Row[{"Apr 15", "Jun 6"}, "-"], Below],        Labeled[{308}, Row[{"Jun 6", "Jul 28"}, "-"], Below],        Labeled[{308}, Row[{"Jul 28", "Sep 19"}, "-"], Below],        Labeled[{344}, Row[{"Sep 19", "Nov 10"}, "-"], Below],        Labeled[{162}, Row[{"Nov 10", "Jan"}, "-"], Below]},       GridLines -> {Automatic, None},       BaseStyle -> Directive[FontFamily -> "Bitstream Charter", 10],       BarSpacing -> 0, Ticks -> None, GridLines -> None,       Frame -> {{True, False}, {False, False}}, PlotRange -> All,       BarOrigin -> Bottom, BarSpacing -> None, ChartLayout -> "Stacked",       PerformanceGoal -> "Speed",       ChartStyle -> {Directive[         EdgeForm[{Opacity[1.`], Thickness[Medium], Blue}], Opacity[1.`],          FaceForm[LightBlue]]}]      ![Mathematica graphics](http://i.stack.imgur.com/GXhd9.png) So the question has two parts:   1. How to detect collisions in frame tick labels in general.   2. How to rearrange labels to minimize collisions and optimize for aesthetics. I'm not sure how to do part 1, but part 2 should involve either rotations or columns I guess. I would rather not assume a specific font or size of text, but perhaps this is unavoidable.


title: Add two Histograms to calculate summed Mean and StandardDeviation

text: As a follow up to this question: Calculate mean and standard deviation from ImageHistogram I would like to add two histograms before calculating the mean and StDev. I would like to sum the numbers, not superimpose the graphics. Explanation: I have photographed flat samples, they have a front and back side, and so I would like to get 1 outcome/Histogram for both sides summed. Thank you for responding! Edit: We are now using:               hist = ImageHistogram[finalCrop, Appearance -> "Separated"];     Print[hist]; resImage = ImageResize[finalCrop, 200];          (*imagedata=ImageData[finalimage];*)          (*If[Mod[i,2]==0,histF=ImageHistogram[finalcrop,Appearance->\     "Separated"],histB=ImageHistogram[finalcrop,Appearance->\" Separated \     "]];          If[Mod[i,2] == 0, Print[histF],Print[histB]];*)          rgbImage = Transpose@Flatten[ImageData[finalCrop], 1];          (*hist2=GraphicsRow[Histogram/@rgbImage,ImageSize->500];     Print[hist2];*)          table = TableForm[Through[{Mean, StandardDeviation}[#]] & /@ rgbImage,         TableHeadings -> {{"Red", "Blue", "Green"}, {"Mean", "StDev"}}];     Print[table];      And I will the first to admit that I do not completely understand this, but as you can (hopefully) see, we are using histF (front of sample) en histB (back of sample) so then I would use               histTotal = Join @@@ Transpose[{histF,histB}]       followed by               GraphicsRow[Histogram /@ histTotal]      Correct? Am trying it now!


title: Why is Return not forcing an exit from my function?

text: Here is simplified version of my code that exhibits the behavior troubling me:               testFn[] := (       Do[        Print[i];        If[i > 3, Print["triggering result for true"]; Return [100]]        , {i, 1, 5}];       Return[200];       )          testFn[]     1     2     3     4     triggering result for true     200      Intuitively, once `i` is bigger than 3, it should evaluate the 2nd argument of the `If` and exit `testFn`, returning 100. However, although the 2nd argument of the If statement is getting evaluated, the function does not exit until it hits the `Return[200]`. I kind of guessed what might be the problem. The Return[100] is just exiting the `Do`, which seems to be confirmed by doing:               testFn[] := (       a = Do[         Print[i];         If[i > 3, Print["triggering result for true"]; Return [100]]         , {i, 1, 5}];       Print["a=" <> ToString[a]];       Return[200];       )          1     2     3     4     a=100     triggering result for true     200      If this is indeed what's happening, how can I make my code actually return from and exit `testFn`?


title: What can I use as the second argument to Return in my own functions?

text: Having found out about the second argument to `Return` I played a bit with it, and the following tests all resulted in `Return::nofunc`:               f[x_]:=x     f[Return[3,f]]          SetAttributes[g,HoldAll];g[x_]:=x     g[Return[3,g]]          h[x_]:=f[x]     h[Return[3,f]]          SetAttributes[i,HoldAll];i[x_]:=f[x]     i[Return[3,f]]      On the other hand, the following works fine:               Module[{i},Return[3,Module]]      Does that mean the second argument of `Return` can only be used with a predefined list of symbols? If so, is there an easy way to find out that list? Otherwise, what am I doing wrong (and how would I do it right)?


title: Reading many single files and creating numbered (? or indexed) variable

text: I tried many different approaches, but I could not solve the following problems, I appreciate your help: What is the best way to read many data files? I mean we have `file1.dat, file2.dat, file3.dat …`. and I would like to put them in a loop and by using the readlist, import the data, something like what we do in C and `sprintf` or in bash scripting. I have seen that there is a package which can handle `sprintf` functionality in Mathematica, but I am looking for simpler solution something like this: (I just used `$` sign to show what I mean, like bash)               Do[d$i = ReadList["/path/file$i.dat", Number, RecordLists -> True], {i, 1, 5}]      Can I create a variable like `d$i` inside the above loop over i? which creates `d1, d2, …`, and so on, after running the loop? How can I remove the curly braces from `Mean` output? I have a single list and the Flatten does not remove the curly braces.               tt = {1, 2, 3, 4, ...}      Flatten[Mean[tt]] = {1234.1234}


title: Using one complicated equation to reduce another

text: (Relative noob here so don't assume much!) I need to use a vector equation (with $N-1$ entries) in the general form $y_j(x_{i,j},x_{i,j+1},x_{i,j-1})=0, i=1...3, j=1...N-1; x_{i,0}=x_{i,N}=0$, which depends fairly complicatedly on the $x_{i,j}$s (etc), to solve another vector equation $w_j(x_{i,j}, x_{i,j+1}, x_{i,j-1}, z_{i,j}, z_{i,j+1}, z_{i,j-1}, r_1,r_2,p_0,p_1)=0, i=1...3, j=1...N-1;$ $z_{i,0}=z_{i,N}=0$, which is fairly fiendish but (when properly factorised) contains several occurrences of $y_j$, that I can therefore eliminate. How do I use $y_j$ to reduce $w_j$? I have tried using `Reduce[expr,var,varlist]`, but I don't want to rearrange the equation 'equal to' anything; I'd rather it equal 0 at the end, but just with the $y$ bits removed; and I also can't really tell what I'm supposed to put into 'varlist' - is it all the argument, including subscripted ones? EDIT - other things I have tried that didn't work:   * `Eliminate[{y==0, w==0}, {Subscript[x,i,j] (etc over j)}]` \- didn't produce anything, had to abort   * `Collect[w==0,y]` \- just spat out $w=0$ fully expanded EDIT2 - Yves - ok, here it comes! Definitions: `m[r_] := Sum[Subscript[m, i]*r^i, {i, 0, 5}] s[r_] := Sum[Subscript[s, i]*r^i, {i, 0, 5}] \[Omega][r_] := Sum[Subscript[\[Omega], i, j]*r^i, {i, 0, 5}] \[Omega]0[r_] := \[Omega][r] /. j -> j - 1 \[Omega]1[r_] := \[Omega][r] /. j -> j + 1 w[r_] := 1 - \[Omega][r]^2 + 1/2*(\[Omega]1[r]^2 + \[Omega]0[r]^2) \[Alpha][r_] := Sum[Subscript[\[Alpha], i, j]*r^i, {i, 0, 5}] \[Alpha]1[r_] := \[Alpha][r] /. j -> j + 1 \[Mu][r_] := Expand[1 - 2 m[r]/r - r^2/(l^2)]` Conditions: `Subscript[\[Omega],0,j] := Sqrt[j*(n-j)] Subscript[\[Omega],1,j] := 0 Subscript[\[Omega],i,0] := 0 Subscript[\[Omega],i,n] := 0 Subscript[\[Alpha],i,0] := 0 Subscript[\[Alpha],i,n] := 0 Subscript[m,0]:=0 Subscript[m,1]:=0 Subscript[m,2]:=0 Subscript[s,1]:=0` Equation: `Expand[Coefficient[-\[Mu][r]*D[\[Mu][r], r]*s[r]^2*D[\[Omega][r], r] -\[Mu[r]^2*s[r]*D[s[r], r]*D[\[Omega][r] - 1/4*\[Omega][r]*(\[Alpha][r] - \[Alpha]1[r])^2 -\[Mu][r]*s[r]^2/r^2*\[Omega][r]*w[r] - \[Mu][r]^2*s[r]^2*D[D[\[Omega][r], r], r], r, 2]]==0` Constraint: `Expand[Coefficient[-\[Mu][r]*D[\[Mu][r], r]*s[r]^2*D[\[Omega][r], r] -\[Mu[r]^2*s[r]*D[s[r], r]*D[\[Omega][r] - 1/4*\[Omega][r]*(\[Alpha][r] - \[Alpha]1[r])^2 -\[Mu][r]*s[r]^2/r^2*\[Omega][r]*w[r] - \[Mu][r]^2*s[r]^2*D[D[\[Omega][r], r], r], r, 0]]==0` which outputs as `2*Subscript[\[Omega][r],2,j]+Subscript[\[Omega][r],2,j-1]*Subscript[\[Omega][r],0,j-1]*Subscript[\[Omega][r],0,j]+Subscript[\[Omega][r],2,j+1]*Subscript[\[Omega][r],0,j+1]*Subscript[\[Omega][r],0,j]-2*Subscript[\[Omega][r],2,j]*Subscript[\[Omega][r],0,j]^2==0` As you'll see, with these above conditions, the constraint reduces down quite a lot, and if you examine the equation, it contains a few mentions of the constraint, or has some of the terms which you could use to replace the constraint with the others. This was one attempt: `Eliminate[{Expand[Coefficient[-\[Mu][r]*D[\[Mu][r], r]*s[r]^2*D[\[Omega][r], r] -\[Mu][r]^2*s[r]*D[s[r], r]*D[\[Omega][r], r] -1/4*\[Omega][r]*(\[Alpha][r] - \[Alpha]1[r])^2-\[Mu][r]*s[r]^2/r^2*\[Omega][r]*w[r] -\[Mu][r]^2*s[r]^2*D[D[\[Omega][r], r], r], r, 2] = 0, r, 2], Expand[Coefficient[-\[Mu][r]*D[\[Mu][r], r]*s[r]^2*D[\[Omega][r], r] -\[Mu][r]^2*s[r]*D[s[r], r]*D[\[Omega][r], r] -1/4*\[Omega][r]*(\[Alpha][r] - \[Alpha]1[r])^2 -\[Mu][r]*s[r]^2/r^2*\[Omega][r]*w[r] -\[Mu][r]^2*s[r]^2*D[D[\[Omega][r], r], r], r, 0] = 0], l != 0, Subscript[s, 0]! == 0, j != 0, j != n}, {Subscript[\[Omega], 2, j], Subscript[\[Omega], 2, j - 1], Subscript[\[Omega], 2, j + 1]}]` Output: `Set::write: Tag Plus in 1/4 (-Sqrt[j (Times[<<2>>]+n)]... Subscript[\[Omega], 4,1+j]) is Protected. >> Set::write: Tag Plus in 0+0+0-2 Subsuperscript[s, 0, 2]... Subscript[\[Omega], 2,1+j]) is Protected. >> Eliminate::eqf: 0 is not a well-formed equation. >>` And another: `Collect[Expand[Coefficient[-\[Mu][r]*D[\[Mu][r], r]*s[r]^2*D[\[Omega][r], r] -\[Mu][r]^2*s[r]*D[s[r], r]*D[\[Omega][r], r] -1/4*\[Omega][r]*(\[Alpha][r] - \[Alpha]1[r])^2 -\[Mu][r]*s[r]^2/r^2*\[Omega][r]*w[r] -\[Mu][r]^2*s[r]^2*D[D[\[Omega][r], r], r], r, 2]], Expand[Coefficient[-\[Mu][r]*D[\[Mu][r], r]*s[r]^2*D[\[Omega][r], r] -\[Mu[r]^2*s[r]*D[s[r], r]*D[\[Omega][r], r] -1/4*\[Omega][r]*(\[Alpha][r] - \[Alpha]1[r])^2 -\[Mu][r]*s[r]^2/r^2*\[Omega][r]*w[r] -\[Mu][r]^2*s[r]^2*D[D[\[Omega][r], r], r], r, 0]]]` (did nothing i.e. returned output fully expanded.)


title: How to group the powers of one variable?

text: Consider the following expression: $\sqrt{a x} \sqrt{b x}$ What do I use to make it simplify to: $\sqrt{ab} x$ I tried actually everything (Simplify, FullSimplify, Collect and so on...) and such expressions remain unchanged. Thanks in Advance and Regards, Misery


title: Dynamic content Aborts in Mathematica 10

text: I have written a notebook in v9 that contains dynamic content (a `Manipulate`). I just downloaded V10. If I double click on the notebook, of course it is opened by v10, but the dynamic output does not look correct and then it aborts this output of `Manipulate`. I then open it with v9 and everything is ok. What is happening?


title: integro differential equation

text: > **Possible Duplicate:**   >  Integro-differential equation I have to solve an Integro-differential equation with Mathematica or Matlab, in the following form:               Dy/Dt = Integral[K(x,u)(D2y/Du2) du] + Sin(y)      The function `K(x,u)` is known, as well as the initial conditions. I have no clue how to solve this; can anyone give me some pointers?


Is there a Mathematica API for the functions.wolfram site?   If there's not, has anyone implemented a web scraper for it? For example it would be nice to be able to access http://functions.wolfram.com/07.23.17.0081.01 from within Mathematica by using something like               In[1]:= FunctionsWolfram["07.23.17.0081.01", InputForm]     Out[1]= Hypergeometric2F1[a,b,a+b-1/2,z]             == Hypergeometric2F1[2 a-1,2 b-1,a+b-1/2,1/2 (1-Sqrt[1-z])]/Sqrt[1-z]          In[2]:= FunctionsWolfram["07.23.17.0081.01", RuleForm]     Out[2]= HoldPattern[Hypergeometric2F1[a_,b_,a_+b_-1/2,z_]]              :> Hypergeometric2F1[2 a-1,2 b-1,a+b-1/2,1/2 (1-Sqrt[1-z])]/Sqrt[1-z]          In[3]:= FunctionsWolfram["07.23.17.0081.01", TraditionalForm]     Out[3]=      ![Image_from_http://functions.wolfram.com/07.23.17.0081.01](http://i.stack.imgur.com/vDu9w.gif)


title: Is FinancialData for India available?

text: FinancialData["IndiaNSE", "Members"] // Shallow      gives               {"^CNXIT", "^CRSLDX", "^CRSMID", "NS:20MICRONS", "NS:3IINFOTEC", \     "NS:3MINDIA", "NS:526015", "NS:AARTIDRUG", "NS:AARTIIND", \     "NS:AARVEEDEN", <<1432>>}      But when I query               FinancialData["NS:20MICRONS"]      I get the following error                FinancialData::notent: NS:20MICRONS is not a known entity, class, or tag for       FinancialData. Use FinancialData[] for a list of entities. >>      Interestingly I tried the same query on Wolfram Alpha http://www.wolframalpha.com/input/?i=FinancialData[%22NS%3A20MICRONS%22] I got this **Assuming 20MICRONS | Use 533022 instead** I tried               FinancialData["MB:533022"]      and I got the same error! Is this expected ?


title: Double helices inside an ellipsoidal cavity

text: This question may be related to a previous query at Plotting a contour on a torus My question is how do you enclose double helix structures (see demonstrations.wolfram.com/DoubleHelix ) inside an ellipsoidal cavity and also within a torus. Following the examples in the previous query, I show a typical case below for the torus, but the coils are not in phase:               With[{rr = 3, r = 1},        torus[{u_, v_}] := {(rr + r*Cos[2*Pi*u])*          Cos[2*Pi*v], (rr + r*Cos[2*Pi*u])*Sin[2*Pi*v], r*Sin[2*Pi*u]}]*        (gr = ContourPlot[          Re[2*Exp[4*Pi*I*(x + 2*y)] + 3*Exp[4*Pi*I*(x - 2*y)]] == 0, {x,            0, 1}, {y, 0, 1}]; )*        (gr1 =          ContourPlot[          Re[2*Exp[4*Pi*I*(x - 2*y)] + 3*Exp[4*Pi*I*(x + 2*y)]] == 0, {x,            0, 1}, {y, 0, 1}]; )*        Show[ParametricPlot3D[torus[{u, v}], {u, 0, 1}, {v, 0, 1},         PlotStyle -> Directive[Opacity[0.3], Red], Mesh -> None],           Graphics3D[{Blue,          Cases[Normal[gr], Line[__], Infinity] /.           Line[pts_] :> Tube[torus /@ pts]}],           Graphics3D[{Red,          Cases[Normal[gr1], Line[__], Infinity] /.           Line[pts_] :> Tube[torus /@ pts]}]]!      ![enter image description here](http://i.stack.imgur.com/cgfaN.png)


title: Wrapping a rectangle to form a cylinder

text: I'd like to make an animation showing how we wrap a rectangle to form a cylinder (by joining a pair of parallel sides). Here's my first pass:                Manipulate[         ParametricPlot3D[         t {Cos[theta], Sin[theta], rho} + (1 - t) {rho, -1, theta},          {theta, -Pi, Pi}, {rho, 0, 2},          PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}, {-1.5, 1.5}},          PerformanceGoal -> "Quality", ViewPoint -> {-2.3, 0.77, -2},          ViewVertical -> {-0.08, 1, -0.06}],       {t, 0, 1}]      I'd much prefer the simpler looking transformation (without the twists this animation shows) which we'd do by simply rotating the pair of parallel sides until they touch to form the cylinder.


title: plotting evolution of points in the same plot

text: I am trying to plot the points (i,j,k) as they are generated in the loop but in the same plot. The next draws the points in different windows.               list = {};     Do[list = Append[list, {i, j, k}];       Print[ListPointPlot3D[list]], {i, 3}, {j, 3}, {k, 3}]      Is there any function in Mathematica that allows us to draw plots dynamically, i.e., keeping the plots that were already generated as new ones are being generated from a loop (all in the same window)?


title: How to extract the numerical value of a dynamical variable

text: I want to inspect interactively an image by selecting points by the mouse pointer. This is easily done by `LocatorPane` \- here is a simplified example:               plot = ListPlot[{{1, 1}}];     Manipulate[       x = Dynamic[First[pt]];       LocatorPane[Dynamic[pt],           Show[plot, Epilog -> {Red, PointSize[Large], Point[Dynamic[pt]],          Text[Style[StringForm["x = `1`", x], Blue, 20], {1, 1.5}]}]],       {{pt, {0, 0}}, None}      ]      ![Mathematica graphics](http://i.stack.imgur.com/LiXAg.png) Now imagine that for a selected point I would like to get the numerical value of the x-coordinate. I would like to calculate a function of it (like divide by 3) and/or save its numerical value to an external data file. This does not work because the x is a dynamical object. How to extract the current numerical value of x? In addition to solving this particular problem I would like to understand better how does Dynamic really work.


title: Return Values from DynamicModule

text: I found the answer to my question here. How to extract the numerical value of a dynamical variable Is it possible to have the return value from a `DynamicModule` be just the value and not the whole `DynamicModule` definition? Here is a (much) simplified version of the problem that I am having. The actual code has several interacting `Dynamic` variables that provide the end result.                   func[var_List] := DynamicModule[            {insideFunc, choice},            insideFunc = RadioButtonBar[Dynamic[choice], var];            DialogInput[             {},             Row[{insideFunc, Button["Return", DialogReturn[choice]]}]             ]            ];      Now, if I call `func` with a simple list, the output that I get is indeed the answer that I chose (2),                   In[63]:= func[{1, 2, 3}]              Out[63]= 2      But in the end I want to write this piece of data to a file for later use, and upon doing that, I find that really that simple little number 2 is the actual `DynamicModule`, here illustrated by `FullForm`.                   In[64]:= % // FullForm              Out[64]//FullForm=          DynamicModule[          List[Set[insideFunc, RadioButtonBar[Dynamic[choice], List[1, 2, 3]]],            Set[choice, 2]], 2, RuleDelayed[DynamicModuleValues, List[]]]      So, is there a way to back out the end value rather than the `DynamicModule`? A naive attempt to just use `Evaluate` failed. Also, I have played around with putting the `DialogInput` on the outside of the `DynamicModule` and in my particular case, a variety of things break in the various dynamic actions when I do that. While I have played around trying to debug those errors, it was to no avail. Hmmm, I should have done a little bit better research in this wonderful database, because about 1 minute after my original posting, I stumbled on the right answer. To fix the problem I simply needed to use `Setting` as you can see below.                   In[75]:= % // Setting // FullForm              Out[75]//FullForm= 2      Hopefully, my title will help somebody find this answer in the future.


title: How to extract value from dynamic list?

text: > **Possible Duplicate:**   >  How to extract the numerical value of a dynamical variable   >  Dynamic wraps a list that I cannot extract values from I want to extract value from list dynamically,this is my code               xData = {"Environment", "Building"};     DynamicModule[{},       Row[{tabP1 =          Dynamic[Position[xData, ToString[buttonValue]],           t = tabP1[[1, 1]]]}]]     Button[button1, buttonValue = Environment] Button[button2,        buttonValue = Building]      It gives `{{1}}` or `{{2}}` based on button i have clicked. Now i want to extract value(1) from this list(`{{1}}`) . I have tried to extract it as follows `t=tabP1[[1,1]]` but t has list(`{{1}}`) not value(1). I need value instead of list.


title: Getting value of clock

text: I have the following code:               a = Dynamic[Floor[Clock[2]]] (*So this basically alternates between 0 and 1*)     If[a==1, Print["true"]]      But this doesn't work, it instead prints the following `If[a==0, Print["true"]]` and then changes to `If[a==1, Print["true"]]` and then back. How can I get the value from the clock?


title: Undocumented overload for Graph?

text: I stumbled (here, in the expression for the block diagram) upon a version of Graph that I don't see in the documentation over here. That documentation admits three overloads (the following are in my own words):   1. `Graph[{` _edges_`}]`   2. `Graph[{` _vertices_`}, {` _edges_`}]`   3. `Graph[{` _decoratedVertices_`}, {` _decoratedEdges_`}]` For instance, the following example invokes overload 2:               Graph[{1,2,3}, {{1, 2}, {1, 3}, {2, 3}}]      ![enter image description here](http://i.stack.imgur.com/8tfwu.png) If I add a `Null` in an undocumented place, I get arrows:               Graph[{1,2,3}, { {{1, 2}, {1, 3}, {2, 3}}, Null } ]      Notice there is an extra level of `List` in the list of vertices. It's as though the list of vertices contains a nested list of vertices and a Null vertex. This seems to produce similar results to               Graph[{1, 2, 3}, {1 \[DirectedEdge] 2, 1 \[DirectedEdge] 3, 2 \[DirectedEdge] 3}]      Anyone happen to know what's going on? I'm ok with blindly using the cool feature, but I wonder what the other options for this API might be. ![enter image description here](http://i.stack.imgur.com/fxs14.png)


title: Finding the Centroid of the grid

text: Im trying to automate the processing of my shooting targets to measure my performance in the range. I was able to process the shots, but I still have to select the center of the target by the use of locator function. Tried using the following questions as a base Detecting Grid Lines               src = ColorSeparate[Import["http://i.imgur.com/BW61u.jpg"], "RGB"][[1]];     p = ImageDimensions[src]/2;     shots = DeleteCases[DeleteCases[Last /@ ComponentMeasurements[MaxDetect@DistanceTransform     @ColorNegate@DeleteSmallComponents@           Binarize[            Closing[ImageAdjust[Blur@Blur@Blur@src, {1, 1}], 2]],        "Centroid"], {0.5, ___}], {___, 0.5}];     pts = Graphics[{Red, PointSize[Large], Point[#]}] & /@ shots;     Show[src, pts, Graphics[Locator[Dynamic[p]]]]      ![Identified Shots](http://i.stack.imgur.com/ptvuO.png) With the locator in place I can now extract the actual shots with respect to the center of the target.               values = (# - p)/100 & /@ shots;     sigImage =       DensityHistogram[values, {0.2}, ColorFunction -> "DarkRainbow",        Method -> {"DistributionAxes" -> True},        ChartBaseStyle -> EdgeForm[Thin],        GridLines -> {{{0, {Red, Dashed, Thick}}}, {{0, {Red, Thick,         Dashed}}}}, PlotRange -> {{-2, 2}, {-2, 2}}]      ![Mathematica graphics](http://i.stack.imgur.com/yrX10.png) I would like for Mathematica to be able to find the center of the target automatically, so then I can create a program to process several targets which I can extract the shots automatically and save in a database, which I can then use to review the Density Histograms of different dates, weapons, distances, stances, etc.


title: Compiling/calling Mathematica-generated .so from C

text: I'm trying to call a compiled function from a C program. I am generating the static object               /home/fabio/.Mathematica/SystemFiles/LibraryResources/Linux-x86-64/test.so      through the _Mathematica_ code               << CompiledFunctionTools`     Needs["CCodeGenerator`"]     Needs["CCompilerDriver`"]     compiledfunction = Compile[{x, _Real}, x];     LibraryGenerate[compiledfunction, "test"]      then by using the source `test.c`               #include <stdio.h>          double compiledfunction(double);          int main(){       double a=2e0;       printf("%20.12e\n",compiledfunction(a));       return 0;     }      How I should call the compiler to link with the static object above?


title: Tricks for solving (lots of) coupled nonlinear equations numerically?

text: I have a system of 6 non-linear (quadratic) coupled equations with 6 complex unknowns \begin{align*} |x_1|^2 + |x_2|^2 + |x_3|^2 &= a\\\ x_1 x_4^* + x_3 x_5^* &= b + c i\\\ x_1 x_6^* &= d + e i\\\ |x_4|^2 + |x_5|^2 &= f\\\ x_4 x_6^* &= g + h i\\\ |x_6|^2 &= k \end{align*}               {Abs[x1]^2 + Abs[x2]^2 + Abs[x3]^2 == a,      x1 Conjugate[x4] + x3 Conjugate[x5] == b + c I,      x1 Conjugate[x6] == d + e I,      Abs[x4]^2 + Abs[x5]^2 == f,      x4 Conjugate[x6] == g + h I,      Abs[x6]^2 == k}      where $x_1$ etc. are complex variables, $x_1^*$ is `Conjugate[x1]`, $|x|$ is `Abs[x]`, and `a` etc. are real constants. The equations are probably underdetermined - if you break them into real and imaginary parts, there are only 9 equations for 12 real unknowns. Physically (since these equations solves for parameters in a model) I expect some phases in the $x_i$ are not physical (i.e. some $x_i$ are actually real numbers instead of complex), but I don't know a good way to parametrize the phases away. `NSolve[{eqns}, {vars}, Complexes]` has been running for more than 10 minutes (and still running!). I've never encountered numerical equation solving with coupled non-linear equations before, so I don't know what to expect. Is there anything I can do to optimize the process? What other numerical solving functions can I try? Also, probably off-topic here: I am under the impression that numerics is not _Mathematica_ 's strong suit; should I seek out other programs to solve this problem? Recommendations?


title: How do I link the txt file data sheet to mathematica and extract exact elements that I would like to use in solving for x?

text: I am trying to solve for a numerical solution for an equation which contains variables that evolves as index i incrreases. The actual equation that I am using to extract solution for x with an ongoing iteration with index i is the following:


title: How to set the position of the palette when use CreatePalette[]

text: When using `CreatePalette[]`, the palette created always shows up on the upper left corner. Is there a way to make it show up at the center of the screen, just like what `CreateDialog[]` does?


title: Graphics3D from Mathematica to SolidWorks (for 3D-printing)

text: I have an 3D Graphic generated with Mathematica's Graphics3D, and want to use it later in SolidWorks. SolidWorks files are usually *.stp, *.step, *.stl extentions. google search hasn't given me a solution yet, and I didn't find anything on this page either. Are there solutions to that? What is the best way to do this? Or do you know any workarounds? **edit:** Just for info - my 3D Graphics (from here) is:               Graphics3D[{GraphicsComplex[        Join[{Cos[#], Sin[#], 0} & /@ Range[0, Pi, Pi/(25)], {{0, 0, 1}}],         {         {#, Rotate[Rotate[#, 180 °, {0, 0, 1}], 90 °, {0, 1, 0}]} &[              GeometricTransformation[Polygon[{##, 27} & @@@ Partition[Range[26], 2, 1]],                                        {IdentityMatrix[3], ScalingTransform[{1, 1, -1}]}]          ]         }]}]      **edit2:** Thanks to Simon Woods' wonderful answere, I was able to export to Solid Works, and print it with my 3D-printer. Here are real-world results: ![100-sided Sphericon 1](http://i.imgur.com/7WWJLLZ.jpg) ![100-sided Sphericon 2](http://i.imgur.com/9hwv3qV.jpg) Thanks alot again :)


title: How to flip texture?

text: I discovered this excellent answer which contains a so beautiful plot. I just copied the whole code and tried to reproduce the result but the contour plot used as texture looks like flipped, that is, when I see the plot from above the result is ![enter image description here](http://i.stack.imgur.com/LKh6r.png) and if I see it from below the result is ![enter image description here](http://i.stack.imgur.com/eQdSC.png) How to fix this? I mean, how to put the white color visible from the top? I'm using _Mathematica_ 9.


title: Creating a dynamic plot directly from the recurrence relation

text: I have the following recurrence relation that has no general solution: $$x(t+1) = \frac{x^2 + x(1-x)(1-sh)}{x^2 + 2x(1-x)(1-sh) + (1-x)^2(1-s)}$$ In Mathematica language it gives:               x[t + 1] == (x[t]^2 + x[t] (1 - x[t]) (1 - s h))/(        x[t]^2 + 2 x[t] (1 - x[t]) (1 - s h) + (1 - x[t])^2 (1 - s)  )      * * * I'd like to plot $x$ as a function of $t$ (range{0,100}). How can I do this? Also, that would be awesome if I could directly on my plot, modify the values of $h$ and $s$ in the range {0,1}


title: Properly Force Mathematica to Simplify Log Expressions/Rules

text: I want to be able to expand $\log(x^n e^x) = n \log(x) +x$:               FullSimplify[Log[x^n Exp[x]], x > 0 && Element[n, Integers] && n > 1]      yields               Log[E^x x^n]      whereas               -1 +FullSimplify[Log[x^n Exp[x]] + 1,  x > 0 && Element[n, Integers] && n > 1]      yields               x + n Log[x]      what gives? Maybe it recognizes that I want to do arithmetic outside the log, so it then simplifies the expression; if that's the case, how can I force it to do that without hacking it by adding and subtracting 1? thanks!


title: How to find matrix exponential using RootSum?

text: From what I've been able to deduce, Mathematica uses a root sum scheme to determine the exponential of a matrix. Can someone please explain to me the theory behind this? I've searched, but have had no luck finding any literature on calculating a matrix exponential using root sums. (Example: Help->RootSum->Applications->'Matrix exponential of any order:'


title: How can I fill an entire Building with transparent points?

text: I am posting the same code found at an earlier question, although the concept here is totally different. The following code corresponds to a building-shaped structure.               w = 100;     l = 200;     h = 30;     m = 70;     backwall = {{0, l, 0}, {w, l, 0}, {w, l, h}, {0, l, h}};     side1 = {{0, 0, 0}, {0, 0, h}, {0, l, h}, {0, l, 0}};     side2 = {{w, 0, 0}, {w, 0, h}, {w, l, h}, {w, l, 0}};     floor = {{0, 0, 0}, {w, 0, 0}, {w, l, 0}, {0, l, 0}};     top = {{0, 0, h}, {w, 0, h}, {w, l, h}, {0, l, h}};     front = {{0, 0, 0}, {w, 0, 0}, {w, 0, h}, {0, 0, h}};     leftRoof = {{0, 0, h}, {w/2, 0, m}, {w/2, l, m}, {0, l, h}};     rightRoof = {{w, 0, h}, {w/2, 0, m}, {w/2, l, m}, {w, l, h}};     roofBack = {{w, l, h}, {w/2, l, m}, {0, l, h}};     roofFront = {{w, 0, h}, {w/2, 0, m}, {0, 0, h}};     building = {backwall, side1, side2, floor, front, leftRoof, rightRoof,roofBack, roofFront};     figure =Graphics3D[{Opacity[0.5],Style[Polygon[building,VertexColors -> Map[0.5 + #[[3]]/80 &, building, {2}]],Lighting -> {{"Ambient", White}}]}, Boxed -> False,RotationAction -> "Clip"];     data = RandomReal[60, {100, 3}];     data1 = RandomReal[60, {100, 3}];     redPoints = Graphics3D[{Opacity[0.4], PointSize -> Large,Style[Point[#], Blue]} & /@ data, Boxed -> False,RotationAction -> "Clip"];     bluePoints =Graphics3D[{Opacity[0.4], PointSize -> Large,Style[Point[#], Red]} & /@ data1, Boxed -> False,RotationAction -> "Clip"];     Show[{figure, redPoints, bluePoints}]      and upon evaluation it produces: ![house with transparent points](http://i.stack.imgur.com/MTjV1.png) I have 10000 points that need placing, some with coordinates inside the building while the remaining are outside (like the ones circled above). I have the following two questions:   1. How can I omit the points that are not within the building?   2. How do I fill the entire building with points? Having tried a few things this morning, I still couldn't get it to work as I want so any help is appreciated.


title: How can I assign a Fit result to a function?

text: I have this code               ntcrr[t_] := E^(a + b/t + c/t^2 + d/t^3)     kelvin[t_] := t + 273.15     a = -13.40956889; b = 4481.798865; c = -150521.6916; d = 1877102.652;     p1 = {30, ntcrr[kelvin[30]]}; p2 = {35, ntcrr[kelvin[35]]};     line := Fit[{p1, p2}, {1, x}, x]      { 1.67709 - 0.0285019 x } Then I plug in this function in my `Plot`               Plot[ntcrr[kelvin[t]]/(1.67709 - 0.0285019 t), {t, 30, 35}]      and that works, but I'd rather like to assign the `Fit` result to a function, like this:               line[x_] := Fit[{p1, p2}, {1, x}, x]     Plot[ntcrr[kelvin[t]]/line[t], {t, 30, 35}]      but that doesn't work. How can I assign a `Fit` result to a function?


title: How to get Coefficient List from an expression with various variables

text: consider following expression:               t = Subscript[α, 0]/2 + Subscript[α, 1]/2 + 2 Subscript[α, 2] + (9 Subscript[α, 3])/2 +      8 Subscript[α, 4] + (25 Subscript[α, 5])/2 + 18 Subscript[α, 6] + (49 Subscript[α, 7])/2 +      32 Subscript[α, 8] + (81 Subscript[α, 9])/2;      one can access variable list of expression above by using:               Variables[t]      but how can I get the corresponding coefficient list of variables? I've tried:               CoefficientList[t, Variables[t]]      it just doesn't work...


title: Indexed variable with alternatives

text: I have               a["tree"] := "oak"     a["flower"] := "rose"     a["dog" | "cat"] := "animals"      I want that the last definition of `a` behaves differently like in               b[x_ /; x == "dog" || x == "cat"] := If[x == "dog", "wow", "miau"]      but want to do this with `a` Is there a way to write something like               a["dog" | "cat"] := If[ (* passed parameter *) == "dog", "wow", "miau"]


title: How to find a recurrence relation for a numerical sequence?

text: This question was inspired by Vladimir Reshetnikov's question (How to find a recurrence relation for a sequence?): Given a finite sequence of numbers, how can we find in MMA a recurrence relation obeyed by this sequence? To be more specific, assume that the numbers are rationals and the recurrence relation is of a simple type, say linear. This problem is similar to FindFit for the function "behind" the sequence but now we are interested in a recurrence relation of a given form containing some Parameters. Also there is a similarity to DifferenceRootReduce where MMA tries to find the recurrence relation for a given formula for the elements of a sequence. Now the formula is replaced by the numerical sequence. As an Option we would specify a class of recurrence relation, e.g. linear. Let's consider the example of Vladimir, and take this sequnce               seq = Table[{n, -2^-n (2^(1 + n) LerchPhi[2, 2, 1 + n] - PolyLog[2, 2])}, {n, 1, 20}] // Simplify      $\left\\{\\{1,1\\},\left\\{2,\frac{3}{4}\right\\},\left\\{3,\frac{35}{72}\right\\},\left\\{4,\frac{11}{36}\right\\},\left\\{5,\frac{347}{1800}\right\\},\left\\{6,\frac{149}{1200}\right\\},\left\\{7,\frac{9701}{117600}\right\\},\left\\{8,\frac{209}{3675}\right\\},\left\\{9,\frac{8093}{198450}\right\\},\left\\{10,\frac{6031}{198450}\right\\},\left\\{11,\frac{1126651}{48024900}\right\\},\left\\{12,\frac{3587327}{192099600}\right\\},\left\\{13,\frac{990457463}{64929664800}\right\\},\left\\{14,\frac{1653005063}{129859329600}\right\\},\left\\{15,\frac{561462043}{51943731840}\right\\},\left\\{16,\frac{3778408}{405810405}\right\\},\left\\{17,\frac{951790361}{117279207045}\right\\},\left\\{18,\frac{1117157389}{156372276060}\right\\},\left\\{19,\frac{716038369549}{112900783315320}\right\\},\left\\{20,\frac{1600677857657}{282251958288300}\right\\}\right\\}$ Now let make an "educated guess" and assume a recurrence relation of the form $f(n) = a f(n-1) + \frac{b}{n^2}$ How do we determine the two parameters $a$ and $b$? (In this example the solution is well known: $a = \frac{1}{2}$, $b=1$) I tried to first RSolve the recurrence relation and then use FindFit to determine the parameters. It didn't work, too many error message and no result. Can you do better?


title: How to use Undocumented Functions Prism, Tetrahedron and Hexahedron

text: Taking a look at this question and this one, I checked to see if _Mathematica_ really does not have a `Prism` primitive. To my surprise the function `Prism` was black but hitting the `F1` key didn't bring up anything useful. I also stumbled upon `Tetrahedron` and `Hexahedron` as being undocumented too. So how can one properly use these functions? If these functions have already been unearthed please forgive me as I could not find any usage of them here.


title: How to find discretezation error of NDSolve

text: Is there a way to find out how large the truncation, round-off, and other errors that occur from discretizing a differential equation are while using the default settings in NDSolve? Or would I have to explicitly ask Mathematica to solve the problem using 4th order Runge-Kutta, Adams, etc and find the errors myself. I did find this link: http://reference.wolfram.com/mathematica/howto/CheckTheResultsOfNDSolve.html helpful, but I am wondering what other methods are available.


title: Calculate mean of values in bins

text: **Problem description** : I have a list of $\\{x,y\\}$ pairs. I'd like to divide $x$ into equal[*] bins, say $bx_1, bx_2, \ldots$, calculate $\left<y\right>$ for every bin and then plot the bin values versus the means. I.e., plot $bx_i$ versus $\left<y\right>_i$ with `ListPlot[]`. **Question** : I've already done it manually, but I was wondering whether:   1. exists a builtin function in _Mathematica_ that does what I want.   2. exists a builtin function that I could use in my own implementation (e.g., `HistogramList[]`?). [*] Bins with the same interval. Equally spaced intervals. * * * **EDIT** : Largely off-topic, but in `R` it turns out to be very easy with the `fields` package:               library('fields')     df <- read.table('my.dat')    # V1 -> off-axis distance, V2 -> energy     st <- stats.bin(x=df$V1, y=df$V2, N=100)     df2 <- as.data.frame(st$stats["mean",])          # Plot mean energy for every distance bin     names(df2) <- c('mean.energy')     plot(df2$mean.energy, type="s",         xlab="Off-axis distance (mm)", ylab="Mean Energy (MeV)")      ![enter image description here](http://i.stack.imgur.com/bofp5.png)


title: Binomial sum identities

text: How do you persuade Mathematica to give simple identities involving binomial sums. For example               Sum[Binomial[a,i]*Binomial[b,i],{i,0,n}]      where n is bigger than both a and b.


title: Clean webMathematica Kernel

text: On my webMathematica server, certain input values are being saved between page loads on different computers. I assume this is because the kernel is not clearing the values after it finishes loading a page, which is the behavior that I would like. As per How do I clear all user defined symbols?, it seems there are a few ways to clear the kernel:               ClearAll["Global`*"]      and               Quit[]      and               Utilities`CleanSlate      My worry is this: Does calling one of these functions interfere with all pages that are currently being processed? I'm not sure I understand how the webMathematica kernel pool works, so I have no idea if multiple user accessing the server at the same time would be interfered with by clearing the Kernel. Also, would calling `Quit[]` quit the Kernel until it is restarted through some other process (e.g the Kernel Monitor), and would this interfere with multiple users accessing the page at the same time, or would it slow down the system with constant clearing and reloading? Finally, would it be wise (assuming I'm not counting on packages staying loaded) to just add the lines               <KernelReleaseCode>         Quit[]     </KernelReleaseCode>      to MSPConfiguration.xml? I know there are several questions here, but what I'd really is just a explanation (or a link to one) of how the webMathematica kernel pool and kernels work - I assume the answers to these questions would be trivial once I understand that.


title: Sorting a list of triplets by first element of each triplet fails

text: In the last line of code, I´m trying to order the matrix by the first column. I want to store in the Array t2tlistsorted ( 100 x 3 ), but I can´t.               t = {       {{2, 1}, {5, 2}},       {{7, 1}, {9, 4}},       {{9, 2}, {6, 6}},       {{5, 4}, {2, 3}},       {{4, 5}, {7, 9}},       {{8, 5}, {2, 4}},       {{3, 7}, {7, 7}},       {{4, 8}, {1, 10}},       {{3, 10}, {10, 7}},       {{9, 10}, {9, 8}}       }     (* t[[i,j,k]    i\[Rule]tramo Nºi    j\[Rule] \     1=Inicio=Pick-Up  2=Fin=Drop-Off     k\[Rule] 1ª o 2ª componente (es \     decir x ó y) *)          Array[t2t, {10, 10}]     Array[t2tlist, {100, 3}]     Array[t2tlistsorted, {100, 3}]          For[i = 1, i <= 10, i++,      For[j = 1, j <= 10, j++,       If[i != j,        t2t[i, j] =          Sqrt[  (    t[[j, 1, 1]] - t[[i, 2, 1]]      )^2          +    (              t[[j, 1, 2]] - t[[i, 2, 2]]      )^2    ], t2t[i, j] = Infinity        (* Calcualmos los Kilometros para ir del tramo i al tramo j,         para lo que recurrimos a la raiz cuadrada de la suma de los \     cuadrados de la diferencia entre el principio(1) del tramo=        trip j   y el fin (2) del tramo=trip i *)        ]       ]      ]     For[i = 1, i <= 10, i++,      For[j = 1, j <= 10, j++,       t2tlist[10 (i - 1) + j, 1] = t2t[i, j];            t2tlist[10 (i - 1) + j, 2] = i;            t2tlist[10 (i - 1) + j, 3] = j;       ]      ]     t2tlistsorted = SortBy[t2tlist, First]     (*SortBy[t2tlist,First] *)      Can you correct my fault? In this image you can see the output lines


title: Make a histogram by giving the range and height of each bin one by one

text: I got the data of each bin by measurements like `{start, end, height}` and I want something like this picture: http://tinypic.com/view.php?pic=2i208hs&s=5 I have no other data for the `Histogram[]`, just what you can see on the linked picture. So any ideas how to do this in _Mathematica_ (version 9)? (The whole thing is for fitting a distibution curve on it.)


title: Avoiding RandomVariate update with use of Locator

text: I am preparing an activity that simulates the response from a noisy spectrometer. The function I use to generate the data has the form:               curve[a_, x_] :=        a PDF[NormalDistribution[0, 1], x] +         RandomVariate[NormalDistribution[0, 0.03]];      Which produces something like:               Plot[curve[1, x], {x, -5, 5}, PlotPoints -> 200, MaxRecursion -> 2]      ![enter image description here](http://i.stack.imgur.com/bppS9.png) and I can get the coordinates using a right mouse button click on the plot. The right mouse button works differently in a CDF than it does in a Notebook and I would like to ultimately turn this activity into a CDF-enabled web page. My first attempt is to use a `Locator`               ControllerManipulate[      Plot[curve[1, x], {x, -5, 5}, PlotPoints -> 200, MaxRecursion -> 2,        Epilog -> Inset[p, Scaled[{0.9, 0.9}]]], {p, Locator}]      ![Mathematica graphics](http://i.stack.imgur.com/GR9O0.png) Which does the job except that when I move the locator, the "noise" in my plot changes. How do I modify my `curve` function so that I maintain the ability to generate a "unique" noise pattern each time `curve` is called but it does not continuously update when the end user moves a locator?


title: Why are we so sure about Map results?

text: I do abuse it often but when I have faced this feature first time I was really suprised:               i = 0;     (i++; # - i) & /@ Range[5]      > {0, 0, 0, 0, 0} What am I asking about is **how do we know`Map` will do 'mapping' position after position?** Of course it might look logical but it is not stated, and then, since I know nothing about memory allocation etc., I could expect strange results. To be more precise, I could expect them only in cases where mapping funcion is changing during mapping. I have failed to find a word in documentation, only related but **not important** in this case: > Leaves are visited before roots * * * Have I missed something?


title: Normalization of eigenvectors

text: I am trying to normalize the following vector in _Mathematica_ with the `Normalize` command. $$(-1+2\cot[x]\csc[x]+2\csc[x]^2,\;2^\frac{1}{2} (1+\cos[x])\csc[x],\; 1)$$ I specified that the argument was real, but keep getting `Abs` in my answer. Is there anyway around this?


title: Plot image function together maintaining compatibility between their coordinate systems?

text: Is it possible to plot an image, i.e., draw it's pixels against usual coordinates? My goal is to plot my image and my function in the same coordinates. **Update** I drew an image of size `200x100` and drew a spot at `100,50`. When plotting it should coincide with actual coordinates, but it doesn't. ![enter image description here](http://i.stack.imgur.com/lQate.jpg) i.e. image takes random size and random scale both unrelated with plot size and scale. While I need each pixel be located at it's correct coordinates, not only image corner. **Update 2** Why `Image` is not a `Graphics` primitive or directive?


title: Axis/Angle from rotation matrix

text: With `r=RotationMatrix[a,{x,y,z}]` I can compute a 3D rotation matrix from axis/angle representation. Given a 3D rotation matrix `r` how can I compute `a, x, y, z`? Example:               r = {{0.966496, -0.214612, 0.14081}, {0.241415, 0.946393, -0.214612}, {-0.0872034, 0.241415, 0.966496}}      The result should be `a=20. Degree` and `{x,y,z}={2, 1, 2}/3` (or equivalent). **Edit:** I am fine with any answer that gives the same `r` when applied to `RotationMatrix`. PS: Sorry if the tag is wrong, I did not found a matching tag...


title: What is the correct way to provide Mathematica with a path to Python user scripts?

text: What is the correct way to provide _Mathematica_ with a path to Python user scripts? Simply executing Python as a shell command, using something like               usefulOutput = Import["!python -c 'import mypkg; mypkg.use()'", "Text"];      fails, because _Mathematica_ — like many IDEs and Python launchers — has no access to (or at least ignores) `PYTHONPATH` or any `sys.path.append` in 'shell_config.py'. I seem to be able to `Run` shell scripts without errors, but that's not what I'm looking fore here. Does _Mathematica_ provide a setting for extending `python.path` or is there a related directory setting in _Mathematica_ that would result in my scripts being found?


title: Manipulate: size of controls

text: As you can see in the drawing, I'm making a little Manipulate program. I'd now like to decrease the size of the controls at the left—to have more space for the `Graphics[]`. How is this possible? I've searched in the Documentation, but haven't found anything helpful. Perhaps is it possible to use the grey space in the left part of the screen for displaying purposes (`Print` or `Text`)? For example, print the Cosine of the angle `alpha` somewhere in the left `Pane`? Thanks for all help! ![enter image description here](http://i.stack.imgur.com/yqQro.png)


title: Missing V9 Menu: File -> New -> FreeCDF

text: I can run CDFs fine, and can export Notebooks as CDFs. But the `File -> New` menu does not contain a `FreeCDF` option, just the `Package` and `Text File` options. What am I missing? M9.0.1.0 on Mac OS X Mavericks.


title: How do I display imported images at actual size?

text: I know that this is an extremely basic question, but I am having a lot of trouble finding the answer in the documentation. When I import an image (for example, `Import[test.png]`), Mathematica often displays it smaller than the _actual_ size of the image. How do I force Mathematica to display the imported image at actual size? I may want to display such images using `Grid`. For example, suppose that `fname` is a list of ***.png** file names. Then I may want to import and display all of those images using a command like:               fname = FileNames["*.png"];     table = Transpose[{fname, Table[Import[fname[[i]]], {i, 1, Length[fname]}]}];     Grid[table]      and I'd like the images displayed at actual size. I know that this is a very basic question, but I really appreciate your time.


title: Complex valued 2+1D PDE Schroedinger equation, numerical method for `NDSolve`?

text: Based on the heat equation of the Mathematica Manual tutorial, I wrote the complex counterpart (Schroedinger) equation, for the free particle propagation of an initial wavepacket.               NDSolve[      {       I D[u[t, x, y], t] == -D[u[t, x, y], {x, 2}] -          D[u[t, x, y], {y, 2}], u[0., x, y] == Exp[-(x^2. + y^2.)],        u[t, -5., y] == u[t, 5., y], u[t, x, -5.] == u[t, x, 5.]       }, u, {t, 0., 1.}, {x, -5., 5.}, {y, -5., 5.}      ]      However the solver chokes with serveral warnings, the most serious being that the Maximum number of iterations has been reached that stops the calculation at `t == 0.48`. But the worst is that the solutions (plotted with `Table[Plot3D[ Evaluate[Abs[u[t, x, y] /. First[sol]]^2], {x, -5, 5}, {y, -5, 5}, PlotRange -> All, PlotPoints -> 100, Mesh -> False], {t, 0.0, 0.05, 0.01}]`) looks completely wrong with diverging values. **I know the`NDSolve` is not magic but does anybody know of an option to pass that will make this problem tractable with `NDSolve`?** I couldn't find a coherent explanation of the `NDSolve` options in the manual or anywhere else. Otherwise I would be playing with known methods of propagation, like Crank-Nicolson (for time propagation) and spectral methods (for spatial coordinates). A first nice step would to control the spatial (`x` and `y`) resolution and the time (`t`) resolution independently. **Note 1:** One knows that the time propagation of this problem for that particular initial condition is a simple spreading Gaussian probability, in particular the solution is well defined and smooth. **Note 2:** I tried with and without periodic boundary conditions in both cases the result is numerically wrong (diverging values). **Note 3:** I did some progress for the simpler 1+1D equation, that problem is well undercontrol with most of the defaults/automatics of `NDSolve`, I can propagate for a while:               sol = NDSolve[       {        I D[u[t, x], t] == -D[u[t, x], {x, 2}], u[0., x] == Exp[-(x^2.)],         u[t, 5.] == 0, u[t, -5.] == 0        }, u, {t, 0., 20.}, {x, -5., 5.}, MaxStepSize -> 0.1       ]     Animate[Plot[Evaluate[Abs[u[t, x] /. First[sol]]^2], {x, -5, 5},        PlotRange -> {0, 1}], {t, 0, 17, 0.01}]


title: Convert Mathematica formula to TeX (MathJax) with color

text: Case1: formula generated by functions.               Nest[1 + 1/Style[#, Red] &, x, 5]          (*         1+1/(1+1/(1+1/(1+1/(1+1/x))))     *)          TeXForm[%]          (*         \frac{1}{\frac{1}{\frac{1}{\frac{1}{\frac{1}{x}+1}+1}+1}+1}+1     *)      Case2: formula typed by hand(or copy from elsewhere) in inline `InlineFormula` style cell or in `DisplayFormula` style cell. This is an inline formula with coloring ![Mathematica graphics](http://i.stack.imgur.com/CFT7k.png) Some posts or answers at Math.SE you would see are with colored TeXForm output rendered. Here is one sample http://math.stackexchange.com/a/432154/76942 If you are interested that, you may find some more samples, it's helpful by highlighting questionable part of the formulas when asking in Math.SE or Mathematica.SE.                Consider the analytic formulas relating the $\color{#00A000}{\text{vertices}}$      , $\color{#C00000}{\text{midpoints}}$, and $\color{#0000FF}{\text{median}}$:      > $\color{#C00000}{\text{midpoints}}$, and $\color{#0000FF}{\text{median}}$:


title: Plot a solid generated by a family of surfaces

text: I'm trying to graph a series of planes as a solid object in _Mathematica_. I first tried to use the `Plot3D` options as well as the fill options to plot a $3D$ volume, but was unable to find a working result. The graphics I'm trying to create will show the deviation between the $z$ axis and the radius from the origin of a $3D$ cuboid. The current equation I'm using is this:               Plot3D[Evaluate[{ Sqrt[(C[1])^2 + x^2 + y^2]} /. C[1] -> Range[6378100, 6379120]],               {x, -1000000, 1000000}, {y, -1000000, 1000000}, AxesLabel -> Automatic]      Where `C1` was the original $z$-value at each plane and the result of this equation is $\; z+(r-z)\;$ for any point on the $(x,y)$-plane. Output for more manageable range looks as follows ![enter image description here](http://i.stack.imgur.com/svwNk.jpg) However this method is incredibly inefficient. Because this will be used to model large objects with an original $z$-values of $>6,000,000$ and heights above $1000$, _Mathematica_ is unable to graph thousands of planes and represent them in a responsive method. Additionally, because the `Range` of `C1` only includes integer values, there is discontinuity between these planes. Is there a way to rewrite this using different _Mathematica_ functionality that will generate a $3D$-plot that is both a reasonable load on my system and is a smooth object? 2nd, What can I do to improve my perforamance? when computing the above input for $>30$min, _Mathematica_ was only utilizing about $30$% _CPU_ and $4$_GB_ of ram with a light load on my graphics card as well. This is only about twice as much as Chrome is using right now on my system. I attempted to enable _CUDALink_ , but it wouldn't enable properly. Would this offer a performance boost for this type of processing? For a reference, my system build is: $16$_GB Ram Intel i7 4770K_ running at stock settings _Nvidia GeForce 760GTX 256 Samsung SSD_ I'm running _Mathematica 9_.


title: How to discriminate Weatherdata latitude and longitude from a more detailed list

text: From this list of weather data how can I discriminate only latitude longitude for each station? For example from the following sample I would need only the coordinates:   * "50136","","Aoluguya|Mohe, 15","","CN", **52.13333,122.51667** ,433   * "50246","","Tahe|Ta-He, 23","","CN", **52.33330,124.80000** ,465   * "50349","","Jinsong|Jiu-Hai-Lai, 15","","CN", **51.13330,124.05000** ,610


title: Specifying an array with a specific number of copies of two elements

text: To specify an array of length `L` in Mathematica, where each entry is `someElement`, I'm accustomed to writing:               exArray=Array[someElement &, L];      However, let's say that I want to (quickly) generate an array of length `L` where there are `n` copies of `elementOne` and `L- n` copies of `elementTwo`. Maybe `elementOne` is the string character `A` and `elementTwo` is the string character `B`. I'd like to be able to position the two elements in two different ways: (1) where the first `n` elements are all `elementOne` and the remaining elements are all `elementTwo`, and (2) where we have a uniform random sample from the set of all possible arrays where there are `n` copies of `elementOne` and `L - n` copies of `elementTwo`. Are there simple "one-liners" to do (1) + (2)?


title: Eliminate complex answer to differential equation

text: I've tried the following:               In[32]:= DSolve[{y'[x] == (x + 2)/(x*(3 - x)), y[4] == 2}, y[x], x]          Out[32]= {{y(x)->1/3 (-5 log(3-x)+2 log(x)+5 I \[Pi]+6-2 log(4))}}          In[57]:= z[x_] := 2/3*Log[x] - 5/3*Log[x - 3] + (2 - 2/3*Log[4])          In[58]:= z[4]          Out[58]= 2          In[59]:= D[z[x], x]          Out[59]= 2/(3 x)-5/(3 (x-3))          In[60]:= Simplify[-(5/(3 (-3 + x))) + 2/(3 x)]          Out[60]= (x+2)/(3 x-x^2)      In[32] produces an answer with a complex number. In[57] is the answer I generated by hand and you can see that it checks. How do I use DSolve to produce the answer In[57]?


title: How to find intervals in the domain corresponding to intervals in the range?

text: I want to find the intervals for the argument `m1` of this function corresponding to the value for the function lying in given intervals of the range:               F1==Sqrt[2] Sqrt[Sqrt[1/m1^2 + 20 Sqrt[3118] (1/m1)^(3/2) Sqrt[1/50] +         3118020 Sqrt[3118] Sqrt[1/m1] (1/50)^(3/2) + 24304810001/50^2 +         623602/(m1* 50)] - 10 Sqrt[3118] Sqrt[1/m1] Sqrt[1/50] - 155900/50]      and graph for this function is: ![enter image description here](http://i.stack.imgur.com/LpVWm.jpg) For example I want to find the range of intervals of `m1` when I divide a given range for `F1` into 10 equal intervals. How do I tell the software to divide a range into 10 equal interval and give the corresponding intervals for `m1`?


title: How to fold output cells by default?

text: In _Mathematica_ the default behavior of output cells is to pop up after the kernel has processed the input cells and got a result. I know I could add `;` in the end of input cells to disable output cells, which are often too messy in the middle of my calculations and usually I don't really care what they are, from appearing. However sometimes I need to go back and check some stuff, so it is still necessary to keep those intermediate results there. Then my questions is that **is it possible to "fold" output cells?** By "folding" I mean it would look as if I manually double click the cell, so the output cell will be hidden and an arrow appears next to the input cell. I tried to find some related settings described in this post, but nothing useful there. Thanks!


title: Usage of Assuming for Integration

text: For some reason, when I enter the following integration in Mathematica               Assuming[{k ∈ Integers}, Integrate[ Exp[ I k t], {t, -π, π}]]      the result turns out to be 0. However, clearly, if $k = 0$, the integral should evaluate to $2\pi$ instead. Can someone explain this behavior?


title: Inequalities with assumptions and constraints

text: I'm using Mathematica 8 I've been searching the net without luck for this specific solutions: Suppose I have an inequality f(x;M,m)>0 where I KNOW that M>4m and m>0. How can I let _Mathematica_ know this so that when solving the inequality using `Reduce` I don't get twenty irrelevant solutions, but instead only solutions where 0<4m I've used assumptions and so on but without luck, for instance:               Assuming[m > 0, Reduce[(x + m)*(x - m) < 0]]      Produces;               x \[Element] Reals && (m < -Sqrt[x^2] || m > Sqrt[x^2])      `m<-Sqrt` is unnecessary here, so why does _Mathematica_ write it out? How can we stop it?


title: Simplification of integrals depending on a parameter

text: Assuming[Element[n, Integers], Integrate[Sin[x]*Sin[n*x],{x,0,Pi}]]      returns 0, which is obviously wrong for n=1.               Assuming[n==1, Integrate[Sin[x]*Sin[n*x],{x,0,Pi}]]      does return Pi/2 (so in particular not 0). Just evaluating the integral yields               -Sin[n*Pi]/(-1+n^2)      which is indetermined for n=1. Can someone explain to me what Mathematica is doing and how to obtain a correct result?


title: When and why are Assuming and Assumptions not equivalent?

text: In this question there's an example of an integral where using `Assuming` and `Assumptions` give different results:               In[1]:= Integrate[Cos[n x], {x, 0, Pi}, Assumptions -> Element[n, Integers]]         Out[1]= Sin[n π]/n          In[2]:= Assuming[Element[n, Integers], Integrate[Cos[n x], {x, 0, Pi}]]     Out[2]= 0          In[3]:= Integrate[Cos[n x], {x, 0, Pi}, Assumptions -> Element[n, Integers]]         Out[3]= Sin[n π]/n      Now let's clear the system cache (or restart the kernel if you like) and try again, but now in a different order:               In[4]:= ClearSystemCache[] (* fresh start! *)          In[5]:= Assuming[Element[n, Integers], Integrate[Cos[n x], {x, 0, Pi}]]     Out[5]= 0          In[6]:= Integrate[Cos[n x], {x, 0, Pi}, Assumptions -> Element[n, Integers]]     Out[6]= 0      To make things even more weird, the results are affected by the order these two versions are evaluated (clearly due to caching). `In[6]` and `In[3]` are the same but they return different results. I always assumed that using `Assuming` or `Assumptions` with built-in functions should be equivalent. It seems this is not true. I can imagine that `Integrate` uses something internally (e.g. `Refine`) that is affected by the global `Assuming`, but not by `Assumptions`. Generally, when are `Assuming` and `Assumptions` not equivalent? Is the result I quoted above a bug? * * * **EDIT:** As Artes and Michael noted in the comments, this is explained by Daniel Lichtblau here. My only remaining worry is that the results are cached and effectively depend on the order of evaluation.


title: strange result with trigonometric triple integral

text: I'm defining functions                   e[k_, t_] := Cos[Pi (k - 1) t]         cosIntRaw[k_, l_, m_] := Integrate[e[k, t] e[l, t] e[m, t], {t, 0, 1}]         cosInt[k_, l_, m_] :=             Assuming[Element[{k, l, m}, Integers], Refine[cosIntRaw[k, l, m]]]      The value that Mathematica gives me for `cosInt[k,l,m]` is `0`. But explicitly evaluating `cosInt[1, 1, 1]`, I get `1`. In fact, for any given value of `m`, the number of nonzero elements in the `n`$\times$`n` matrix whose `[k,l]` element is `cosInt[k,l,m]` grows linearly in `n`, said matrix having a nice banded structure. Any idea why Mathematica gives me `0` for `cosInt[k,l,m]`? Thank you!


title: How do I make a frequency table from a histogram (data set)?

text: I have a data set.               dataA = {0.37, 0.51, 0.55, 0.78, 0.99, 1.35, 1.49, 1.50, 1.56, 1.61,         1.67, 1.70, 1.89, 1.97, 2.05, 2.16, 2.18, 2.32, 2.41, 2.45, 2.48,         2.49, 2.50, 2.51, 2.52, 2.53, 2.54, 2.65, 2.75, 2.80, 2.85, 2.99,         3.00, 3.15, 3.23, 3.29, 3.44, 3.45, 3.46, 3.47, 3.49, 3.50, 3.51,         3.62, 3.65, 3.66, 3.82, 3.84, 3.99, 4.00, 4.12, 4.23, 4.33, 4.44,         4.45, 4.46, 4.49, 4.52, 4.62, 4.99, 5.20, 5.40, 5.59, 5.99};      I'm able to convert the data to a histogram and analyze the histogram against a binomial distribution. As:               Show[Histogram[dataA, {-0.5, 6.5, 1}, "PDF"],       DiscretePlot[PDF[BinomialDistribution[6, 0.5], x], {x, 0, 7},        PlotStyle -> PointSize[Large]]]      How do I convert my data set (histogram) to a frequency table?


title: Interactively extract points from a plot (ListPlot or SmoothDensityHistogram)

text: Is there a way to dynamically define a polygon on a plot (I'm working with `ListPlot` and `SmoothDensityHistogram`) to select a cluster of interest, and give the positions of those points in the original list of data? I'd appreciate any help! Here's just an example set of points:               x = {          {RandomReal[{0, 5}, 20],           RandomReal[{4, 4.5}, 10]},          {RandomReal[1, 20],           RandomReal[{1.5, 2}, 10]}         };          points = Transpose[Join @@@ x] ~RandomSample~ 30;          SmoothDensityHistogram[points, ColorFunction -> "TemperatureMap"]     ListPlot[points, PlotRange -> {{0, 5.5}, {0, 2.5}}]


title: How to use an arbitrary closed region to extract an image region of interest

text: I am working on images and I need to be able to extract into a list all the image points that fall within a closed region, such as gotten from using "get coordinates". I can extract the points from the region such as:               contour = ContourPlot[x^2 + y^2 == 1, {x, -1, 1}, {y, -1, 1}]          points = Cases[Normal@contour, Line[x_] :> x, Infinity];          lfp = Length[Flatten[points, 1]];          circlepoints = Table[{Flatten[points, 1][[i, 1]], Flatten[points, 1][[i, 2]], 1},      {i, 1, lfp}];          ListPointPlot3D[circlepoints]      And now I would like to use the points on the circumference and the interior to select only those points in my image that fall on or within the circle and to set the remaining, exterior image points to zero. Here is a test image:               image = Table[{i, j, 2}, {i, 0, 1, .025}, {j, 0, 1, 0.025}];          ListPointPlot3D[image]      I tried to use `winding[points,0]`, as suggested, to test if the center of the circle is within the circle, but I get: > During evaluation of In[133]:= ArcTan::argt: ArcTan called with 318 > arguments; 1 or 2 arguments are expected. >> > > Out[136]= {0, 0} Clearly, I don't understand the input syntax for `winding[]`


title: how to interactively select points inside certain region in a plot

text: Very often I encounter a situation that I want to select some points inside certain areas of a plot. For example,               p1 = Graphics[Point[Table[{Random[], Random[]}, {200}]]]      will give a plot. If I use MMA's drawing tool to draw a region in the plot, p2=![enter image description here](http://i.stack.imgur.com/7Y7iB.jpg) how I get the plot dynamically updated so that it shows only the points inside that region? * * * Here is my attempt. I use the function `inPolyQ` by rm -rf at here to test whether the points is inside the region or not.               lines = First[Cases[p2, Line[x_] :> x, \[Infinity]]];     pts = First[Cases[p2, Point[x_] :> x, \[Infinity]]];     inPolyQ[poly_, pt_] := Graphics`Mesh`PointWindingNumber[poly, pt] =!= 0     slctPts = Select[pts, inPolyQ[lines, #] &];     Graphics[{Point[slctPts], Line[lines]}, AbsoluteOptions[p1]]      the out put is ![enter image description here](http://i.stack.imgur.com/Lc7aJ.jpg) I have two problems:   1. How can I change it to a efficient function that can do all this dynamically on a plot(or may density plot), and with the option to output the selected data points?   2. There is a problem that sometimes I actually select more points than I want. Like in the example, there are two points outside the region are also selected. Is there a way to solve that? Thanks.


title: Complex Values in TSV

text: I have some data in TSV format and am attempting to import it into Mathematica. Real values import just fine, but complex values keep on getting interpreted as strings. I attempted to figure out what format Mathematica was looking for by exporting some complex values in TSV, but interestingly enough Mathematica fails to import complex TSV values that it exported itself! Is there any way to import complex values through TSV in Mathematica?


title: How do you check if there are any equal arguments(even sublist) in a list?

text: I would like to set up a function which has to return True if at least two arguments of a given List are equal. So if I give `{1,4,6,2}` to the function it has to return `False` (since none of his arguments are equal) and the same would happen if I gave `{{1,2,3},{2,3,4}}`, while if I gave `{1,2,3,1,4}` or `{{1,2,3},{2,0,0},{1,2,3},{2,1,2}}` it has to return `True`. I know this is a very simple problem and i think you can easily tell me a convenient way to achieve that.


title: Setting the context automatically based on section

text: Suppose I have a task that keeps things organized using contexts, so:               windowLength = 10;     Begin["chocolate`"];     data = RandomReal[NormalDistribution[], 100];     ListPlot[MovingAverage[data, windowLength]]     End[]     Begin["vanilla`"];     data = RandomReal[StudentTDistribution[1], 100];     ListPlot[MovingAverage[data, windowLength]]     End[]      Now, if I want to go back and do something in the `chocolate` context, I have to remember to re-run the line that enters that context or things can get very confusing and mistakes can easily be made. It would be really neat to instead use wiggle-4 to create a Section called "Chocolate" and for everything in that section to run in the `chocolate` context. Is there a way to set the context automatically based on the section of the notebook a cell is in?


title: Plot least squares curve on Linear Log Plot

text: I have the following Data:               ExpDataCycles = {23, 69, 39, 25, 6, 43, 431, 328, 130, 614, 5941,         4506, 1876, 7898, 27015, 19154, 11586, 21470,        130885, 431405, 84036, 1003250};     ExpDataMpa = {835.0265363, 823.4175447, 810.7696175, 799.6485919,         794.4425228, 793.0602069, 707.6873459,        704.8236368, 693.9200675, 687.0103167, 609.8345095,        602.6188024, 598.086902, 595.6103517, 591.5466695,        584.7172701, 559.4813142, 556.6416481, 551.1841848,        541.232457, 539.3158579, 385.3438704};      Which I plot using `ListLogLinearPlot`               ListLogLinearPlot[Transpose[{ExpDataCycles, ExpDataMpa}],       PlotRange -> Automatic, AxesLabel -> {"Cycles [N]", "Stress Mpa"},       PlotLabel -> "S-N Cyclic Loading Life at R = -1 "]      ![enter image description here](http://i.stack.imgur.com/TTiiy.jpg) I'm trying to plot a best fit curve using least squares. I plot using:               ExpDataCyclesMpa = Transpose[{ExpDataCycles, ExpDataMpa}];     LeastSqr = Fit[ExpDataCyclesMpa, {1, x, x^2}, x];     Show[ListLogLinearPlot[Transpose[{ExpDataCycles, ExpDataMpa}]],       Plot[LeastSqr, {x, 0, 1100000}]]      ![enter image description here](http://i.stack.imgur.com/4qHTn.jpg) I understand the issue of the straight lines which i thick is because my x-axis is in Log form. How can I Plot a quadratic least squares fit between the LinearLog graph?


title: relative scale of elements in ImageCompose

text: My code:               sqrSize = 16/2;     dots = Flatten[Table[{2 i + Mod[j, 2], j Sqrt[3]},                           {i, -sqrSize, sqrSize}, {j, -sqrSize, sqrSize}], 1];     inner = Select[dots, Norm[#] <= 5 &];     zePlot = ListPlot[{dots, inner}, PlotRange -> {{-sqrSize, sqrSize}, {-sqrSize, sqrSize}},          AspectRatio -> 1, Axes -> None, PlotStyle -> {{PointSize[0.02]}},          Epilog -> {Circle[{0, 0}, 5], PlotStyle -> {Blue, Opacity[0.2]}}];     ImageCompose[zePlot, {Graphics[{Blue, Disk[{0, 0}, 5]}], 0.2}]      gives this `Plot` as result: ![enter image description here](http://i.stack.imgur.com/UuyZg.png) Two issues:   1. The disk seems to use another scale than the rest of the image; I'd like to have it the same size as the circle   2. (not in the code yet) Instead of the disk I'd like to have its complement, i.e. the area outside the circle should be blue, inside the circle white. How can I achieve these?


title: How can I find the source of a memory leak?

text: I found a really weird issue using NDSolve`ProcessEquations inside module. We start by setting HistoryLength to 0. After this we define a function which takes in an integer and creates a Table of stateData Objects of the desired length and returns a list containing a string and the list of stateData objects. To show how much memory the local objects use I make use of the Print[] function.               $HistoryLength = 0;     Clear[prepareEquations]     prepareEquations[iMax_] :=        Module[{stateDataList, output},         stateDataList =          Table[           First @             NDSolve`ProcessEquations[{y''[t] + y[t] == 0, y[0] == 1, y'[0] == 0}, {y, y'}, t],            {i, 1, iMax}];         Print["ByteCount stateDataList :", ByteCount[stateDataList]];         output = {"hello", stateDataList};         Print["ByteCount output :", ByteCount[output]];         output       ];      First we want to see how much memory we use before calling the functions.               MemoryInUse[]      > >     30105504 >   Alright, so about 30.1 mb. Now we call the function with an input value of 5000. The function will at the same time print how much memory the local objects use.               finalList = prepareEquations[5000];     ByteCount stateDataList :87590968     ByteCount output :87591064      So the output takes about 87.6 mb. So we would assume that the total memory used after calling this function would be about `30.1+87.6=117.7` mb. But instead we have               MemoryInUse[]      > >     164795040 >   Which is about 164.8 mb. Hence there seems to vanish about `164.8-117.7=47.1` mb. If i look into my global context, finalList takes up as much memory as the ByteCount of output. If I change the output to not return the stateDataList by for example `output={"hello",1}`, no memory is leaked. Where does the extra memory go when I return a list of stateData objects? Notice that local variables `y$1235`, `y$125`, ..., and so on is leaked to the global context. I removed them by               Remove /@ Select[Names["Global`*"],StringMatchQ[#1, "y$" ~~ DigitCharacter ..] &];      and the memory used after this was               MemoryInUse[]      > >     164518400 >   so they don't seems to have a major impact. If i look into my global context it looks like this               Reverse@SortBy[Map[{#, ByteCount@ToExpression[#]} &, Names["Global`*"]], Last] //TableForm      > >     {"finalList", 87591064}, >     {"y", 0}, >     {"t", 0}, >     {"stateDataList$", 0}, >         {"stateDataList", 0}, >         {"prepareEquations", 0}, >         {"output$", 0}, >     {"output", 0}, >     {"iMax", 0}, >     {"i", 0} >   So the memory leaked doesn't show up here. Can someone help me figure this out?


title: Solve Probability of Distribution

text: Why does this work:               Solve[Probability[x <= t, x \[Distributed] NormalDistribution[]] == 0.95 ,t]      But this doesn't:               Solve[Probability[x <= t,x \[Distributed] StudentTDistribution[2.964, 2.071, 5]] ==0.95,t]      How can I solve this problem?


title: Module trash collection behaviour

text: I have asked this question before on the Wolfram community forum (http://community.wolfram.com/groups/-/m/t/83845?p_p_auth=Gxoxe65B) but not with great success. Module creates temporary variables of the form x$NNN which when no longer used are removed. However under certain conditions the temporary variables created by Module are not removed and remain in the global context. If this happens for a Module inside a frequently used function, this leads to memory leak situation where the memory usage of the kernel grows linearly with time. (Which is not good when doing numerical runs of several days). In certain situations, this behaviour is explainable and probably a feature. Generally, speaking it usually involves some side effects which cause something outside the module to reference the temporary variable. # Some examples ## 1.               Module[{x}, x /. NDSolve[x'[t] == 1 && x[0] == 0, x, {t, 0, 1}][[1]]]      Result: x$NNN is not removed. Reason: NDSolve stores some expressions referencing x$NNN in the system cache. Solution: Clear system cache. (Presumably this will happen on its own as the kernel session progresses.) ## 2.               Module[{y, z, a, b}, a = y + z; b = 2*a];      Result: y\$NNN and z\$NNN are not removed from global context. Reason: y\$NNN and z\$NNN appear in the module output and are thus referenced by Out. Solution: Clear Out, or more systematically limit the History Length through $HistoryLength ## 3.               Module[{x}, f = x]      Result: x\$NNN is not removed from global context. Reason: Definition of f is referencing x\$NNN Solution: Clear f. # Behaviour that I do not understand In addition to these well-understood cases, there some cases where I do not understand why mathematica is not removing the temporary variables after use: ## 4. (from a different thread I found when looking for an answer)               a[b_] := Module[{x}, x := 1; x /; b]     a[True]      Result:a x$NNN is permanently placed in the global context every time a[True] is called. Reason: Unknown. This appears to be a bug. Possibly related to how mathematica handles conditionals combined with Module (Clear and ClearSystemCache[] do not remove the x$NNN.) ## 5.               Module[{a, b},     a[i_] := b[i - 1];     b[i_] := a[i - 1]]      Result: a\$NNN and b\$NNN remain in global context. Reason: Unknown. Bug? Related to circular references of temporary variables. Edit: Some experimentation has lead me to simplify this example. It has confirmed to me that this must be related to circular referencing since the temporary variables disappear after clearing their definitions with               Clear["a\$NNN", "b\$NNN"]      It is essential that the variable names are input as a string, to avoid referencing them from the input history. Interestingly enough both temporary variables remain if you clear only one of the definitions using:               Clear["a\$NNN"]      or               Clear["b\$NNN"]      This behaviour seems very buggy to me. At least a cannot think of a reason why this should happen by design. ## Other cases In addition to these cases I have seen this happen for more complicated functions involving Module, which I have not been able to trace to a simple cause. It would be incredibly helpful for me to understand why this is happening (and how to avoid it). And related if it cannot be avoided: What is the best way of dealing with the stray temporary variables?


title: Is it possible to manipulate a graphics object with 3 rotation transforms simultaneously?

text: The code that I have written has an unintended consequence that I'm not sure how to get around. I want 3 rotation transforms to be applied simultaneously to 1 graphics object. Instead, I get 3 separate separate copies of the graphics object, one per transformation. The documentation does state that this will be the outcome of using multiple transformations on a graphics object. > GeometricTransformation[g, {t1, t2, ...}]   >  **_represents multiple copies_** of g transformed by a collection of > transformations. My question is: how is it possible to achieve the the outcome that I described instead of getting multiple copies? Here is the code I am executing:               Manipulate[       Graphics3D[{         EdgeForm[None],          GeometricTransformation[Cylinder[],            {RotationTransform[a Pi, {1, 0, 0}],             RotationTransform[b Pi, {0, 1, 0}],             RotationTransform[c Pi, {0, 0, 1}]}]}],        {{a, 0}, -1, 1},        {{b, 0}, -1, 1},        {{c, 0}, -1, 1},        SaveDefinitions -> True]      If anyone could show me a way to accomplish this, I'd appreciate it.


title: Using Collect with equations

text: Is it possible to somehow use the expression that Mathematica has collected once the `Collect` command has been used? What I mean is, I have an expression like this (this is imaginary example)               (a[x,y]+b[x,y]+c[x,y]^2) z^5+a[x,y]^3 z^4+(b[x,y]+c[x,y]^4) z^3      That I got after I made `Collect[expression,z,Simplify]`. What I'd like to do is to have command that will, for instance, give me the term that goes along `z^5` (the `(a[x,y]+b[x,y]+c[x,y]^2)`)? I didn't find any examples of it, and `Collect` in help has no such examples. EDIT: Can this be done with the help of `Coefficient` command?


title: How can I create a fountain effect?

text: Inspired by this (please use Chrome or Firefox), I tried to simulate it, but I couldn't do it. I'm not familiar with `Dynamic`. Here is my simple code:               Dynamic[      Graphics[{Hue[Random[]], PointSize@Large,         Point[{0, Dynamic[Clock[{0, 5, 0.5}]]}]}, Axes -> 1, PlotRange -> 5]      ]


title: Making single letters non-italic in Graphics/Text/Style objects

text: Suppose that I use `Graphics`, `Text`, and `Style` to type one letter in the subscript of a letter and one in the superscript of the same letter. In the Writing Assistant in Mathematica 9, I click the ![button](http://i.stack.imgur.com/P8OSX.png) button to help typeset the string in this command:               Graphics[Text[       Style["\!\(\*SubsuperscriptBox[\(A\), \(B\), \(C\)]\)", 30,         FontFamily -> "Arial"]]]      The graphical output is the following. ![example](http://i.stack.imgur.com/Dic0L.png) Why do the letters A, B, and C appear italic, even though I did not specify them as such? I want the letters to all be regular font. The italicization does not happen if I take out the `Graphics` directive, and just use `Text` and `Style`. But I have to use `Graphics` because I will ultimately include it in a plot.


title: How to plot a region bounded by three equations?

text: I'm very new to this website. I am having trouble plotting a 3 dimensional region bounded by these equations:               R = {y == x <= y == - x + 2 <= y == -Sqrt[1 - (x - 1)^2]}      The problem is that I know what command to use to do this, but it gives me a blank plot. If it helps my code is below, and I have _Mathematica_ Version 7.0:               RegionPlot3D[       y == x <= y == - x + 2 <= y == -Sqrt[1 - (x - 1)^2],        {x, -10, 10}, {y, -10, 2}, {z, -10, 10}]      If someone could lead me to the right direction or tell me what is wrong, I would greatly appreciate it.


title: Help find a bright object on Mars!

text: In today's news, scientists found a bright object on one of Curiosity's photos (it's near the bottom of the picture below). It's a bit tricky to find - I actually spent quite some time staring at the picture before I saw it. ![Bright object](http://i.stack.imgur.com/z2jmA.jpg) The question, then, is how one can systematically search for such anomalies. It should be harder than famous How do i find Waldo problem, as we do not necessarily know what we are looking for upfront! Unfortunately, I know next to nothing about image processing. Playing with different _Mathematica_ functions, I managed to find a transformation which makes the anomaly more visible at the third image after color separation -- but I knew what I was looking for already, so I played with the numerical parameter for `Binarize` until I found a value (0.55) that separated the bright object from the noise nicely. I'm wondering how can I do such analysis in a more systematic ways.               img = Import["http://www.nasa.gov/images/content/694809main_pia16225-43_946-710.jpg"];     Colorize @ MorphologicalComponents @ Binarize[#, .55] & /@ ColorSeparate[img]      ![enter image description here](http://i.stack.imgur.com/tm6mR.jpg) Any pointers would be much appreciated!


title: How to select three points $A$, $B$, $C$ from the following list so that the circle passing $A$, $B$, $C$ has centre $(1,2,3)$?

text: I have the sphere $$(x-1)^2 + (y-2)^2 + (z-3)^2 = 36.$$ From the sphere, I find some points with integral coordinates. And select three points from this list so that the triangles are not right triangle. I tried               ClearAll[a, b, r];     a = 1;     b = 2;     c = 3;     r = 6;     ss = Subsets[{x, y, z} /.          Solve[{(x - a)^2 + (y - b)^2 + (z - c)^2 == r^2, x != a, y != b,            z != c}, {x, y, z}, Integers], {3}];     Pick[ss, (FreeQ[#, \[Pi]/2] &) /@ ({VectorAngle[#2 - #1, #3 - #1],            VectorAngle[#1 - #2, #3 - #2],            VectorAngle[#1 - #3, #2 - #3]} & @@@ ss)]      Now, I want to select three points $A$, $B$, $C$ so that the circle passing through points $A$, $B$, $C$ take the point $(1,2,3)$ as its centre. How can I select them?


title: Proof: Convergence of an equation and show the first derivative is bounded

text: We have the following equation \begin{equation} x(k+1)=\arccos\bigg( -\frac{1}{2(Dr^{\frac {|\sin(2x(k)+\theta)|}{M\sin x(k)\sqrt{A+2B\cos(2x(k)+\theta)}}}+1)} \bigg) \nonumber \end{equation} $A,B,D,r,M,\theta$ are constants.               x[k + 1] ==             ArcCos[-1/(Abs[Sin[2 x[k] + θ]]/(             2 (d r^(m Sin[x[k]] Sqrt[a + 2 b Cos[2 x[k] + θ]])) + 1))]      The equation above can be written as $x_{n+1}=f(x_{n})$. How do we show that it converges using _Mathematica_? How do we find the first derivative of the equation given above using _Mathematica_? Also, is that possible to show that the first derivative is bounded?


title: Hide function arguments (from unknown functions) for simpler output

text: How can I print my expression with my function's arguments hidden? For example:               exp=A[r,z]+B[s]^2;          HideArgs[exp]      Output:               A+B^2      The expression that could be tested is this one:               r^3*(Br[r, z]^2+Bz[r, z]^2)==E^(6\[Psi][r, z])*(r*D[\[Psi][r, z], z, z]+r*D[\[Psi][r, z],r,r])      Where the unknown functions are:               Br[r,z],Bz[r,z],\[Psi][r, z]


title: Comparing two symbolic expressions

text: Does _Mathematica_ provide any way to compare two symbolic expressions and find which is the greatest? For example, I want to find which is the greatest of `(n - 1) + 2(n - 1) Log[2, n]` or `n(n - 1)/2`, where `n` is a variable.


title: Extract a value from a list of InterpolatingFunction

text: By running the code               n = 5;     U[t_] := Table[Subscript[u, i][t], {i, 0, n}];     lines = NDSolve[{eqns, initc}, U[t], {t, 0, T}]      I get the output               {{u_0[t]->InterpolatingFunction[{{0.`,5.`}},"<>"][t],        u_1[t]->InterpolatingFunction[{{0.`,5.`}},"<>"][t],       u_2[t]->InterpolatingFunction[{{0.`,5.`}},"<>"][t],        u_3[t]->InterpolatingFunction[{{0.`,5.`}},"<>"][t],        u_4[t]->InterpolatingFunction[{{0.`,5.`}},"<>"][t],        u_5[t]->InterpolatingFunction[{{0.`,5.`}},"<>"][t]}}      (it's the solution of a system of ODEs that I obtain by discretizing a PDE with the method of lines). Now I would like to extract a particular value for each function, for example `u_2[0.5]` but I'm not managing to do that. Can someone help me? Thank you so much!


title: TableHeading Lines Do Not Show Up

text: For a list `list = {{"a", "b", "c"}, {"d", "e"}};` Table heading lines do not show up               TableForm[list, TableHeadings -> Automatic]      ![enter image description here](http://i.stack.imgur.com/tSSKJ.png) But it works if the list `list = {{"a", "b", "c"}, {"d", "e", "f"}};`               TableForm[list, TableHeadings -> Automatic]      ![enter image description here](http://i.stack.imgur.com/wjcq4.png) It seems the lines appear only for rectangular list. Is this a bug or i am missing something? I use v9.0.1 Thank you.


title: Ubuntu global menu bar integration?

text: Is there a way to integrate the Mathematica menu bar into the Ubuntu Unity global menu bar at the top of the screen? (I'm not looking to run mini- applications.) Thanks!