title: Bug with LinearProgramming on Integers?

text: With _Mathematica_ 7:               LinearProgramming[{1, 1}, {{0, 0}, {1, 1}}, {1, 1}, Automatic, Integers]      gives wrong result `{0,1}`. But               LinearProgramming[{1, 1}, {{0, 0}, {1, 1}}, {1, 1}, Automatic, Reals]      gives correct error: > LinearProgramming::lpsnf: No solution can be found that satisfies the > constraints. From my point of view this is a buggy behaviour, or did I miss something? Can someone confirm this for newer _Mathematica_ versions?


title: Plotting a list along with its trend line

text: Say I have these data:               data = {{1, 3}, {2, 4}, {3, 6}, {4, 7}};      I want to fit these data with a quadratic equation, like this:               Fit[data, {1, x}, x]      _Mathematica_ then outputs $1.5 + 1.4x$. However, trying to plot this like this:               Plot[Fit[data, {1, x}, x], {x, 0, 5}]      Results in the errors               General::ivar: 0.00010214285714285715` is not a valid variable.     General::ivar: 0.00010214285714285715` is not a valid variable.     General::ivar: 0.10214295918367347` is not a valid variable.     General::stop: Further output of General::ivar will be suppressed during this calculation.      I tried copying the $1.5 + 1.4x$ directly into `Plot`, after which I saw that it did not actually say $1.5 + 1.4x$:               Plot[1.5000000000000009` + 1.3999999999999995` x, {x, 0, 5}]      So that's where the ` came from. Surely removing them manually is not the way to go. What went wrong?


title: How to collect terms of a given type (with subscript and power) in an expression?

text: Suppose that I have an expression:               expr=(2 λ f[      z]^3 (λ (Subscript[λ, 0, 2] +           Subscript[λ, 2, 0]) - Subscript[λ^2, 0, 1] -        Subscript[λ^2, 1, 0]) - λ^2 (Subscript[z^2, 0,        1] + Subscript[z^2, 1, 0])^2 Derivative[1][f][z]^2 + f[z]^2 (4 λ^2 (-Subscript[z, 0, 2] Subscript[z, 2, 0] +           Subscript[z^2, 1, 1]) +        2 λ (Subscript[z, 0,            1] ((-Subscript[z, 0, 2] + Subscript[z, 2,                 0]) Subscript[λ, 0, 1] -              2 Subscript[z, 1, 1] Subscript[λ, 1, 0]) +           Subscript[z^2, 0,            1] (Subscript[λ, 0, 2] + Subscript[λ, 2,              0]) + Subscript[z, 1,            0] (-2 Subscript[z, 1, 1] Subscript[λ, 0,               1] + (Subscript[z, 0, 2] - Subscript[z, 2,                 0]) Subscript[λ, 1, 0] +              Subscript[z, 1,               0] (Subscript[λ, 0, 2] + Subscript[λ, 2,                 0]))) - (Subscript[z^2, 0, 1] + Subscript[z^2, 1,           0]) (Subscript[λ^2, 0, 1] + Subscript[λ^2, 1,           0]) + 2 λ^3 ((Subscript[z, 0, 2] + Subscript[z, 2,              0]) Derivative[1][f][            z] + (Subscript[z^2, 0, 1] + Subscript[z^2, 1, 0]) (            f^\[Prime]\[Prime])[z])) + 2 λ f[      z] ((Subscript[z^2, 0, 1] + Subscript[z^2, 1,           0]) (Subscript[z, 0, 1] Subscript[λ, 0, 1] +           Subscript[z, 1, 0] Subscript[λ, 1, 0]) Derivative[1][         f][z] - λ^2 (Subscript[z^2, 0, 1] + Subscript[z^2, 1,           0]) Derivative[1][f][         z]^2 + λ (2 (-2 Subscript[z, 0, 1] Subscript[z, 1, 0]               Subscript[z, 1, 1] +              Subscript[z, 2, 0] Subscript[z^2, 0, 1] +              Subscript[z, 0, 2] Subscript[z^2, 1, 0]) Derivative[1][f][            z] + (Subscript[z^2, 0, 1] + Subscript[z^2, 1, 0])^2 (            f^\[Prime]\[Prime])[z])))/(4 λ f[     z] (λ f[z] + Subscript[z^2, 0, 1] + Subscript[z^2, 1, 0]))      and I want to collect the terms of the type               Subscript[z, 0, 1]      and               Subscript[z^2, 0, 1]      here 0, and 1 can be change. I can do for the first one as               Collect[ expr// ExpandAll, Subscript[z, _, _], Simplify]      but while I try to use               Collect[ expr// ExpandAll, Subscript[z^2, _, _], Simplify]      to collect the second one, it doesn't work, Why? What's more, can I write a pattern that will collect both of them at the same time?


title: How to explain the results of the following integrals?

text: Why does the following program lead to different results of `a21` and `a211`?               moveconst[x_] := (x /. Integrate[factor_ expr_, {var_, min_, max_}] /;            FreeQ[factor, var] :> factor Integrate[expr, {var, min, max}]);          inta1 = 2 (2 Cos[q3[t]] fec1[x1] q5[t] - fe1[x1] Sin[q3[t]] );     a1 = Integrate[inta1, {x1, 0, L1}] q6[t];          inta2 = (4 Cos[q3[t]] fec1[x1] q5[t] q6[t] -2 fe1[x1] Sin[q3[t]] q6[t]);     a2 = Integrate[inta2, {x1, 0, L1}];          a21 = a1 - a2;     Simplify[a21, TransformationFunctions -> {Automatic, moveconst}]               inta11 = 4 Cos[q3[t]] fec1[x1] q5[t] - 2 fe1[x1] Sin[q3[t]] ;     a11 = Integrate[inta11, {x1, 0, L1}] q6[t];          inta21 = (4 Cos[q3[t]] fec1[x1] q5[t] q6[t] - 2 fe1[x1] Sin[q3[t]] q6[t]);     a21 = Integrate[inta21, {x1, 0, L1}];          a211 = a11 - a21;     Simplify[a211, TransformationFunctions -> {Automatic, moveconst}]


title: Arranging elements in a Grid by drag&drop

text: I have some elements in a `Grid`. I want to change their positions within that `Grid`. Can I swap their positions just by dragging cursor on to them? For example                      Grid[{{1, 2, 5, 7, 9}, {3, 4, 8, 4, 2}, {5, 12, 7, 3, 8}}]      I want to swap positions of 8 and 2 in drag&drop fahion. Is it possible?


title: Poor performance when evaluating double integral of hat functions

text: I am trying to evaluate a double integral but am having performance issues. **First a bit of math** I am using a Galerkin like scheme to discretize operators in an equation I am working with. The problem I am trying to solve is this: I start with hat functions in x and y, $ \Psi_j(z) \left\\{ \begin{array}{ll} \frac{1}{\Delta z}(z-z_{j-1}) & , z < z_j\\\ -\frac{1}{\Delta z}(z-z_{j-1}) & , z >z_j \\\ 0 & , \left\vert z - z_j \right\vert > \Delta z \\\ \end{array} \right. , $ $ \Psi_i(y) \left\\{ \begin{array}{ll} \frac{1}{\Delta y}(y-y_{i-1}) & , y < y_i\\\ -\frac{1}{\Delta y}(y-y_{i-1}) & , y >y_i \\\ 0 & , \left\vert y - y_i \right\vert > \Delta y \\\ \end{array} \right. . $ where $i$ and $j$ correspond to a node on our grid. I then define an arbitrary function and the variable of interest (pressure in my case) as, $ \Theta(y,z) \cong \sum\limits_i \sum\limits_j \Theta_{ij} \Psi_i(y)\Psi_j(z) , $ $ p(y,z) \cong \sum\limits_i \sum\limits_j p_{ij} \Psi_i(y)\Psi_j(z) . $ The arbitrary function corresponds to the coefficient of the operator we are approximating. The integral I am trying to solve is, $ \Theta p |_{z = z_i} \cong \frac{\int \int \Psi_i \Psi_j \Theta p dz dy}{\int \int \Psi_i \Psi_j dz dy} $ **Now the Code** I am building off of what I had done earlier. Here are the piecewise functions:               ψzt[z_, c_] := Piecewise[{{(z - c)/Δz + 1, z <= c},                                {-(z - c)/Δz + 1, z > c}}];     ψz[z_, c_] := Piecewise[{ {ψzt[z, c], ψzt[z, c] > 0},                                {0, ψzt[z, c] <= 0}}];     ψyt[y_, c_] := Piecewise[{{(y - c)/Δy + 1, y <= c},                                {-(y - c)/Δy + 1, y > c}}];     ψy[y_, c_] := Piecewise[{ {ψyt[y, c], ψyt[y, c] > 0},                                {0, ψyt[y, c] <= 0}}];      Here are the functions I have defined (I just expand the double sum):               θ [y_, z_] :=      Subscript[θ, i - 1, j - 1] ψy[y, Subscript[Y, i - 1]] ψz[z,Subscript[Z, i - 1]] +                    Subscript[θ, i - 1,j] ψy[y, Subscript[Y, i]] ψz[z, Subscript[Z, i - 1]] +       Subscript[θ, i - 1,j + 1] ψy[y, Subscript[Y, i + 1]] ψz[z, Subscript[Z, i - 1]] +       Subscript[θ, i,j - 1] ψy[y, Subscript[Y, i - 1]] ψz[z, Subscript[Z,i]] +     Subscript[θ, i,j] ψy[y, Subscript[Y, i]] ψz[z, Subscript[Z, i]] +      Subscript[θ, i, j + 1] ψy[y, Subscript[Y, i + 1]] ψz[z, Subscript[Z,i]] +       Subscript[θ, i + 1,j - 1] ψy[y, Subscript[Y, i + 1]] ψz[z, Subscript[Z, i - 1]] +       Subscript[θ, i + 1,j] ψy[y, Subscript[Y, i]] ψz[z, Subscript[Z, i + 1]] +      Subscript[θ, i + 1,j + 1] ψy[y, Subscript[Y, i + 1]] ψz[z,Subscript[Z,i + 1]];                μ[y_, z_] :=      Subscript[μ, i - 1, j - 1] ψy[y, Subscript[Y, i - 1]] ψz[z, Subscript[Z, i - 1]] +       Subscript[μ, i - 1, j] ψy[y, Subscript[Y, i]] ψz[z, Subscript[Z, i - 1]] +      Subscript[μ, i - 1,j + 1] ψy[y, Subscript[Y, i + 1]] ψz[z, Subscript[Z,i - 1]] +       Subscript[μ, i,j - 1] ψy[y, Subscript[Y, i - 1]] ψz[z, Subscript[Z, i]] +     Subscript[μ, i, j] ψy[y, Subscript[Y, i]] ψz[z, Subscript[Z, i]] +     Subscript[μ, i, j + 1] ψy[y, Subscript[Y, i + 1]] ψz[z, Subscript[Z, i]] +     Subscript[μ, i + 1, j - 1] ψy[y, Subscript[Y, i + 1]] ψz[z, Subscript[Z,i - 1]] +      Subscript[μ, i + 1,j] ψy[y, Subscript[Y, i]] ψz[z, Subscript[Z, i + 1]] +      Subscript[μ, i + 1,j + 1] ψy[y, Subscript[Y, i + 1]] ψz[z, Subscript[Z,i + 1]];        Note: We use $\mu$ to represent $p$. Here are the assumptions I make:               BasisAssumY = {Δy > 0, Subscript[Y, i] ∈ Reals,     y ∈ Reals, Δy ∈ Reals,      Subscript[Y, i - 1] ∈ Reals,      Subscript[Y, i + 1] ∈ Reals,      Subscript[Y, i - 1] < Subscript[Y, i] < Subscript[Y, i + 1],      Subscript[Y, i + 1] - Subscript[Y, i ] == Δy,      Subscript[Y, i] - Subscript[Y, i - 1 ] == Δy,      Subscript[Y, i ] - Subscript[Y, i + 1] == -ΔY};      The same assumptions are made in the z direction.               BasisRulesAll = {Subscript[Z, i + 1] - Subscript[Z,      i ] -> Δz,      Subscript[Z, i] - Subscript[Z, i - 1 ] -> Δz,      Subscript[Z, i ] - Subscript[Z, i + 1] -> -Δz,      Subscript[Y, i + 1] - Subscript[Y, i ] -> Δy,      Subscript[Y, i] - Subscript[Y, i - 1 ] -> Δy,      Subscript[Y, i ] - Subscript[Y, i + 1] -> -Δy};      Here is my integrating procedure:               Simplify[Integrate[     Integrate[ψz[z, Subscript[Z, i]]  θ [y, z] μ [y,          z], {z, Subscript[Z, i - 1], Subscript[Z, i + 1]},        Assumptions -> BasisAssumZ] ψy[y, Subscript[Y, i]], {y,       Subscript[Y, i - 1], Subscript[Y, i + 1]},      Assumptions ->       BasisAssumY]/(Δz Δy)] //. \BasisRulesAll      This will run for hours without returning a result. In contrast, I have done a similar calculation in 1D (get the notebook here) that takes about 10 seconds. I did manage to get the integral to evaluate but I had to remove all $y$ terms from the $x$ integral (I grouped together like terms and factored). After doing that, the integral took about 10 seconds to be evaluated, but it was very messy and I cannot be sure that human error was not introduced. It would be simpler if the method above worked in a reasonable amount of time. Does anyone have any suggestions on how I could improve the performance of the double integration?


title: Moving From Dynamic Module to Manipulate

text: In trying to implement Vitaly's suggestion about how to take control of `Locator` events, I have been able to make headway using `DynamicModule`. However, the ultimate destination is a demonstration, so I'd like to make the code work in `Manipulate`. **The Code** The following pared-down version works fine. It places 5 locators in a coordinate space with _x_ and _y_ axes displayed.               DynamicModule[{p1 = {0, 2}, p2 = {2, 0}, p3 = {4, -3}, p4 = {-3, 3}, p5 = {1, 1}},     EventHandler[     dQ[p_, q_] := EuclideanDistance[p, MousePosition["Graphics"]] <      EuclideanDistance[q, MousePosition["Graphics"]];     Dynamic[      Style[Graphics[{       {Red, Disk[{0, Round@p1[[2]]}, .2]},       {Blue, Disk[Round@p2, .2]},       {Green, Disk[p3, .2]},       {Brown, Disk[p4, .2]},       GraphicsGroup[{Black, Line[{.1 {0, 1.5} + p5, .1 {0, 3} + p5}],          Line[{.1 {0, -1.5} + p5, .1 {0, -3} + p5}],          Line[{.1 {-1.5, 0} + p5, .1 {-3, 0} + p5}],          Line[{.1 {1.5, 0} + p5, .1 {3, 0} + p5}],          Circle[{0, 0} + p5, .2], Gray, Disk[p5, .1]}]},      PlotRange -> 5, Axes -> True],Selectable -> False]],      {"MouseDragged" :>       (Which[       dQ[p1, p2] && dQ[p1, p3] && dQ[p1, p4] && dQ[p1, p5],        p1 = MousePosition["Graphics"],       dQ[p2, p1] && dQ[p2, p3] && dQ[p2, p4] && dQ[p2, p5],        p2 = MousePosition["Graphics"],       dQ[p3, p1] && dQ[p3, p2] && dQ[p3, p4] && dQ[p3, p5],        p3 = MousePosition["Graphics"],       dQ[p4, p1] && dQ[p4, p2] && dQ[p4, p3] && dQ[p4, p5],        p4 = MousePosition["Graphics"],       dQ[p5, p1] && dQ[p5, p2] && dQ[p5, p3] && dQ[p5, p4],        p5 = MousePosition["Graphics"]])}]]      **Moving to Manipulate** The issue is really quite simple. How can I successfully wrap this code in `Manipulate`? I've tried this:                Manipulate[         <above code>,        {x,1,12,Slider} ]      [The slider serves no purpose at the moment.] **What happens** The manipulate screen appears as expected. However, evaluation goes into a loop. The cell right bracket blinks endlessly. What causes this loop? Why doesn't it occur when I use `DynamicModule` without `Manipulate`?


title: How to find the maximum of this function on the positive real line?

text: I need to maximize this function on the positive real line: $$ \frac{1}{\Gamma(x)^{14}}\cdot\frac{1}{{\frac{323.6}{14x}}^{14x}}\cdot(1.22578*10^{19})^{x-1}e^{-14x} $$ the correct answer should be around $x=514$, but I could not use mathematica to show it. My plot has a peak at $x=680$ instead. I want to ask if anyone has any idea how to get the correct answer. The code I am using now is:               A = 1/Gamma[x]^{14}*(301.6/(14*x))^{-14 *x}*(1.22578*10^{19})^{x -1} E^{-14 x}      and I plot it by               Plot[A, {x, 513, 700}, PlotPoints -> 1000]      The result is something very strange: ![enter image description here](http://i.stack.imgur.com/KWqRb.png)


title: What is a type in Wolfram Mathematica programming language?

text: "Everything is an expression" is a popular citation from many _Mathematica_ guidebooks. So, what is type in _Mathematica_? How does it relate to common types from Haskell, for example? I did some _simulation_ of dependent types:               DependentType::illegal= "Value is illegal for dependent types with constraints";     FixedSizedVector[n_?(Positive[#]&)] :=     Module[{type = Symbol["Vector" <> ToString[n]]},         type[dat_] := Message[DependentType::illegal] /; VectorQ[dat] && Length[dat] != n;         type     ];     types =     Map[         FixedSizedVector[#]&,         Range[1, 25]     ];      I have received an array `types` of symbols that are constrained with pattern checking rules. Is it a family of types? Another point is `Head` replacing. For example, for list `Range[1, 5]` I can just type `Plus @@ Range[1, 5]` and get `Integer[15]`. From the point of view of type, what is `Apply`?


title: How to convert each pair of { and } into ( and )?

text: I am a learn-by-example person. I have no idea to change every `{` and `}` to `(` and `)` respectively. Could you let me know which concept in Mathematica is related to this problem so I can learn it much faster? The objective is to convert the output of               Tuples[{{a, b, c}, {1, 2}}]      which is > {{a, 1}, {a, 2}, {b, 1}, {b, 2}, {c, 1}, {c, 2}} to LaTeX-friendly output as follows. I have learnt `TeXForm` but it must be called at the last phase.               $\{(a, 1), (a, 2), (b, 1), (b, 2), (c, 1), (c, 2)\}$


title: Why does CUDAQ (from CUDALink) download data from Wolfram servers?

text: I understand why functions like `ElementData` or `CountryData` need to download up-to-date data when first launched. However, when trying to use CUDA for the first time in Mathematica, I ran:               Needs["CUDALink`"]; CUDAQ[]      which downloaded data for several minutes. Given that I have a quite fast net connection, that must amount to a really large amount of data. What does Mathematica download in that case? I guess drivers, but how can I _check_ what it downloads?


title: How to make GraphicsGrid with content tight inside it?

text: I am trying to use GraphicsGrid to typeset some labels for my plots. I found the labels look little better when I use GrapicsGrid vs Grid. The labels have equations in them and not just plain labels. I just do not know how to make a GraphicsGrid which has no wasted space in it. Here is an example using Grid, which does not have the problem of wasted space, and same example, using GraphicsGrid. Ps. in this example, I am using a nice little makeBoxes function I found on the net by P.J. Hinton to make Derivatives in Traditionalform come out like they are in our textbook. Here is a link to the original post if needed               Remove["Global`*"];     MakeBoxes[Derivative[indices__][f_][vars__], TraditionalForm] :=        SubscriptBox[MakeBoxes[f, TraditionalForm],         RowBox[Map[ToString,           Flatten[Thread[dummyhead[{vars}, Partition[{indices}, 1]]] /.             dummyhead -> Table]]]];          title = 2 Derivative[2, 0][u][x, t] ==         1.1 Derivative[0, 1][u][x, t] + 80 Derivative[1, 0][u][x, t];          title = Style[title, 16];          GraphicsGrid[{{Item[title, Alignment -> Top], SpanFromLeft}},       ImageSize -> {150, 80}, Frame -> All, ImageMargins -> 0,       ImagePadding -> 0, BaselinePosition -> Center]      This gives ![enter image description here](http://i.stack.imgur.com/xeQw7.png) and using normal Grid, gives (noticed I had to call TraditionalForm once more here, but not with the above to get it to work)               Remove["Global`*"];     MakeBoxes[Derivative[indices__][f_][vars__], TraditionalForm] :=        SubscriptBox[MakeBoxes[f, TraditionalForm],         RowBox[Map[ToString,           Flatten[Thread[dummyhead[{vars}, Partition[{indices}, 1]]] /.             dummyhead -> Table]]]];          tr = TraditionalForm;     title = 2 tr@Derivative[2, 0][u][x, t] ==         1.1 tr@Derivative[0, 1][u][x, t] + 80 tr@Derivative[1, 0][u][x, t];          title = Style[title, 16];     Grid[{{Item[title, Alignment -> Top], SpanFromLeft}}, Frame -> All]      ![enter image description here](http://i.stack.imgur.com/jrQi7.png) Played around with GraphicsGrid, but can't figure how to automatically tell it to put the object inside it as tight as possible. It will be best if I do not not specify `ImageSize`. But using `ImageSize-> Automatic` does not work:               GraphicsGrid[{{Item[title, Alignment -> Top], SpanFromLeft}},       ImageSize -> Automatic, Frame -> All, ImageMargins -> 0,       ImagePadding -> 0, BaselinePosition -> Center]      ![enter image description here](http://i.stack.imgur.com/L89EL.png) Is there an option or a trick to do this? thanks


title: Dijkstra without Combinatorica

text: There is some overlap between Combinatorica and the Graph related framework but there are also various elements missing. As far as I can see there is no 'Dijkstra' method or algorithm in Mathematica or is there a way (combination of other Graph methods) to do it? That is, without accessing Combinatorica by converting Graph to an EdgeList and so on.


title: How can I draw the Olympic rings with Mathematica?

text: How can I draw the 5 interlocking Olympic rings with Mathematica? ![Olympic rings](http://i.stack.imgur.com/fJthQ.png) (SVG version) * * * **Edit** Hard choice, but some pretty cool answers here. I didn't have 3D answers in mind when I posted the question but without a doubt they look much better than the 2D. Very subjective choice for the selected answer but I do like @cormullion's answer.


title: Functional style using lazy lists?

text: Let's say I want to answer the question "what are the first 400 palindromic prime numbers?" The first approach that comes to my mind from the set of languages that I know is to use some sort of lazy list materialization, a la `IEnumerable` (and `yield`) in C#, generators in Python, or `sequence` blocks in F#. For example, in C#:               PrimesEnumerator().Where(n => n.ToString() == n.ToString().Reverse()).Take(400);      This would cause the PrimesGenerator to be pumped for primes long enough for the `Where()` clause to find enough numbers that meet the requirement for `Take()` to meet its quota. The best I've come up with in Mathematica is something like:               i = 1; results = List[];     While[Length[results] != 400,       If[IntegerDigits[Prime[i]] == Reverse[IntegerDigits[Prime[i]]],         results = Append[results,Prime[i]]];       i = i + 1]      It surprises me that I end up writing in such an imperative style in Mathematica. Am I missing something that would let me write this entirely functionally? Maybe even with lazy lists? > **Update:** I took inspiration from WReach's work of art answer, and made a > package that took his ideas and expanded them into a broad, general solution > for lazy data in Mathematica. I describe its usage in an answer below.


title: Graph and manipulate DSolve result

text: Given a `DSolve` example:               sol = Flatten[     DSolve[{D[x[t, th], {t, 2}] == -0.2*D[x[t, th], t]/2.30,       Derivative[1, 0][x][0, th] == 10.8*Cos[th], x[0, th] == 0},      x[t, th], t]]      Then assigning `sol` to a function:                x[t,th]/.sol[[1]]      I'm having trouble plotting a 2D portion of it:               Plot[x[t,1],{t,0,20}]      And also trouble Manipulating it:               Manipulate[x[t,th], {th, 0, Pi/2}]      What mistakes am I making?


title: PrependTo fails on a Table of Evaluated funtions

text: My task is something like this:               PrependTo[Evaluate[Table[{x, Sin[x]}, {x, 0.1, 2 \[Pi], 0.1}], {0., 1.}]]      where I tried also skipping the               Evaluate       and I get a               PrependTo::rvalue:      error. If I do:               a = Table[{x, Sin[x]}, {x, 0.1, 2 \[Pi], 0.1}];     b = PrependTo[b, {0., 0.}];      everything works fine. I want it to be a part of a big code, so doing it in one line without defining the first list separately would speed up the program. And I don't need the first list, only the second one, so why should I store both? How can I deal with this problem? Edit: The case is to make               Join[{{0., 0.}}, Table[{x, Sin[x]}, {x, 0.1, 2 \[Pi], 0.1}], 1]      but are there other, maybe better, solutions?


title: Does every Symbol in Mathematica induce a monad?

text: From my question about types in Mathematica, I assume that every `Symbol` in Mathematica is a type if it appears as a `Head` of some expression. So I can implement operators for monad associated with that `Symbol` (let it be `F` for instance):   1. monad _lift_ function ( _return_ in Haskell notation) is just `return[p_] = F[p]`;   2. monad _bind_ function ( _>>=_ in Haskell notation) is just a rule `bind[F[p_], f_] := F[f[p]]` (as monad Maybe is for example). From point of view of category theory, in Mathematica one can define some common rules for symbols to model monad multiplication (just flatten of repeating `Head`): `monadMultiplyRule = {p_[p_[params___]] -> p[params]}`. So expression `F[F[F[p_]]] //. monadMultiplyRule` will be just `F[p]`. Also all monad axioms are satisfied:   1. `return` acts as a neutral element of `bind`: `bind[return[p], f]` is `F[f[p]]` and `bind[F[p], Identity]` is `F[p]`;   2. sequential `bind` of two functions `f` and `q` is the same as a single `bind` with their "composition" `Bind[F[f[p]], q]`: `Bind[Bind[F[p], f], q]` and `Bind[F[f[p]], q]` produce both the same result `F[q[f[p]]]`. So, does Mathematica provide a natural maybe-like monad for every symbol and does it provide a natural framework for any explicit monadic computations?


title: Solving an integral equation numerically for an unknown within the integral

text: I'm trying to solve an integral equation of the form `Constant == Integrate [g(x)f(x,Efermi), {x,-200,200}]`, for the parameter `Efermi`. The function `g(x)` is `Exp[-(x^2)/5000]` and `f(x)` is `1/(1+Exp[(x-Efermi)/25]`. In addition to this, if the `Constant` is an array, I'd like to extract `Efermi` as an array. Any inputs on how to go about solving this would be appreciated.


title: How to avoid font substitution with Mathematica fonts?

text: When I export a `Plot` to `PDF`, a journal publisher complains that they do not have the Mathematica fonts. I believe there is a way to inhibit Mathematica from substituting its fonts (e.g., for `"("`) but I cannot figure it out. I tried this but it did not work.                Plot[<deleted> , BaseStyle -> {PrivateFontOptions -> {"OperatorSubstitution" ->False}}]


title: Solving systems of equations and derivatives

text: I am new to Mathematica, and I'm not sure how to solve a system of equations that include differentiation. Given that f and g are differentiable functions:               f(x) < 0 for all x       g(5) = 2       h(x) = f(x) / g(x)       h'(x) = f'(x) / g(x)       Then g(x) = ?      (The answer is 2) I didn't expect it to work, but I tried this:               DSolve[{f[x] < 0, g[5] = 2, h[x] == f[x]/g[x], h'[x] = f'[x]/g[x]}, g[x], x]      And of course it didn't work. How would I do this?


title: Is it possible to embed fonts in a .cdf?

text: I am trying to use a special font with musical symbols in a .cdf that I send to some friends. The font is called "Tempera" and is freely distributed here: http://christian.texier.pagespro-orange.fr/mididesi/free/index.htm#tempera In the .cdf I use substitutions like this:               sub = "A" -> "\*StyleBox[\(\!\(\*StyleBox[\"A\",\n\        FontFamily->\"Mathematica6\"]\)\!\(\*StyleBox[\"U\",\n\        FontFamily->\"Tempera\",\nFontSize->18,\nFontWeight->\"Plain\"]\)\)]";      which are used in this manner:                "A" //. sub      What this does is to change the regular "A" character into a curly A (from the Mathematica6 font) and a symbol that is a half-sharp (the "U" from the Tempera font). This works fine in Mathematica, and also in the .cdf on my computer. However, when I send it to my friend, he sees the "U" and not the half-flat. This is probably what you will see too, unless you download the Tempera font. I believe this means that Mathematica does not embed the font in the .cdf, and I'm wondering if there is any way to force the embedding to occur. While I could have my friend download the font, if I ever want to place the .cdf on the web, this would not be practical.


title: Finding exact local extrema of simple functions

text: I want to _exactly_ find all the local maxima of               f[x_] := x^4/4 - x^2/2      over the interval `[-Sqrt[2], 1 + Pi/10]`. The correct answer is that we have global maxima at `x = -Sqrt[2]` and `x=0`, and a local maximum at `x= 1 + Pi/10`. Right now my approach is to iterate the `Maximize` command, which finds global maximums symbolically, and each time it finds a maximum I tell it to not find the same one again. Of course after it finds the two global maxima, it doesn't give me anything useful on the third application, as the one I am trying to find is merely local. Now I could use `FindMaximum`, but that only yields a numerical approximation, and I want the exact value. Also note that in this case my algorithm fails to find the local maximum at an endpoint, but it would be easy to use a different function where the method would fail to find a local maximum properly inside the interval. **Iteration 1:**               Maximize[{x^4/4 - x^2/2, (x >= -Sqrt[2]) && (x <= 1 + Pi/10)}, x]      This finds the point `x=0`. **Iteration 2:**               Maximize[{x^4/4 - x^2/2, (x >= -Sqrt[2]) && (x <= 1 + Pi/10) && (x != 0)}, x]      This finds the point `x = -Sqrt[2]`. **Iteration 3:**               Maximize[{x^4/4 - x^2/2, (x >= -Sqrt[2]) && (x <= 1 + Pi/10) && (x != 0) && (x != -Sqrt[2])}, x]      Of course this throws a "no maximum in the region" error, when I would like it to find `x = 1 + Pi/10`. I am open to patches for this approach or completely different algorithms as well.


title: Is it possible restore initial values after modify a control in manipulate?

text: I used to program in Visual Basic, but in _Mathematica_ I have not seen some kind of restore default values after any user modification command in the `Manipulate` environment. For instance, in               Manipulate[x + y, {{x, 1, "First"}, 1, 6}, {{y, 40, "Second"}, {40, 50, 60}}]      ![enter image description here](http://i.stack.imgur.com/dscU5.png) The user modify the slider for `x` to `5`. ![enter image description here](http://i.stack.imgur.com/D0rat.png) After that, when the user pick other value for `y`, there is a way to restore `x` to the initial value? such that: ![enter image description here](http://i.stack.imgur.com/aRi3y.png) And also by modifying the slider `x` again restore the value `y` to `40`. In other words, by detect a modification in the controllers, could `Manipulate` restore the default values?


title: Cancelling units in two-argument ArcTan

text: Consider               ArcTan[3, -3]       (* out: *) -Pi/4            ArcTan[3 a Sin[t/2], -3 a Sin[t/2]]     (* out: *) ArcTan[3 a Sin[t/2], -3 a Sin[t/2]]        However, we can fix the second one with some assumptions (where applicable)               $Assumptions = a > 0 && Pi > t > 0       Refine@ArcTan[3 a Sin[t/2], -3 a Sin[t/2]]     (* out: *) -Pi/4        I need a way to force mathematica to similarly realize it can cancel units in the ArcTan (which is basically a ratio, except for the sign consideration for the quadrant). For example, say I now have               $Assumptions = a > 0 && Pi > t > 0        aa=(4 Pi/(3 Sqrt[3]))(Quantity[1.42, "Angstroms"])^(-1)       b=(Quantity[5, "Angstroms"])^(-1)     ArcTan[b+3 aa Sin[t/2],-b-3 aa Sin[t/2]]      How can I force Mathematica to recognize that these arguments are just +c and -c and thus the ArcTan significantly reduces? I wish to avoid removing the units here artificially with QuantityMagnitude[] because elswhere in these expressions the units appear outside of these ArcTan[]s. However, a last ditch solution would be one that simply searched for these ArcTan[] and applied QuantityMagnitude[] to their arguments, I suppose.


title: Replacing functions

text: Given an expresion 'e' in terms of a function 'f' and given another function 'g', how could I write a Module that replaces the function f to g in the expresion e and returns it? An example:               MyFunction[expresion_, f_, g_] := (...)      `MyFunction[f[x]-3, f, Sin[x]]` should evaluate to `Sin[x]-3` `MyFunction[D[f[x],x], f, x]` should evaluate to `1` `MyFunction[f[x], f, 19]` should evaluate to `19` I hope it's clear. Sorry about my bad english.


title: Why mathematica have difficulty solving nonlinear equations?

text: I tried to solve this equation via Mathematica:               Solve[-(0.35 - b)/sigma == 9.8602 &&A*Exp[-(0.35 - b)^2/(2*sigma)] == 0.150099           &&A*Exp[-(0.55 - b)^2/(2*sigma)] == 0.895049, {A, b, sigma}]      However, mathematica shows that: Solve::inex: Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help. What should I do?


title: Determinant of a square matrix with univariate polynomial entries is not a polynom?

text: I have a 15x15 Matrix with all polynomial entries. I want to calculate the determinant of the matrix. To my understanding the determinant should be a (albeit high order) polynom, too. And the paper, I am following, expects this, too. But Mathematica does not seem to agree with me here. Anyone had this? If I take only the upper left submatrix with rows/columns 1 to 11, the determinant is a polynom. But after that using upper left submatrix with rows/columns 1 to 12 and higher results in non-polynomial determinants. **Code Explanation:** Until the line where the array T appears first, the code is just constructing polynomials of three variables (x,y,w) according to a paper ("Closed-Form Dynamic Equations of the General Stewart Platform through the Newton–Euler Approach"). The two For-loops afterwards extract the x polynomials such that the inner product of the i'th row of M15x15 with T corresponds to the i'th polynomial (pi). The Matrix M15x15 then only consists of univariate polynomials.               alpha = N[8/180*Pi];     beta = N[12.8/180*Pi];     ra = N[15.0];     rb = N[9.45];     xi  = ra*Cos[{0, 2*alpha, 2/3*Pi, 2/3*Pi + 2*alpha, 4/3*Pi, 4/3*Pi + 2*alpha}]     yi = ra*Sin[{0, 2*alpha, 2/3*Pi, 2/3*Pi + 2*alpha, 4/3*Pi, 4/3*Pi + 2*alpha}]     zi = {0, 0, 0, 0, 0, 0}     pi = rb*Cos[1/3*Pi + {0, 2*beta, 2/3*Pi, 2/3*Pi + 2*beta, 4/3*Pi, 4/3*Pi + 2*beta}]     qi = rb*Sin[1/3*Pi + {0, 2*beta, 2/3*Pi, 2/3*Pi + 2*beta, 4/3*Pi, 4/3*Pi + 2*beta}]     ri = {0, 0, 0, 0, 0, 0};     Li = {20.0, 20.0, 20.0, 20.0, 20.0, 20.0};     mi = 1/2*(Li^2 - xi^2 - yi^2 - pi^2 - qi^2);     M6x10 = Array[0, {6, 10}];     For[i = 1, i <= 6, i++,      M6x10[[i, ;;]] = {pi[[i]]*xi[[i]], pi[[i]]*yi[[i]], -pi[[i]],         qi[[i]]*xi[[i]], qi[[i]]*yi[[i]], -qi[[i]], xi[[i]], yi[[i]], -0.5,         mi[[i]]}     ]     a0 = Det[ M6x10[[;; , 1 ;; 6]] ];     a6x4 = Array[0, {6, 4}];     M6x6 =  M6x10[[;; , 1 ;; 6]];     For[i = 1, i <= 6, i++,      For[j = 1, j <= 4, j++,       tmp = M6x6;       tmp[[;; , i]] = M6x10[[;; , j + 6]];       a6x4[[i, j]] = Det[tmp];      ]     ]     AA = a6x4[[1, 1]]*x + a6x4[[1, 2]]*y + a6x4[[1, 3]]*w + a6x4[[1, 4]];     BB = a6x4[[2, 1]]*x + a6x4[[2, 2]]*y + a6x4[[2, 3]]*w + a6x4[[2, 4]];     CC = a6x4[[3, 1]]*x + a6x4[[3, 2]]*y +                  a6x4[[3, 4]];     DD = a6x4[[4, 1]]*x + a6x4[[4, 2]]*y + a6x4[[4, 3]]*w + a6x4[[4, 4]];     FF = a6x4[[5, 1]]*x + a6x4[[5, 2]]*y + a6x4[[5, 3]]*w + a6x4[[5, 4]];     GG = a6x4[[6, 1]]*x + a6x4[[6, 2]]*y +                  a6x4[[6, 4]];     f1 = 1 - a0^(-2)*(AA^2 + BB^2);     f2 = 1 - a0^(-2)*(DD^2 + FF^2);     f3 = 1 - a0^(-2)*(AA*DD + BB*FF);     f4 = a0^(-1)*(-CC*AA*x + BB*y);     f5 = a0^(-1)*(-GG*DD*x + FF*y);     f6 = w - x^2 - y^2;     p1 = f1*f6 - f4^2;     p2 = f2*f6 - f5^2;     p3 = f3*f6 - f4*f5;     p4 = f1*f5 - f3*f4;     p5 = f2*f4 - f3*f5;     p6 = f1*f2 - f3^2;      p7 = -DD*p1 + AA*p3 - x*p4;     p8 = FF*p1 - BB*p3 + y*p4;     p9 = DD*p3 - AA*p2 - x*p5;     p10 = -FF*p1 + BB*p3 + y*p5;     p11 = AA*p5 + DD*p4 + x*p6;     p12 = BB*p5 + FF*p4 + y*p6;     p13 = -FF*p7 - BB*p9 + y*p11;     p14 = -CC*p5 + DD*p7 + BB*p10 - a0^2*p2 - x*p11;     p15 = p14 - DD*p7 - FF*p8 - AA*p9 - BB*p10 + x*p11 + y*p12;     T = {w^4, w^3 y, w^2 y^2, w y^3, y^4, w^3, w^2 y, w y^2, y^3, w^2, w y, y^2, w, y, 1};     pAll = {p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14,         p15};     M15x15 = Array[0, {15, 15}];     For[i = 1, i <= 15, i++,      For[j = 1, j <= 14, j++,       M15x15[[i, j]] = Coefficient[ pAll[[i]], T[[j]] ] /. {y -> 0, w -> 0};       ]     ]     For[i = 1, i <= 15, i++,      M15x15[[i, 15]] = ( pAll[[i]] /. {y -> 0, w -> 0});     ]     determinante = Det[M15x15];


title: How to replace a list with the result list after each iteration

text: I have some initial values such as `L1` list:               L1={10,20,30,40,50};      I want to use the `L1` list and do some calculation that the result will be like :               L2={110,120,130,140,150};      Now I want to use this `L2` list instead of `L1` list and execute my `Do` loop again with this new initial Values. And this iteration will be performed 5 times and in each iteration, I want to replace my previous list with the new calculated list. A `Do` loop like below: 1st. Iteration : use `L1` list and result will be `L2` list 2nd. Iteration : use `L2` list and result will be `L3` list 3rd. Iteration : use `L3` list and result will be `L4` list 4th. Iteration : use `L4` list and result will be `L5` list 5.th Iteration : use `L5` list and result will be `L6` list End After 5 iterations, the final result will be `L6` list values. I have no idea to do this kind of iteration! Could anyone help me, please ?!


title: Font size in PDF export with legended plots not working

text: I need to export plots as PDF with a given image and font size. Everything is working fine if there is no legend for that plot. However, if I want to export legended plots, the font size is decreased in the exported PDF. Here is a small working example:               plotWithoutLegend =       ListPlot[Table[f, {f, {Sin[x], Cos[x]}}, {x, 0, 2 \[Pi], 0.1}],        Frame -> True, FrameLabel -> "Frame label font size is 12",        ImageSize -> 200, BaseStyle -> {FontSize -> 12}];     Export["plotWithoutLegend.pdf", plotWithoutLegend]      This yields the expected font size. However, when trying to export:               plotWithLegend =       ListPlot[Table[f, {f, {Sin[x], Cos[x]}}, {x, 0, 2 \[Pi], 0.1}],        Frame -> True, PlotLegends -> {"sin(x)", "cos(x)"},        FrameLabel -> "Frame label font size is about 8 pt",        ImageSize -> 200, BaseStyle -> {FontSize -> 12}];     Export["plotWithLegend.pdf", plotWithLegend]      the font size of the frame label is about 8 pt. This can be seen by importing the PDFs in a LaTeX document or by verifying the font size with Acrobat Pro. Is this a bug? Is there a workaround for this behavior?


title: Unit of the frequency axis in BodePlot

text: I have a simple question: What is the unit of the frequency axis in the BodePlot? I searched the documentation, but only found this: > The scaling functions can be specified as > ScalingFunctions->{{magfreqscale,magscale}, {phasefreqscale,phasescale}}. > > The frequency scales magfreqscale and phasefreqscale can be "Log10" or > "Linear", which correspond to the base-10 logarithmic scale and linear > scale, respectively. > > The magnitude scale magscale can be "dB" or "Absolute", which correspond to > the decibel >and absolute values of the magnitude, respectively. > > The phase scale phasescale can be "Degree" or "Radian". But it doesn't say me if the frequency axis is in Hz or rad/s or rad/min or what ever ... I'm asking because I have two BodePlots which, I'm rather shure one is in Hz and the other in rad/s.


title: C Code generated from Mathematica not working?

text: I am a .Net developer. I'm trying to build a Visual C++ application using C code generated from Mathematica (by another person). I don't have Mathematica installed on my machine. When I try to compile my code, I get this error: "error LNK2019: unresolved external symbol _WolframLibraryData_new referenced in function _wmain" Can anyone help me with this? Do I need to have Mathematica installed on my machine in order to use C code compiled from Mathematica? Or are there some .h/.dll/.lib files that I should be including in my project? Any help would be appreciated. This is a link to the Mathematica documentation which says this can be done: Here is my code:               #include "stdafx.h"     #include "stdio.h"     #include "stdlib.h"     #include "WolframRTL.h"     #include "funct.h"          static WolframLibraryData libData=0;     int _tmain(int argc, _TCHAR* argv[])     {         mint version=2;         libData = WolframLibraryData_new(version); //error is at this line         Initialize_funct(libData);              double A1[10][10]={{258.3379872132036,178.815628898537,274.5474024360497,674.9391898068819,223.178274172278,880.9581284722401,132.54033649875424,791.5414955768498,928.458244854092,853.042661440361},         {326.39463864136036,65.54849946988038,7.013535695540694,760.8886179075255,892.4870852590801,154.85960584875158,993.9999549781506,376.1879698639858,852.6107989941474,643.4517088040595},         {182.6857552274334,183.10740080449298,115.54339508284843,739.9140368208969,924.3477680142298,4.291771905955958,840.9959926467988,64.97484701401486,701.1694938419519,123.33364343371585},         {708.4556561480445,273.433351437165,772.7112489878598,270.29098199335476,382.06101750668415,207.88485196728465,765.6977132923191,509.4023640858293,489.57393224760403,53.02524611853305},         {771.6977583141684,133.21439422184343,636.9631332534566,409.5735373144735,589.012003086735,950.1069934173505,521.4197381706082,669.6595004935767,664.6642350725052,945.8152215113945},         {680.4237455238093,604.6846534795618,963.4947412305534,822.4815780776786,971.9680893757649,331.25130204239684,190.78349224269357,552.1905960843238,589.9070718690806,123.36645007511217},         {425.08577895037445,42.78823199849459,100.33313962147668,70.34120395657912,653.3880206362061,909.5738377766511,463.37000636802014,660.7676666421056,64.37601754947093,959.4668443593006},         {941.9502681974119,991.1081661485289,399.7117824769657,13.651622847906154,261.5265226736025,386.4235126689671,436.2170412464123,191.17004477022746,289.5584332978377,55.17221062657027},         {245.43354900371878,638.9794486859037,699.651361428757,931.8057605514581,820.3477700533443,596.191216687409,599.3182218072803,861.464556594879,166.9597494171383,686.6173789107579},         {135.94821543926025,200.69688995277338,102.58373186766738,727.1505345514572,193.9979472418483,209.58872380424447,702.8719493907016,713.498911703551,932.4714245682458,823.1652111352774}};              MTensor B1;         mint type = MType_Real;         mint dims[2];         mint rank = 2;         int err;         dims[0] = 10;         dims[1] = 10;         err = libData->MTensor_new( type, rank, dims, &B1);               for(int i=0;i<10;i++)         {             for(int j=0;j<10;j++)             {                 err = libData->MTensor_setReal(B1, dims, A1[i][j]);             }         }              MTensor result;         err = libData->MTensor_new(type, rank, dims, &result);                int A2=2;              funct(libData, B1, A2, &result); //this is the function compiled from Mathematica              double *res[10] ;              for(int i=0;i<10;i++)         {             res[i]= (*(libData->MTensor_getRealData))(&result[i]);         }         return 0;     }


title: Problem with Sinc[x] function and rounding

text: I seem to be having some trouble with the `Sinc[x]` function, and I think it's due to rounding, but I'm not sure. The code is below, with relevant constants:               b = 0.1;     a = 8.7106181548*^-18;     alpha$of$r[r_] := alpha /. FindRoot[alpha - b * alpha + (b/a) * Sin[a * alpha] ==                                         r (1 - 2 * b),  {alpha, r (1 - 2 *b)}];          u[r_] := b * Sinc[a * alpha$of$r[r]];     Plot[b - u[r], {r, 10^9, 10^10}]      When we plot the function `u[r]` in the range specified, it does not seem to return a continuous curve as expected. Here's a picture of the plot: ![wacky-looking plot](http://i.stack.imgur.com/8ffaT.png) Could anyone offer insight as to why this happens and how I could fix it? I apologize in advance if I'm missing any information, as I'm new here. Thanks!


title: Alternating sum

text: A frog is at the bottom of a 30 metre well. Each day it climbs 5 metres up the side, but it then slips back 3 metres each night. How long does it take to reach the top of the well? Is there an easier /more direct way to make an alternating sum than this?               y = 14; Flatten[Transpose[{Table[2 x + 5, {x, 0, y - 1}],      Table[2 x, {x, 1, y}]}]]      # Update Not automated, but simple and more direct than first attempt:               Accumulate[Table[If[OddQ[n], 5, -3], {n, 1, 27}]]


Adding a textfield to the function that I implemented to represent the tangent or derivative of a function, but I've added so mark errors.               f[x_] = -x^3 + 12 x - 3;   (*Se define la función*)     xmin = -6;     xmax = 6 ;     (* se define el mínimo y el máximo de la función*)      ainicia = -3 ;(* inicio del punto de tangencia*)     amin = -4.3;     amax = 5; (* se define el punto de tangencia mínimo y máximo*)     hinicia = -1;(*inicio del punto de intersección de la línea secante*)     hmin = -1.3;     hmax = 8.5;          Manipulate[       DynamicModule[{f = Sin[x^2]},        Column[{InputField[Dynamic[f]], Dynamic[Plot[f, {x, -5, 5}]]}]]       If[h == 0, h = .001];        Grid[          {{Plot[{f[x], If[t1, f[a] + (D[f[t], t] /. t -> a)*(x - a)],           f[a] + ((f[a + h] - f[a])/h)*(x - a)}, {x, xmin, xmax},           PlotStyle -> {{Thickness[0.005], Black}, {Thickness[0.004],           Blue}, {Thickness[0.004], Red}},           PlotRange -> {15*xmin, (8*xmax) + 2}, ImageSize -> {475, 325},           PlotLabel -> Style[Row[{Style["f(x)", Italic], "=",          ToString[-x^3 + x^2 + 12 x - 3, TraditionalForm]}], 20],          AxesLabel -> {Style["x", 16, Italic], Style["y", 16, Italic]},          Prolog -> {{PointSize[0.02], If[t1, Blue, Red], Point[{a, f[a]}]},           {PointSize[0.02], Red, Point[{a + h, f[a + h]}]}}]},           {Row[             {If[t1,             Style[Text[           "Pendiente-tangente =" <> ToString[D[f[t], t] /. t -> a]],            Blue, 20]],          Style[          Text["Pendiente-secante =" <> ToString[(f[a + h] - f[a])/h]],           Red, 20]}, "   "]}}],          {{a, ainicia, "x0"}, amin, amax},           {{h, hinicia, "h"}, hmin, hmax},           {{t1, False, "Linea Tangente"}, {True, False}},           TrackedSymbols -> {a, h, t1}, SaveDefinitions -> True]      I do not like putting the textfield to enter the function, which is shown in the graph and is the same for the tangent.


title: Plotting a set of trajectories (not a vector field) in 3D

text: Consider a set of trajectories in 3D space, that possibly converge. By visualizing trajectories as arrows the result will look crowded as each arrowhead will be placed where the attractor is. In 2D, the issue can be resolved by using `StreamPlot`, which places arrows neatly so that no arrows cross and no arrowheads/tails are placed at the same position. A `Stream[...]` object implementing these restrictions seems to be a natural extension to `Point`, `Line` and `Arrow` primitives. Unfortunately, nothing like this exists out of the black box of `StreamPlot`. Example image with 3D `Arrow`s: ![3D_trajectories](http://i.stack.imgur.com/6fESJ.png) Note, that the result is **not** a vectorfield in 3D but a set of trajectories (of a 4D ODE on a 3D simplex). Accordingly, I look for solutions which comply to/deal with the following issues:   1. Trajectories are specified as lists of points rather than individual vectors of a given position in space.   2. A trajectory should be divisible to multiple arrows (streamlines), arranged neatly without any overlap.   3. No streamlines should cross.   4. A set of streamlines forming a trajectory should have its individual color.   5. Arrows shouldn't start or end at the very same position.   6. Interpolation of trajectories would be nice. I have asked this question on Mathgroup (here and answers here), but as I haven't really dealt with the problem since (and did not develop it myself), it is still open. Heike already provided some useful stuff, but I think there is a lot of opportunity for improvement. (Heike, would you care to post your answers here as a solution please?) Here is an **updated** toy example (posted without linebreaks not to flood page):               data = {{{0., 0., 1.}, {0.01, 0.01, 0.97}, {0.02, 0.02, 0.95}, {0.03, 0.02, 0.94}, {0.03, 0.02, 0.94}}, {{0., 0.17, 0.83}, {0.01, 0.08, 0.9}, {0.02, 0.04, 0.92}, {0.03, 0.03, 0.93}, {0.03, 0.02, 0.93}}, {{0., 0.33, 0.67}, {0.02, 0.17, 0.81}, {0.03, 0.09, 0.87}, {0.04, 0.05, 0.9}, {0.04, 0.03, 0.91}}, {{0., 0.5, 0.5}, {0.02, 0.28, 0.69}, {0.04, 0.15, 0.8}, {0.05, 0.08, 0.86}, {0.05, 0.05, 0.88}}, {{0., 0.67, 0.33}, {0.02, 0.43, 0.53}, {0.05, 0.26, 0.67}, {0.07, 0.16, 0.75}, {0.08, 0.11, 0.8}}, {{0., 0.83, 0.17}, {0.03, 0.64, 0.31}, {0.09, 0.48, 0.41}, {0.15, 0.4, 0.42}, {0.22, 0.39, 0.36}}, {{0.17, 0., 0.83}, {0.15, 0.01, 0.82}, {0.14, 0.02, 0.82}, {0.13, 0.03, 0.82}, {0.13, 0.04, 0.83}}, {{0.17, 0.17, 0.67}, {0.19, 0.16, 0.64}, {0.22, 0.16, 0.6}, {0.26, 0.19, 0.53}, {0.32, 0.25, 0.41}}, {{0.17, 0.33, 0.5}, {0.22, 0.33, 0.44}, {0.29, 0.38, 0.32}, {0.33, 0.48, 0.17}, {0.3, 0.63, 0.06}}, {{0.17, 0.5, 0.33}, {0.23, 0.52, 0.24}, {0.27, 0.6, 0.12}, {0.23, 0.71, 0.04}, {0.16, 0.81, 0.02}}, {{0.17, 0.67, 0.17}, {0.19, 0.71, 0.08}, {0.17, 0.79, 0.03}, {0.13, 0.85, 0.02}, {0.1, 0.88, 0.01}}, {{0.17, 0.83, 0.}, {0.09, 0.89, 0.01}, {0.07, 0.9, 0.01}, {0.07, 0.91, 0.01}, {0.07, 0.9, 0.01}}, {{0.33, 0., 0.67}, {0.37, 0.02, 0.59}, {0.45, 0.06, 0.48}, {0.53, 0.14, 0.31}, {0.56, 0.29, 0.13}}, {{0.33, 0.17, 0.5}, {0.39, 0.26, 0.34}, {0.42, 0.4, 0.17}, {0.35, 0.57, 0.06}, {0.24, 0.73, 0.02}}, {{0.33, 0.33, 0.33}, {0.36, 0.46, 0.17}, {0.31, 0.62, 0.06}, {0.21, 0.75, 0.02}, {0.14, 0.84, 0.01}}, {{0.33, 0.5, 0.17}, {0.29, 0.65, 0.06}, {0.2, 0.77, 0.02}, {0.13, 0.85, 0.01}, {0.09, 0.88, 0.01}}, {{0.33, 0.67, 0.}, {0.18, 0.81, 0.01}, {0.11, 0.87, 0.01}, {0.08, 0.9, 0.01}, {0.07, 0.9, 0.01}}, {{0.5, 0., 0.5}, {0.62, 0.03, 0.34}, {0.73, 0.1, 0.16}, {0.69, 0.23, 0.06}, {0.53, 0.44, 0.02}}, {{0.5, 0.17, 0.33}, {0.52, 0.32, 0.15}, {0.42, 0.52, 0.05}, {0.27, 0.70, 0.02}, {0.17, 0.81, 0.01}}, {{0.5, 0.33, 0.17}, {0.41, 0.53, 0.05}, {0.27, 0.70, 0.02}, {0.16, 0.82, 0.01}, {0.11, 0.87, 0.01}}};     Graphics3D[{Hue@RandomReal[], Arrow@#} & /@ data]      ![Mathematica graphics](http://i.stack.imgur.com/NQEIx.png)


title: Is there a way to add arrows along a parametric curve inside a manipulate function?

text: I cannot find a good way to add arrows along a parametric curve that I used `NDSolve` to get. I have written everything inside `Manipulate`.               Manipulate[           Module[{Tf, Tm, Ta, Cp, Caf, km, Ea, Rho, DeltaH, UAV,         k, Cps, Qg, Qr, x, sol, p1, p2, p3, p4, z},       Tf = 298; Tm = 298; Ta = 298; Cp = 4; Caf = 2; km = 0.004;        Ea = 1.5*10^4; Rho = 10^3; DeltaH = -2.2*10^5;        UAV = 340;            k[T[t_]] = km*Exp[-Ea*(1/T[t] - 1/Tm)];       Cps = Rho*Cp;       Qg[t_] = -k[T[t]]/(1 + k[T[t]]*Tau)*Caf*DeltaH;       Qr[t_] = Cps/Tau*(T[t] - Tf);       x[t_] = 1 - Ca[t]/Caf;       sol = NDSolve[{          D[Ca[t], {t, 1}] == (Caf - Ca[t])/Tau - k[T[t]]*Ca[t],          D[T[t], {t, 1}] ==            UAV/Cps*(Ta - T[t]) + (            Tf - T[t])/Tau -DeltaH/Cps*k[T[t]]*Ca[t],          Ca[0] == Cao,          T[0] == To},         {Ca[t], T[t]},         {t, 0, 800}];       p1 = ParametricPlot[{T[t], x[t]} /. Flatten[sol], {t, 0, 800},         PlotRange -> {{290, 400}, {0, 1.1}},         PlotPoints -> Automatic]],     {{Tau,45,""},10,100},     {{To,310,""},298,320},     {{Cao,2.4,""},0,5}]      This is the most I can condense it for y'all. I want to add arrows along the solution plotted using `ParametricPlot` I have tried a number of different things but it looks like `Graphics[Arrow[ ]]` is meant more for fixed points and not manipulated curves. Am I right about that or can I put arrows in my plot? I have looked at this post Plotting a set of trajectories but I've been having a bit of trouble following the code after a certain point. Yes, I asked this question on Stack Exchange but I was told to come here instead.


title: Adding tangent (velocity) vectors to a plot of a space curve

text: I am just getting started with _Mathematica_ and need help plotting tangential vectors to a 3D parametric function. I know how to do this in 2D but am unsure how to do it in 3D. Maybe I am using the wrong functions? Anyway, here is my attempt :               Clear[t, x, y, z, P];     x[t_] = 2 Sin[t];      y[t_] = 6 Sin[t/2]^2;     z[t_] = 3 Cos[t];     P[t_] = {x[t], y[t], z[t]};           curveplot = ParametricPlot3D[P[t], {t, 1, 6}, PlotStyle -> Thickness[0.01]];          velocity[t_] = {x'[t], y'[t], z'[t]};     velvector[t_] := Vector3D[velocity[t], Tail -> P[t], VectorColor -> Blue];          velocityvectors = Graphics3D[Arrow[{{P[t]}, {velocity[t]}}]];          Show[curveplot,          Table[velocityvectors[t], {t, 1, 6, (6 - 1)/10}],          PlotRange -> All, AxesLabel -> {"x", "y", "z"}]


title: Finding unit tangent, normal, and binormal vectors for a given r(t)

text: For my Calc III class, I need to find $T(t), N(t)$, and $B(t)$ for $t=1, 2$, and $-1$, given $r(t)=\\{t,t^2,t^3\\}$. I've got _Mathematica_ , but I've never used it before and I'm not sure how to coerce it into solving this. (My professor told us to use a computer, as it starts getting pretty nasty around $T'(t)$. By hand, $$T(t)=\frac{1}{ \sqrt{(1+4t^2+9t^4})}\\{1,2t,3t^2\\}$$ I've tried defining `r` as stated above and using `D`,`Norm`, and `CrossProduct`. However, I get a bunch of `Abs` in my outputs (am I missing an assumption?). Additionally, I can't seem to google up how to ask _Mathematica_ to sub in a specific value for $t$, once I get the equations worked out properly.


title: How to define the tangent gradient operator?

text: I would like to define a new differential operator that is the tangent gradient for a curve $\Sigma$. This is defined as $$\nabla_\Sigma=\mathbf{P}\nabla$$ where $\mathbf{P}$ is the projection operator defined as $$\mathbf{P}=\mathbf{I}-\mathbf{n}\otimes\mathbf{n}$$ where $\mathbf{n}$ is the normal at point $x$. A related question is how to define the Laplace-Beltrami operator for a curve. This is defined as: $$\Delta_\Sigma=\nabla_\Sigma \cdot \nabla_\Sigma$$ For example given a curve defined via the signed distance function $d(x,y)=\sqrt{x^2+y^2}-1$ and a function $u(x,y)$, I want to be able to have a command in _Mathematica_ that gives $\nabla_\Sigma u$ the same way that I can call for example `Grad[u(x,y),{x,y}]`


title: Using Manipulate, how do you display the points on the curve and the tangent vector?

text: I'm new to Mathematica and my assignment is very vague... I'm hoping someone can explain to me a bit more of that this quesion means: > Given the curve C, display the point on the curve and the tangent vector > there for t=[0,1]. Use the manipulate function. I do not want the answer, just an expansion on this question if someone else understands what I am supposed to do. Pointing me in the correct direction would be great. I don't even know what function to use, which means I do not even know enough to Google this problem...


title: Draw Vector Tangent to Point on Parameterized Curve

text: I define the vector function $\vec{r}(t)$ by               r[t_] = {t, Cos[t], Sin[t]}      The command `r'[t]` gives the vector tangent to the curve drawn by $r(t)$ for any specified value of $t$. I can generate the curve for $r(t)$ on the interval $[0, 2\pi]$ via               ParametricPlot3D[{t, Cos[t], Sin[t]}, {t, 0, 2 Pi}]      What I would like to do is draw a tangent vector whose tail actually touches the curve. For example, I would like to draw the vector described by $r^\prime(0)$ with its tail at $r(0)$. Even better would be to wrap this inside `Manipulate` and draw the tangent vector for any $t \in [0, 2\pi]$. How can I accomplish either of these goals?


title: 3D Phase Portrait with direction fields and sample solution curves

text: I have seen NDSolve and ParamtericPlot3D used for things like the Lorenz Attractor, but was wondering if there is a way to draw a 3D phase portrait for a system. Something akin to this: http://www.mapleprimes.com/questions/35774-Phase- Portrait-In-3D Does MMA have something built-in to do this and I have just discovered Trekker, but have not explored it and a search did not turn anything up readily. Thanks for any insights.


title: Exporting EPS figures with dashing from ListPlot

text: I am having difficulties exporting EPS figures. If I use the LineLegend option to create a dashed or a dot-dashed line, it seems ok in _Mathematica_ 9.0 e.g.: ![enter image description here](http://i.stack.imgur.com/c9uRS.png) But the problem came out when the figure was expoted to EPS e.g., ![enter image description here](http://i.stack.imgur.com/gkVOl.png) I use the following _Mathematica_ code               G1 = ListPlot[{           Table[{(i - 1) h, ρf[u, (i - 1) h, RKuOm, FB][[4, 4]]}, {i, 1, n - 1}],           Table[{(i - 1) h, ρf[u, (i - 1) h, RKuOm, FB][[3, 3]]}, {i, 1, n - 1}],            Table[{(i - 1) h, ρf[u, (i - 1) h, RKuOm, FB][[2, 2]]}, {i, 1, n - 1}]           },            PlotRange -> All, MaxPlotPoints -> Infinity, Joined -> True,            PlotLegends -> Placed[LineLegend[{Directive[Purple, Thickness[0.14]],             Directive[Blue, Thickness[0.14], Dashed], Directive[Red, Thickness[0.14],             DotDashed]}, {Style["\!\(\*SubscriptBox[\(ρ\), \(44\)]\)", 22, Bold],             Style["\!\(\*SubscriptBox[\(ρ\), \(33\)]\)", 22, Bold],             Style["\!\(\*SubscriptBox[\(ρ\), \(22\)]\)", 22, Bold]},            LegendMarkerSize -> {{35, 8}}], {{0.82, 0.4}}], AspectRatio -> 0.8,            PlotStyle -> {{Purple, Thickness[0.012]}, {Blue, Thickness[0.014],             Dashed}, {Red, Thickness[0.013], DotDashed}},  Frame -> True,            FrameStyle -> Directive[Thick, 15],           FrameLabel -> {Style["\!\(\*SubscriptBox[\(ω\), \(1\)]\)t", 18], None},            Epilog -> {Inset[Style["(a)", 24, FontFamily -> "Times", Bold], {6, 0.95}],                     Inset[Style["G=0.1", 24, FontFamily -> "Times", Bold], {41.5, 0.61}]}]          Export["D:\\fermion.eps",G1,"EPS"];`      So, my question: why the style of the lines change? And how to solve? Many thanks in advance.


title: Workbench install 64-bit on Windows 7

text: I have downloaded the Workbench 2.0.0 zip file and followed the install new software -> add -> archive steps to install the workbench plugin. After that, the Workbench core and webMathematica tools are listed as already installed. I installed the plugin into a 3.8 vintage eclipse. When I try to "Run" a notebook in a _Mathematica_ projects (basic or application) I get the following error message: > FrontEnd Job:: Open Notebook has enountered a problem. An internal error > occurred during::FrontEnd Job::Open Notebook. > > Details: an internal error occurred during: "FrontEnd Job::Open Notebook". > com.wolfram.jlink.NativeLink.MLOpenString(Ljava/lang/String;[Ljava/lang/String;)J I believe I have the right path to the _Mathematica_ executable (when I change the path to point to a non existing file, I get a message that says to adjust the path). Most postings on this site suggest that 32-bit is the only workable solution while at least one post indicated that there is a workaround for 64-bit machines. I'd rather use 64-bit kepler (4.2 vintage eclipse). Is that possible? I couldn't find the details from the one posting that indicated 64-bit is possible. Can someone provide the details?


title: Expansion with binomial coefficients

text: How can I get binomial coefficients in expansion of $(n x+i) (1+i x)^n+(n x-i) (1-i x)^n$, where $i=\sqrt{-1}$ and $n$ is an integer. I have no idea how to coax Mathematica to do something remotely close to this without doing a lot of copying and pasting as if I was doing it by hand. If possible, I like the coefficients given in binomial notation.


title: Merging Vertices of a Graph and adding up the edges weights

text: I have a Weighted Graph of `g` which looks like this.               vertex = {a, b, c, d, e}     SeedRandom[1]     g = Graph[#[[1]] -> #[[2]] & /@ Permutations[vertex, {2}],      VertexLabels -> Placed["Name", Center], VertexSize -> 0.3,      EdgeWeight ->      RandomReal[{10, 20},      Count[#[[1]] -> #[[2]] & /@ Permutations[vertex, {2}], _]],      EdgeLabels -> "EdgeWeight"]      ![enter image description here](http://i.stack.imgur.com/eBCao.jpg) Could you please help me to merge two or even more vertices from `g` (Please just `g` I used `Permutations` just to build a graph), in the way that in the end, I have a graph with added up the weights of the previous edges.For example, if vertices `a` and `b` merged together, in new vertex all of weights from old edges added up together to have new edges weights with connected vertices?


title: Equating two lists, element by element

text: Say you have two lists: `listA = {a, b, c}` `listB = {d, e, f}` How would you produce a listC that equates each of the two's elements, ie. `listC = {a == d, b == e, c == f}` ? I know, it's very easy, but somehow I've already spent an slightly embarrassing amount of time on this. I suspect it will involve `Map`, but can't seem to get the elements to behave together per each element. It seems to just `Append` the two together for some reason. `SetAttributes[listA, Listable]` `SetAttributes[listB, Listable]` seems promising given this: http://reference.wolfram.com/mathematica/ref/Listable.html


title: Finessing labels in BarChart

text: `BarChart` is aggravating. Why don't the following correctly display both percentages and labels? (1)               BarChart[{{1,2,3}},       ChartLayout -> "Stacked",        ChartLabels ->          {Placed[{"17%", "33%", "50%"}, Center, Style[#, FontFamily -> "Helvetica", 11]&],          Placed[{"aa", "bbb", "cccc"}, After, Style[#, FontFamily -> "Helvetica", 14]&]},       AspectRatio -> 2,       ImageSize -> 100]      The text labels are rendered correctly (based on an A to a similar Q by Pinguin Dirk here, turns out that the `After` option left-justifies the text, while numerical parameters don't, even with `TextAlignment -> Left` set in `Style`): ![chart with incorrect label display](http://i.stack.imgur.com/REJXa.jpg) I have also tried using `LabelingFunction`: (2)               BarChart[{{1, 2, 3}}, ChartLayout -> "Stacked",      ChartLabels ->        Placed[{"aa", "bbb", "cccc"}, After,         Style[#, FontFamily -> "Helvetica", 14] &],      LabelingFunction -> Placed[{"17%", "33%", "50%"}, Center],      AspectRatio -> 2, ImageSize -> 100]      But it doesn't display _any_ numbers: ![the labels don't work here, either](http://i.stack.imgur.com/rDFm9.jpg) Finally, this works: (3)               BarChart[{{1, 2, 3}}, ChartLayout -> "Stacked", ChartLabels -> {        Placed[{Style[#, FontFamily -> "Helvetica", 10] & /@ {"17%", "33%",             "50%"},          Style[#, FontFamily -> "Helvetica", 14] & /@ {"aa", "bbb",             "cccc"}}, {Center, After}]},      AspectRatio -> 2, ImageSize -> 100]      ![finally, a proper chart!](http://i.stack.imgur.com/bkTNr.jpg) Is the syntax in (1) and (2) incorrect, or are those bugs? Also note that `FontSize` doesn't match. If it is set to the same value for both numerical and text labels, the numerical values look larger. What's going on there?


title: Reap/Sow: strange behavior with tags and functions

text: I was trying to use strings as tags for Reap/Sow and I've found out the following strange behavior when I also add a function as the third argument of Reap[]:               Reap[Sow[11, "a"]; Sow[21, "b"]; Sow[12, "c"]; Sow[15, "a"], {"a", "b", "c"}]          (* {15, {{{11, 15}}, {{21}}, {{12}}}} *)          Reap[Sow[11, "a"]; Sow[21, "b"]; Sow[12, "c"]; Sow[15, "a"], {"a", "b", "c"}, Max]          (* {15, {{Max[15, "a"]}, {Max[21, "b"]}, {Max[12, "c"]}}} *)      Whereas when I use numeric tags I get the following, expected, result:               Reap[Sow[11, 1]; Sow[21, 2]; Sow[12, 3]; Sow[15, 1], {1, 2, 3}, Max]     (* {15, {{15}, {21}, {12}}} *)      Why do string-tags seem not to work properly as "tags"? And more in general, do you know what kind of structures can be used as tags?


title: NDSolve - sampling for result during the computation

text: I am using NDSolve for a Langevin dynamics problem. I want to the know long term behaviour of my system ($t>1$) but it has to be simulated with very small time steps ($dt\sim 10^{-9}$). An example code:               R[t_Real]:= RandomVariate[NormalDistribution[0,1]]          NDSolve[       {(-x''[t] - k1*x'[t] + k2*R[t])==0, x[0]==0, x'[0]==0} //.values,       x,       {t, 0, 10},       StartingStepSize-> 10^-9,       Method->{"FixedStep",Method->"ExplicitEuler"},       MaxSteps->\[Infinity]     ]      **The Problem:** My computer runs out memory when trying to store $10^{10}$ data points necessary for this computation. Is there a way to sample and store only a small subset of all the integration points?


title: Fundamental Theorem of Calculus for definite integrals... assume continuity?

text: So here's the problem: I can evaluate the indefinite integral:               Integrate[D[u[x], x], x]      > >     u[x] >   However, I'd like to evaluate:               Integrate[D[u[x],x], {x, x0, x1}]      and get > >     u[x1] - u[x0] >   Or especially, evaluate               Integrate[D[u[x, y], x], {x, x0, x1}]      and get > >     u[x1, y] - u[x0, y] >   Is there a way that I can assume that `D[u[x], x]` is continuous in the range x0 to x1? Is there a some assumption that can be met in order for me to evaluate the fundamental theorem of calculus?


title: How does Mathematica's LowpassFilter work?

text: I don't really understand the documentation for the `LowpassFilter[]` function in _Mathematica_. In the course I have about signal processing, low-pass filters come in many different forms and from different kinds of operations, so I was just wondering if someone could explain to me the math behind this specific function.


title: Antialiasing in 3D

text: Is it possible? Is it platform specific? Does it rely on the graphics hardware? Why does the antialiasing slider under **Preferences** > **Appearance** > **Graphics** do nothing? I remember seeing some post-plotting solutions years before in MathGroup, but could not find it. **Edit** System is: HP EliteBook 8440p, integrated Intel HD Graphics, running Windows 7, 64bit


title: How to change a spacing between the lines of a notebook?

text: My question is formulated above. However, to precise a bit I would like to split it into two sub-questions:   1. It it possible to define the spacing in the current notebook/CDF pressumably through the Option Inspector. I have in mind that this definition should persist in case the notebook is given away and opened on another machine, where Mathematica or PDF Player are ignorant of my settings?   2. How to control the line spacing through the StyleSheet?


title: How to draw a box with holes using Mathematica

text: ![enter image description here](http://i.stack.imgur.com/3p3AR.png) How to draw these two(especially the second one) graphs using Mathematica? The curve is not important.The point is how to dig some holes in a cube. BTW, These two shapes are Homotopy.


title: Return value of Reap when using tags

text: I've noticed a behaviour of `Reap` that I don't quite understand yet. Suppose I want to `Sow` several values during a computation.               sowstuff := (Do[Sow[i, tag1], {i, 5}]; Do[Sow[i^2, tag2], {i, 5}])      If I `Reap` this, I get one list of values per tag.               Reap[sowstuff] // Last     -> {{1, 2, 3, 4, 5}, {1, 4, 9, 16, 25}}      ![TreeForm of plain Reap](http://i.stack.imgur.com/oyIxP.png) If I specify the tags i want to use explicitly, each of these lists gets wrapped in an additional list:               Reap[sowstuff, {tag1, tag2}] // Last     -> {{{1, 2, 3, 4, 5}}, {{1, 4, 9, 16, 25}}}      ![TreeForm of Reap with explicit tags](http://i.stack.imgur.com/Xb2IT.png) I believe I understand how `Reap` in general works. What puzzles me is the purpose of this additional wrapping. After reading the documentation of `Reap` and `Sow`, I have not yet seen a situation in which this list contains more than one element. So my questions are:   * Is there a reason for the introduction of another list?   * Can this list have more than one element or is it always safe to just run `Map[First,%]` to remove it?


title: plotting output from FindRoot

text: I am an R user and am totally new to _Mathematica_. I am trying to find the roots of a system of two equations over a series of paramter values and plot the results. I can do the computation but would love to know how I can work with the results without exporting them from _Mathmatica_.                alphas = Table[               FindRoot[ {               S1*(1 - Exp[-R01*(1 - alpha)*Zinf1/N1 - R02*alpha*Zinf2/N2]) - Zinf1,               S2*(1 - Exp[-R02*(1 - alpha)*Zinf2/N2 - R01*alpha*Zinf1/N1]) - Zinf2} == 0,                {Zinf1, 10000},               {Zinf2, 10000}], {alpha, 0, 1, .1}]      This seems to return a list of named lists (each element being something like `{Zinf1 -> 9403.65, Zinf2 -> 9800.66}`). I would like to plot all the `Zinf1`'s vs. `alphas` and thought something like `ListPlot[]` could do it, but it seems to have issues with the name:               ListPlot::optx: Unknown option Zinf1 in ListPlot[Zinf1->9403.65,Zinf1->9475.33,Zinf1-    9533.97,Zinf1->....      Any idea how to get this data into an easier (perhaps unnamed) form?


title: DSolve does not give solution

text: No answer is given when I evaluate the following expression:               p[x_,t_]:=D[h[x, t], x]     DSolve[{       D[h[x, t], t] == 11120 D[h[x, t], {x, 2}] + 0.000625,       h[60000, t] == 10,       p[0, t] == 0,       (h[x, 0])^2 == 45100 - 0.0000125 x^2     }, h[x, t], {x, t}]      Did I go wrong somewhere?


title: Partial convolution of random variables in random vectors

text: Suppose $(X_1,Y_1)$ is a bivariate random vector with a given distribution and let $X_2$ be a univariate random variable with the same distribution as $X_1$ but independent of $(X_1,Y_1)$. I want to find the distribution of $(X_1+X_2,Y_1)$. As an specific example suppose $(X_1,Y_1)$ is bivariate normal so my first attempt was the following code:               \[ScriptCapitalD] =      TransformedDistribution[{u + w ,      v}, {{u, v} \[Distributed]       BinormalDistribution[{0, 0}, {1, 1}, 0.5],      w \[Distributed] NormalDistribution[0, 1]}];          PDF[\[ScriptCapitalD], {x, y}]          PDF[     TransformedDistribution[{u + w,      v}, {{u, v} \[Distributed]      BinormalDistribution[{0, 0}, {1, 1}, 0.5],      w \[Distributed] NormalDistribution[0, 1]}], {x, y}]          Mean[\[ScriptCapitalD]]          {0, 0}          Covariance[\[ScriptCapitalD]]          {{2., 0.5}, {0.5, 1.}}      I have tried some other distributions such as uniform distribution as well but I can not get the `PDF` of the joint distribution. Although I can find the answer myself by using the transformation theory for random variables I wonder if it is possible to get the results in Mathematica.


title: How do I export to Excel in multiple, named worksheets?

text: If I have two lists:               list1 = {{1, 2}, {3, 4}};          list2 = {{5, 6}, {7, 8}};      I want to export these two lists to an Excel file and have `list1` in a a worksheet called "list1" and `list2` in a worksheet called list2. How do I do that ...using information contained in `ref/format/XLSX` and `ref/format/XLX`? **Edit** What I had in mind actually was from the Import and Export sections of the documentation for XLSX that give descriptions of the syntax for exporting.               Export["file.xlsx",expr, elem] creates an XLSX file by treating expr as specifying element elem.          Export["file.xlsx",{expr1,expr2,...},{{elem1,elem2,...}}] treats each expri as specifying the corresponding elemi.          Export["file.xlsx",expr,opt1->val1,...] exports expr with the specified option elements taken to have the specified values.          Export["file.xlsx",{elem1->expr1,elem2->expr2,...},"Rules"] uses rules to specify the elements to be exported.      Could I re-phrase and ask if someone could explain how the Export syntax examples above map to a working export to two worksheets? For example elements in the documentation, at the top of the documentation page anyway, are not listed for `Export`(other than "Data") but are listed as e.g. "Data","Formulas" etc. for `Import`. So I am unclear about how any of those export syntax examples correspond to something containing a worksheet name.


title: How to convert this answer into $\ln$ form?

text: I find the integral               Integrate[Sqrt[2 x - x^2] + x^3 Log[(9 - x^2)/(9 + x^2)], {x, 0, 2}]      and got               1/2 (-36 + \[Pi] + 65 ArcTanh[4/9])      How can I write this answer has the form $\dfrac{65}{4} \ln \dfrac{13}{5} + \dfrac{\pi}{2}-18$


title: How to protect existing MathLink connection from disconnecting

text: I am developing an application that consists of a Mathematica package and an external Java program. The purpose of the application is to read streamed data from a port and update a variable in the Mathematica package through a callback function. The callback scheme works using ImplementJavaInterface and the possibility to pass objects as references through MathLink. After the connection is established, the given variable is updated in Mathematica as expected. In the meantime, the notebook that uses the package (and sees the updated variable) does not noticeably block, and I can perform other operations while the variable is updated "in the background". However, a problem occurs whenever I call the help function (e.g., ?Plot, or ?anything). Sometimes the call goes through and returns the help text. On other occasions, the help text is returned, but as a side effect the link between Mathematica and the external Java program is broken, and I get a message such as:               LinkObject::linkd: Unable to communicate with closed link LinkObject[RealTimeLink,49,17].      It seems as if the help function is running into concurrency issues, and breaks the link. It is interesting that I have only found this to happen with help, other functions (even ones that take relatively long to evaluate) run fine. I would be grateful for any leads on this issue, as I can't see the relationship between help and the LinkObject I previously establish. Here are some details on the implementation: When initializing the Mathematica package, the Java program is started, and it creates two KernelLinks like so:               String[] argstopass = {"-linkmode", "listen", "-linkname", "RealTimeLink"};     String[] argstopass2 = {"-linkmode", "listen", "-linkname", "CommandLink"};     datalink = MathLinkFactory.createKernelLink(argstopass);     commandlink = MathLinkFactory.createKernelLink(argstopass2);      Afterwards, the Mathematica package connects to the two listening links, and the Java program sends an event handler object to Mathematica by reference. This allows Mathematica to attach a listener to the object (using ImplementJavaInterface):               datalink.enableObjectReferences();     datalink.discardAnswer();     datalink.putFunction("EvaluatePacket", 1);     datalink.putFunction("InitializeStreamListener", 1);     datalink.putReference(eh); //this is the event handler object     datalink.endPacket();     datalink.discardAnswer();     datalink.evaluate("$ParentLink = First[Links[]];");      On the Mathematica side, this is what the beginning of InitializeStreamListener[] looks like:               InitializeStreamListener[input_] := Module[{},     streamListenerInterface = ImplementJavaInterface["StreamListenerInterface",{"onDataArrival"->"StreamDataArrived"}];     input@addListenerObject[streamListenerInterface];      After this initialization, the Java program runs in an indefinite loop, while periodically checking for any commands through CommandLink (for example, to quit), and if necessary (when an interesting event occurs) invoking eh.notifyEventListener(), which in turn calls the onDataArrival function of the interface that is implemented in Mathematica. The function updates the variable. Perhaps I should note that RealTimeLink in Mathematica (above) corresponds to the datalink KernelLink which is created in Java. It is curious that it is always this link that is broken (I suppose because it is the only one that is active, invoking the callback function at least once every second). Thanks in advance for your help!


title: Detecting KeyUp events

text: Is there a way to detect when a key is released, similar to               EventHandler[InputField[], {"KeyDown", "k"} :> Print["k pressed"]]      It seems such detection isn't available at first glance, perhaps it can be achieved some other way? Alternatively is there a way to detect which keys are currently pressed? I know that;               CurrentValue["ModifierKeys"]       Works for `shift`, `ctrl` and such, but I can't seem to figure out how to get a list of regular keys being pressed. Edit: `CurrentValue["EventKey"]` does not seem to work for this purpose as it only detects keydown events, thus you cannot do something like the following which detects shift-up               shiftDown = False;     Dynamic[     If[MemberQ[CurrentValue["ModifierKeys"], "Shift"], (shiftDown = True;),            If[shiftDown, (shiftDown = False; Print["Shift up code"])]         ]     ]      link to MathGroup post


title: Does AbsoluteTiming slow the evaluation time?

text: I've started using `AbsoluteTiming` to discriminate between similar function constructs, but I sometimes feel like it takes substantially more time to evaluate a function using `AbsoluteTiming` than without. Is this behaviour normal? (This may qualify as a second question) Is there a way to know how much time the last evaluation took, without wrapping it in a timing function?


title: What is the most efficient way to save a big graphic?

text: I want to generate a graphic using               DiscretePlot[primePercent[x], {x, 10^10},        ImageSize -> Full,        Filling -> None,        Joined -> True]       where               primePercent[x_Integer] := 100 PrimePi[x]/x      When I generate it for 10^6, my computer becomes slow as there are simply too many data points. What I'm wondering is if I can get some load off my RAM by continually saving the evaluated data to a file (or using a different evaluation method/graphic options, of course)? Does `Export[]` save the file only once it has been generated?


title: Import a large no. of image from a folder together to Mathematica and assign a variable to each of the image

text: I am using Mathematica for the processing of images. For this I have to process a lot of images. Currently, I import one by one of the images to run the simulation. I want to import all the image files of a folder and assign variable to each of them...How to do it? Any suggestion?


title: Importation multiple dcm images

text: I'm extremely new to Mathematica. I want to import 201 .dcm (DICOM) files into Mathematica 9. Is there a way to do this which doesn't require my doing it an image at a time? My ultimate need to is to then create a 3D image from these files. Can anyone help? Thanks


title: Examples of (well coded) packages using custom notation

text: Which packages do you know of, that have the following properties:   * using custom notation (for input AND output would be preferable)    * well coded & designed (from your subjective perspective!)


title: Enhanced "Complete Selection" (dynamic autocomplete) for Text input?

text: The autocomplete ("Complete Selection") feature `Ctrl`-`K` (or `F2` on Windows) works fine for functions and code input. Is there a way to enhance it for text input? Today’s standard (see e.g. OpenOffice etc.) is to autocomplete based on words already occuring in the text. For text _Mathematica_ will just display words from a (very simple) dictionary. If I type e.g. "Grav" it will show "Grave", "Gravy" etc. It does not even seem to know "Gravity" or "Gravitation" (despite these being common words and despite occurences in my text)


title: What's wrong with this code to create a matrix?

text: Here is my code:               h = .2;      m = .04;     k = 4/Pi^2;     L = 4;     n = L/h;      s = k*m/h^2;     A = SparseArray[{Band[{1, 1}] -> 1.0 + 2.0*s, Band[{2, 1}] -> -s,          Band[{1, 2}] -> -s}, n + 1];      Here's the error:               SparseArray::dims: The dimensions 21.` in SparseArray[{Band[{1,1}]->1.81057,Band[{2,1}]->-0.405285,Band[{1,2}]->-0.405285},21.] are not given as a list of positive machine integers. >>      I've been experimenting with this for quite a while now and can't seem to figure out what's wrong. Any ideas?


title: Map structure of irregular list, Flatten then reconstruct list using structure

text: I'm trying to use `Compile[]` to improve the performance of an algorithm. The algorithm works on a set of matrices which are not of a similar shape. Unfortunately to use the Compile function, lists passed to it must be of similar shape.   To circumvent this inconvenience, I propose to `Flatten` the set of matrices before passing the resultant flat vector to the compiled function and then reconstructing the vector into the set of matrices before applying the algorithm. Sounds simple but actually implementing it in Mathematica is proving difficult (for me) - help appreciated. The general gist of what I want to do is as follows:               (* Generate a set of irregular shaped matricies *)     mSet = {Table[RandomReal[], {i, 3}, {j, 5}], Table[RandomReal[], {i, 5}, {j, 4}], Table[RandomReal[], {i, 4}, {j, 6}]};          (* Create a mapping that describes the structure of the set of matrices *)     mStruct = FunctionToGenerateVectorThatDescribesTheStructure[mSet]          (* myCompiledFunc uses mStruct to reassemble the flattened mSet before doing it's thing *)     myCompiledFunc = Compile[{{setOfMats, _Real, 1}, {matStructure, _Integer, 1}},         (* Reconstruct the setOfMats *)         ReconstructedSetOfMats = someReconstructionFunction[setOfMats, matStructure];         (* do stuff with the reconstructed matricies *)     ];               (* Use the compiled function *)     (* Flatten the set of matricies so we can pass it and the structure to a compiled function *)     myCompiledFunc[Flatten[mSet], mStruct];


title: Stuck in local minimum in NonlinearModelFit using Simulated Annealing?

text: I recorded a set of experimental rates $r = r(c,T,P)$ at 2 values of $c$ and >15 values of $T$.   $r(c,T,P)$ obeys the following functional form: $$ r(c,T,P) = \frac{c+1}{1+e^{\frac{W-X*T}{T}}}e^{-\frac{Y-Z*T}{T}}. $$ Now I am trying to obtain the the 4 parameters $P=\\{W,X,Y,Z\\}$ via global non-linear regression in a Monte carlo simulation, in which I repeatedly generate a set of Gaussian-noised data based on the error estimates of $c,T,r$. Each dataset is fitted to $r(c,T,P)$ against $c$ and $T$ and the fitted parameters are averaged to get their mean and std-values. For the constrained regression I use Mathematica 8.0 and the function               NonlinearModelFit[myData,fitModel,fitParams,Method-> NMinimize,Method->"SimulatedAnnealing"}]       Allmost all regressions converged. I noticed, that ~3 out of 4 fits can are 'good' (nice interpolation of the data by the fit), while 1 in 4 does not seem to interpolate the dataset properly. Below picture: red and blue curves were fitted to the first dataset at c=c1 (red points) and c=c2 (blue points). I would deem them as good, while the green and yellow curves from dataset 2 are bad. However I don't see any 'significant' difference between the two raw datasets. ![dataset 1 at c=1 \(blue\) and c=2 \(red\), dataset 2 at c=1 \(yellow\) and c=2 \(green\) and respective interpolations obtained from NonlinearModelFit](http://i.stack.imgur.com/yzjnA.png) I played around with the fitting method using various options given by Mathematica, but I found that 'simulated annealing' gave superior results. Varying the parameters of 'simulated annealing' (InitialPoints, PertubationScale,PostProcess ..) did not lead to a better rate of good fits. Looking at the ParameterTables, it becomes obvious, that the errors are reasonable for dataset 1, while errors for Y and Z in dataset 2 are nearly ~0 (all BestFitparameters are not close to Constraints). As shown, there is also a difference in the CurvatureTable. I tried to understand the meaning of CurvatureTable, but the Manual and google are not very informative on this particular subject. As far as I understand, small values of Intrinsic and Parameter effects compared to Conf.Region indicates, that the minimum of the target function of the minimization can be approximated by a plane locally at the BestFitParameters. This should mean, that the solution is stable with respect to small variations of the BestFitParameters. The BestFitParameters should therfore be acceptable?! Now my questions: 1) Is there an apparent reason for the failure of the fits (which I don't see and might be optimized, e.g. wrong fitting routine, functional form of the fitmodel,..?) 2) Can I use the FitCurvatureTable to conclude, that the found solution is likley to be stuck in a local minimum? 3) Will the selection of 'good fits' give a bias to the results and is therefore inappropriate? I would be very glad, if someone could help me with these question or relate me to someone/somewhere that could do so. Since I am not an expert, I would also appreciate recommendations for article/books (beginner compatible) on the presented topic. Thx in advance!


title: How to create a discrete 2d slider using existing 2d data?

text: data = Sort[RandomReal[{0, 1}, {100, 2}]];     Manipulate[pt, {pt, data}, ControlType -> Slider2D]      I get a error message: > Manipulate::vstype: ControlType -> Slider2D is not supported for the > variable specification Is there a workaround? What I'm trying to achieve is something like this               {Slider2D[Dynamic[pt1], {{0, 0}, {1, 1}, {0.5, 0.5}}], Dynamic[pt1]}      here pt1 can take from               {{0, 0}, {0, 0.5}, {0, 1}, {0.5, 0}, {0.5, 0.5}, {0.5, 1}, {1, 0}, {1,0.5}, {1, 1}}      . Now I want to use my own `data`, which may contain points that are not equally space.


title: Select a Placeholder in a Notebook?

text: How might I select the 1st Placeholder in a Notebook?               SelectionMove      Has no option.               Button["Click Here",      NotebookWrite[        InputNotebook[],        ToBoxes[Unevaluated@Sum[Placeholder[m ], {t, 1, n}]],        Placeholder];      ]


title: Mathematica package for supergravity and superstring theory

text: I am looking for a Mathematica package that can manipulate tensors for supergravity, string theory or M-theory. I am particularly looking for a package that can do spinor and Clifford algebra computations. Also, I would like this package to be able to do wedge and hodge dual, and other computation relating to forms. Can anyone suggest a specific one? I looked for atlas2, but it seems I have to pay to use it without a trial version.


title: Inclusion-Exclusion Principle Implementation

text: I would like to know how I can write a _Mathematica_ code for the Inclusion–exclusion principle. The formulas governing it are: $ P(\bigcup_{i=1}^n A_i)=\sum_{k=1}^n (-1)^{k-1} \sum_{\substack{I\subset\\{1,2,...,n\\}\\\|I|=k} }P(\bigcap_{i\in I} A_i) $ where $P(A_i)$ denotes the probability of the event $A_i$. Similarly for cardinality of union we have: $ |\bigcup_{i=1}^n A_i|=\sum_{k=1}^n |A_k|- \sum_{1\leq i_1<i_2\leq n} |A_{i_1}\cap A_{i_2}|+\sum_{1\leq i_1<i_2<i_3\leq n} |A_{i_1}\cap A_{i_2}\cap A_{i_3}|-\cdots+(-1)^{n-1}|A_{i_1}\cap A_{i_2}\cap\cdots\cap A_{i_n}| $ or in closed form $|\bigcup_{i=1}^n A_i|=\sum_{\substack{\emptyset\neq I\subset\\{1,2,...,n\\}\\\|I|=k} }(-1)^{|I|-1} |\bigcap_{i\in I} A_i|$


title: How do I construct a pure function to extract data fields from records that are strings?

text: How can I get from data segment format to the final segment format with a pure function? The data fields are fixed length. There are no separators between the fields. a) list               wordlength = {11, 20, 10, 9};     from = 2; to = 3;            datasegment = {"        109Lemon Chiffon       25:22:29  6519218  ",                    "       2082Mint Cream          39:24:41  7314284  ",                    "       6790Indian Red          21:57:53  3368766  "};  s     finalsegment = {"Lemon Chiffon       25:22:29  ",                     "Mint Cream          39:24:41  ",                     "Indian Red          21:57:53  "};        b) string               dataline = {"       1556Floral White        29:48:49  7856900  "};     finalline = {"Floral White        29:48:49  "};      * * * ## **Update** Final solutions were found for the task. I like to share it here.               inlist = RandomChoice[     {"       2524Lemon Chiffon       22:51:28  1881779  ",      "       3085Teal                19:22:24  9744812  ",      "       5935Light Yellow        03:32:54  8374029  ",      "       6128Powder Blue         27:20:07  7315046  "},      400000];            wordLength = {11, 20, 10, 9};     fromWord = 2;     numberOfWords = 2;            fields = Length[wordLength];     borders = {{1, wordLength[[1]]}};     Do[     borders =      FlattenAt[{borders, {borders[[i, 2]] + 1,      borders[[i, 2]] + wordLength[[i + 1]]}}, 1], {i, fields - 1}];     grenz = {borders[[fromWord, 1]],      borders[[fromWord + numberOfWords - 1, 2]] };     outlist = StringTake[inlist, grenz];// Timing            {0.141, Null}        The honor goes to the very concerned in this task. Every detail of their conception was vital to the solution. Keep'n rocking.


title: Counting adjacent elements in a Matrix?

text: To start, I have a situation where I have some matrix, for example $$ A=\left[ \begin{matrix} 4&2&2&3&3\\\ 2&3&1&2&3\\\ 3&0&4&0&4\\\ 1&4&1&1&2\\\ 1&3&4&1&4\\\ \end{matrix} \right] $$ and I would like to count how many adjacent elements there are. Adjacent elements can be up, down, left or right. For a pair to be valid the numbers have to have the same value. For example $\left(A_{1,2},A_{1,3}\right)$ is a valid pair because the are both $2$ and they are next to each other. I need a way to count the defined adjacent element pairs on a matrix of size $n$. eg. $$ \left[ \begin{matrix} 2&2&3\\\ 3&2&3\\\ 2&1&1 \end{matrix} \right] $$ There would be 4 pairs in this matrix. I thought about converting the matrix into some sort of graph with "weighted vertices" however I had no clue on doing so. It would have then made it a matter of counting arcs. So how would one produce a function that takes in a matrix and spits out the number of pairs (by my definition) it contains? I am unsure whether or not I have tagged this correctly.


title: Using Locators in a non-standard Manipulate code

text: I'm trying to adapt **Nasser** 's method for using a **control variable** inside Manipulate to selectively choose what part of the code should be recalculated depending on the controls changed (see this question). I need this functionality for a simulation I'm working on about the field lines of an electric dipole. In the simulation it should be possible to move the two charges q1 and q2 generating the field and also to move a third point P. The point P only serves to see the field line passing through P. Since the single field line originating from P should have different graphical parameters than the field lines of the "background field", I've created two different Streamplots: " _fieldlines_ " is for the general field and " _fieldpoint_ " is for the single line through P. They are combined together with the " _Show_ " command. Nasser helped me a lot with the code and his version addresses the problem of the selective recalculation. But in my plan I'd like to use three **Locator** instead of 3 **Slider2D**. Locators are easy to set in a standard Manipulate code, but are not easy to implement in a custom code like the following one:               Manipulate[tick;      Show[f2, f1, ImageSize -> 300],           Text@Grid[{         {Grid[{            {"Q1"},            {Slider2D[Dynamic[q1pos, {q1pos = #;                 f1 = fieldlines[q1pos, q2pos, pnts];                 f2 = fieldpoint[q1pos, q2pos, pt];                 tick = Not[tick]} &], {{-6, -6}, {6, 6}, {.1, .1}}]},            {Dynamic[q1pos]}            }, Alignment -> Center]}         ,         {Grid[{{"Q2"},            {Slider2D[Dynamic[q2pos, {q2pos = #;                 f1 = fieldlines[q1pos, q2pos, pnts];                 f2 = fieldpoint[q1pos, q2pos, pt];                 tick = Not[tick]} &], {{-6, -6}, {6, 6}, {.1, .1}}]},            {Dynamic[q2pos]}            }, Alignment -> Center]}         ,         {Grid[{{"pt"},            {Slider2D[Dynamic[pt, {pt = #;                 f2 = fieldpoint[q1pos, q2pos, pt];                 tick = Not[tick]} &], {{-6, -6}, {6, 6}, {.1, .1}}]},            {Dynamic[pt]}            }, Alignment -> Center]}         }, Spacings -> {.5, 1.5}, Alignment -> Center, Frame -> All        ]      ,      {{tick, False}, None},      {{q1pos, {-2, 0}}, None},      {{q2pos, {2, 0}}, None},      {{pt, {-2.5, 2}}, None},      {{f1, fieldlines[{-2, 0}, {2, 0}, Tuples[{-3, -2, -1, 0, 1, 2, 3}, 2]]}, None},      {{f2, fieldpoint[{-2, 0}, {2, 0}, {-2.5, 2}]}, None},      {{pnts, Tuples[{-3, -2, -1, 0, 1, 2, 3}, 2]}, None},      ControlPlacement -> Left,      ContinuousAction -> False,      SynchronousInitialization -> False,      TrackedSymbols :> {tick},       Initialization :> (             field[x_, y_, q1pos_List, q2pos_List] := Module[{},          {           (2 (x - q1pos[[1]]))/EuclideanDistance[q1pos, {x, y}]^3 +               (-2 (x - q2pos[[1]]))/EuclideanDistance[q2pos, {x, y}]^3           ,           (2 (y - q1pos[[2]]))/EuclideanDistance[q1pos, {x, y}]^3 +              (-2 (y - q2pos[[2]]))/EuclideanDistance[q2pos, {x, y}]^3}          ];             fieldlines[q1pos_List, q2pos_List, pnts_List] := Module[{x, y},          StreamPlot[field[x, y, q1pos, q2pos], {x, -5, 5}, {y, -5, 5},           StreamPoints -> pnts, StreamScale -> Automatic , PerformanceGoal -> "Quality"]];             fieldpoint[q1pos_List, q2pos_List, pt_List] := Module[{x, y},          StreamPlot[field[x, y, q1pos, q2pos], {x, -5, 5}, {y, -5, 5},           StreamPoints -> {             {              {pt, {Thickness[0.005], RGBColor[1, 0, 0], Arrowheads[0.02]}}              }, Automatic, {ForwardBackward, 400}}, PerformanceGoal -> "Quality"]          ]             )      ]      So my question to _advanced users_ is if it's possible to substitute the 3 Slider2D controls with 3 Locator in this context without disrupting the selective recalculation achieved so far. It seem a **tough thing** to do since these controls are not located in the usual control section of a standard Manipulate command. Thanks for your help.


title: Unable to Solve Two-Point Boundary Value Problem

text: I'm trying to solve the equation `-u''[x] + ((x - k)^2 - en[x]) u[x] == 0` using the boundary conditions `u[0] == u[8] == 0, u'[0] == 1`. en[x] is meant to be an eigenvalue that depends upon the value k. For this reason I wrote               Block[{k = 4},      sol = NDSolve[{-u''[x] + ((x - k)^2 - en[x]) u[x] == 0, en'[x] == 0,     u[0] == u[8] == 0, u'[0] == 1}, {u, en}, x]];      But plotting (`Plot[u[x] /. First[sol], {x, 0, 10}]`) this gives solutions u[x] which look nothing like they should and values en[x] nowhere near the values they should have and the following messages:               FindRoot::cvmit: Failed to converge to the requested accuracy or precision within     100  iterations. >>          NDSolve::berr: There are significant errors {-0.0000120696,-0.0000359624,-0.99995} in     the boundary value residuals. Returning the best solution found. >>


title: How to put labels on a 3d plot

text: I'm close, but I'm stuck. Here's my code so far:               data = Import["http://www.powerball.com/powerball/winnums-text.txt",         "Table", "HeaderLines" -> 1];          clipped = Take[data[[All, 2 ;; 7]]];          ListPointPlot3D[clipped];          balls = Take[clipped[[All, 1 ;; 6]]];          whiteballs = Take[balls, 10];          sorted = Map[Sort, whiteballs];          p = ListPlot3D[sorted, Mesh -> All, InterpolationOrder -> 0,        ColorFunction -> "TemperatureMap"]          labels = Graphics3D[Text[ToString@Round[#, 1], #, {0, 0}]] & /@        Take[sorted[[All, 1 ;; 3]]]          Show[{p, labels}]      I would like to have the ball numbers placed on top of each of the colored squares, but I'm out of ideas.


title: User-defined template; removing repeated text (v 9.0.1)

text: In _Mathematica 9.0.1_ , I want to write a user-defined template for a function that I wrote: `myfunc`               Remove[myfunc]     myfunc::usage = "myfunc[x,y,z] is a function.                      myfunc[x,y,z,w] is another function."      with the result: ![User-defined template for myfunc](http://i.stack.imgur.com/ho9Nr.png) As you can see, within the description "myfunc" is (in my opinion) unnecessarily repeated. In fact, templates for built-in functions do not behave that way. For example, look at the template for the `Integrate` function: ![Build-int template for Integrate](http://i.stack.imgur.com/hkIab.png) The function name "Integrate" is not repeated in the description. How do I tell _Mathematica_ not to repeat the name of the function inside the description?


title: Tooltip not showing fully - mostly whitespace

text: Here is an example of what I mean, the tooltip doesn't show most of the requested text ("example" in this case). ![enter image description here](http://i.stack.imgur.com/XCcJp.png) There is more information about my code in my previous question: show contour area as tooltip. However, I made this post to address the display issue with the tooltip which is likely a broad problem. Here is the code from the symptomatic screenshot I showed.               w = 4;     plot = ContourPlot[         Sqrt[(x - 2)^2 + (y - 2)^2 - 5], {x, -15, 15}, {y, -15, 15},          PlotPoints -> 30, MaxRecursion -> 4, Contours -> {w},          ContourStyle -> Blue, ImageSize -> 250] /. _Polygon ->          Sequence[] /. Tooltip[x_, y_] :> Tooltip[x, "example"]        Which can be simplified to just               ContourPlot[        Sqrt[(x - 2)^2 + (y - 2)^2 - 5], {x, -15, 15}, {y, -15, 15},         Contours -> {4}] /. _Polygon -> Sequence[] /.       Tooltip[x_, y_] :> Tooltip[x, "example"]        and still have the same issue with the tooltip not showing. I have tried adding a `Pane` wrapper around `"example"` within the argument of the last `Tooltip`, but this hasn't helped.


title: SubTitle and SubSubTitle do not group by default

text: For some reason, the `SubTitle` and `SubSubTitle` cell formats do not group automatically on my machine any more, and I cannot figure out how to fix that. To be explicit, here is a picture of the problem: ![enter image description here](http://i.stack.imgur.com/hXoo8.png) If you notice, only the topmost layer in the hierarchy will automatically group with those below it, until you reach the `Section` level (level-4 on the default stylesheet). This makes using the notebook interface difficult for deeply nested topics, as there are only an effective 4 levels of grouping available to me. How can I fix this?