title: Is it possible to circumvent a bug inside SeriesCoefficient?

text: As far as I can tell, there seems to be a bug in `SeriesCoefficient`:               In[4]:=        f[z_] := (-z + z Sqrt[1 - 4 z^2])/(2 (-1 + z));       SeriesCoefficient[f[z], {z, 0, 10}]       SeriesCoefficient[f[z], {z, 0, n}] /. n -> 10          Out[5]= 9          Out[6]= 93/256      Note that both outputs should be the same, but apparently the application general in `n` makes a mistake (`9` is the correct result). In fact, I know that the coefficients grow exponentially in `n` but we get:               In[9]:=        SeriesCoefficient[f[z], {z, 0, n},          Assumptions :> Mod[n, 2] == 0 && n >= 2] // FullSimplify          Out[9]= 1/2 (1 - Gamma[n/2]/(Sqrt[\[Pi]] Gamma[(1 + n)/2]))      This quantity, $\qquad\displaystyle \frac{1}{2} \cdot \biggl(1 - \frac{\Gamma\bigl(\frac{n}{2}\bigr)}{\sqrt{\pi} \cdot \Gamma\bigr(\frac{n+1}{2}\bigr)} \biggr)$, converges to 1/2 from below (odd `n` support the same series), so it's not even _close_ to being correct. Obviously, I can't tell what exactly goes wrong inside `SeriesCoefficient`. Since I have an interest in the general form of the coefficient (of the expansions of this and other functions), is there a way to circumvent the bug inside (or the application of `SeriesCoefficient`) so that it works more reliably? Less power would be acceptable in trade.


title: recursive integration

text: I am trying to do multiple integrations recursively. For instance, I would like to do the following equation for arbitrary integer $n$: $\displaystyle R_n(t) = \int_0^t \mathrm dt' R_0(t-t') R_{n-1}(t')$ where $R_0(t) = e^{-k t}\cos\omega_0 t$. I can do it by brute force, but I would like to be able to do it automatically for any $n$.


title: Making a symbol's new definitions be tried before all previously defined ones

text: Is there any way to "close" a package (or a symbol, or a context) in that if a user of the package adds definitions to the symbol they will be tried before the package defined ones, just like what happens with built-ins?


title: Fast randomization of a graph, while keeping the graph connected

text: I'm looking for a very efficient method for randomizing graph of a given size (N nodes, L links), but keeping them connected. Assume you have the adjacency matrix A of a given connected graph. You want to generate R (usually a big number) random adjacency matrices Aran1,Aran2,...AranR, with the same N, L, AND connected. I did the following code, I'm looking for a more efficient one.               randomization[Q_] :=        Module[{Aran = {0, 0}},         While[           Length[Select[Total[Aran], # == 0 &]]> 0,            Aran = Partition[Nest[RandomSample, Flatten[Q], 10], Dimensions[Q][[2]]]         ]     ];      Thanks!


title: Anchor Manipulate Controls to Edges of Content

text: I'm running into an issue with arranging Manipulate controls and a dynamic module around the content pane of the Manipulate. For example:               Manipulate[      Plot[a b c x, {x, 0, 100}, PlotRange -> {0, 100}],      {{a, 1}, 0, 2, Appearance -> "Labeled"},      {{b1, 1}, 0, 2, Appearance -> "Labeled"},      {{b2, 1}, 0, 2, Appearance -> "Labeled"},           Dynamic[       Plot[        Sin[t], {t, 0, 10}, AspectRatio -> 1.5, ImageSize -> {200, 300}        ]],           {{b, 1, Row[{Spacer[300], "a"}]}, 0, 2, Appearance -> "Labeled"},      {{c, 1}, 0, 2, Appearance -> "Labeled"},      ContentSize -> {400, 260},           ControlPlacement ->        Flatten[{Table[Left, {4}], Table[Bottom, {1}], Table[Right, {7}]}]     ]      ![Imgur](http://i.imgur.com/6YMFfWz.jpg) I want the slider on the bottom, labeled "a" (oops, should have been b), to be sitting right underneath the content of the Manipulate (the linear graph). However, the dynamic module on the left-hand side, which is a plot of a sine function, seems to "push" the control further down than I want it to. How can I fix this?


title: Running out of variables

text: I am running symbolic calculations with Mathematica. Simplification of algebraic expressions is an important part of them as very often final results can be simplified considerably. Typically my expressions involve many variables that can be categorised into few groups. I use to denote a group by a letter, variables within the group are distinguished by an index, e.g. $A_1$, $B_2$, etc. At some point I found out (and tried to discuss it here Simplifying using assumptions) that _FullSimplify_ command best works with variables without any subscripts. In the example below **the result** of the simplification is cardinally different depending whether I am using **plain letters** $-\frac{p}{a+x}+\frac{q}{x-a}+\frac{P}{b+x}+\frac{Q}{b-x}$ or **letters with subscripts** $\frac{B_1 \left(a_1+x\right) \left(A_2 \left(a_2-x\right) \left(-a_1+a_2+2 x\right)-\left(a_1-a_2\right) B_2 \left(a_2+x\right)\right)-A_1 \left(a_1-x\right) \left(\left(a_1-a_2\right) A_2 \left(a_2-x\right)+B_2 \left(a_1-a_2+2 x\right) \left(a_2+x\right)\right)}{\left(x-a_1\right) \left(a_1+x\right) \left(a_2-x\right) \left(a_2+x\right)}$. Clearly, I prefer the first form. Therefore I am using rules to replace indexed variables with plain letters, perform a simplification, and using the rules again to replace plain letters by the original indexed variables. However, it is not very convenient method, also in view of the fact that the number of letters is finite... Therefore I have a question, is there a way to teach _FullSimplify_ to work as efficiently with indexed variables as it does with the normal ones? Below are two equivalent expressions. The first one contains only letters               f2 = (-p (a - x) ((a - b) P (b - x) + Q (b + x) (a - b + 2 x)) + q (a + x) (-(a - b) Q (b + x) + P (b - x) (-a + b + 2 x)))/((b - x) (-a + x) (a + x) (b + x));     rule2 = {(p + q) -> 1, (P + Q) -> 1};     FullSimplify[f2] /. rule2      It leads to the first equation. The second one               f1 = ((x + Subscript[a,1]) Subscript[B,1]((-x + Subscript[a, 2])(2 x - Subscript[a,1] + Subscript[a,2]) Subscript[A,2]-(Subscript[a,1]-Subscript[a, 2]) (x + Subscript[a,2]) Subscript[B,2]) - (-x + Subscript[a,1]) Subscript[A,1] ((Subscript[a, 1] - Subscript[a,2]) (-x + Subscript[a,2]) Subscript[A,2] + (2 x + Subscript[a, 1] - Subscript[a, 2]) (x + Subscript[a,2]) Subscript[B,2]))/((x - Subscript[a,1]) (x + Subscript[a,1]) (-x + Subscript[a, 2]) (x + Subscript[a, 2]));     rule1 = {Subscript[A,1] + Subscript[B,1] -> 1, Subscript[A,2] + Subscript[B,2] -> 1};     FullSimplify[f1] /. rule1      Is equivalent to the first one, however, it is returned unsimplified (at least with my version of Mathematica: 9.0.1 for Mac OS X). Two expressions are equivalent as the following command shows               FullSimplify[f1 - f2 /. {Subscript[a,1] -> a, Subscript[a,2] -> b, Subscript[A,1] -> p, Subscript[A,2] -> P, Subscript[B,1] -> q,Subscript[B,2] -> Q}]      Returns **0**. Thank you in advance.


title: how to write TableForm expression into file?

text: Now I have a list stored in `data` as follows               data = {{"Ca", 1, 1, 1}, {"Ca", 2, 2, 2}, {"Ca", 3, 3, 3}}      the `TableForm` of `data` is of course as follows:               Ca  1   1   1     Ca  2   2   2     Ca  3   3   3      But how to write this `TableForm` of `data` into a file? I tried code like               OutputForm[TableForm[data]]>>"test"      But the result is               Ca   1   1   1          Ca   2   2   2          Ca   3   3   3      **Why there are blank lines????** How to prevent the emergence of these blank lines when write TableForm expression into a file?


title: How can I exhibit the evaluation of formulas in a Mathcad-like way?

text: ![enter image description here](http://i.stack.imgur.com/U7KsR.png) How can I create a function F that works like this:                x = 2      f1 = x^2 + 3      f2=x+5           F[f1]      > >     x^2 + 3 = 2^2 + 3 = 7 >                  F[f2]      > >     x + 5 = 2 + 5 = 7 >


title: How to control the positions of contour labels?

text: ContourPlot[x^2 + 5 y^2, {x, -5, 5}, {y, -2, 2},        Contours -> {2, 4, 6, 8, 10, 12, 14, 16, 20},        ContourLabels -> True,        AspectRatio -> Automatic,        ContourShading -> None]      gives result ![enter image description here](http://i.stack.imgur.com/b4CiV.png) But I want result like this ![enter image description here](http://i.stack.imgur.com/o57OD.png) So I hope this code will work               ContourPlot[x^2 + 5 y^2, {x, -5, 5}, {y, -2, 2},        Contours -> {2, 4, 6, 8, 10, 12, 14, 16, 20},        ContourLabels -> (Text[#3, {#1, 0}, Background -> White] &),        AspectRatio -> Automatic,        ContourShading -> None]      But it didn't, it gives result ![enter image description here](http://i.stack.imgur.com/xD7Og.png) **So how to control the position of`ContourLabels`?**


title: Finding shortest non-zero vector $x$ satisfying $Ax=0 \pmod q$

text: Let $n$, $m$, and $q$ be positive integers (with $m > n$), and $A$ be a matrix over $\mathbb{Z}_q^{n \times m}$. Using Mathematica, I want to find the shortest non-zero vectors $x \in \mathbb{Z}_q^m$ such that: $$Ax=0 \pmod q$$ Note: By "shortest," I mean the vector with the smallest Euclidean norm. I'm not sure if this vector is unique. If it's not, I want a list of vectors with smallest Euclidean norm. * * * **Example:** Let: $n=2, m=3, q=7, A = \left(\begin{matrix} 2 & 1 & 6\\\ 1 & 3 & 1 \end{matrix} \right)$. Then, the following vectors are solutions to {1,1,3} $\quad$ Norm = $\sqrt{11}$ {3,3,2} $\quad$ Norm = $\sqrt{22}$ {2,2,6} $\quad$ Norm = $\sqrt{44}$ {5,5,1} $\quad$ Norm = $\sqrt{51}$ {4,4,5} $\quad$ Norm = $\sqrt{57}$ {6,6,4} $\quad$ Norm = $\sqrt{88}$ Therefore, the vector {1,1,3} is the shortest solution. * * * **PS:** I used an exhaustive search to find the above solutions. My approach takes a long time for even small choices of $n$ and $m$, say $n=2, m=8$. Please offer an approach which can at least find solutions for such small parameters. **Edit:** As Michael suggested in a comment, I demonstrate the "exhaustive search" code I used. I'm not proud of it at all, as I just wrote the code to find an example for this question.               A = RandomInteger[6, {2, 3}];     x = {a, b, c};     Table[       If[Mod[A.x, 7] == {0, 0}, Print[{x, x // Norm}]],          {a, 0, 6}, {b, 0, 6}, {c, 0, 6}]


title: How to simulate a multivariate recursive system from a list

text: New to mathematica, trying to use Eric Swanson's Pertubation AIM program to solve DSGE models. His code produces a solution as a list or a table. My question is how do I use this list to simulate the model without copying and pasting stuff? For the one sector stochastic growth model, the solution (as a list) appears as:               {A == 0.800000000000000 A[-1 + t] + 1.00000000000000 eps,      C == 0.1114834992288968 + 0.292723851887318 A[-1 + t] +      0.1186384419679934 Inv[-1 + t] + 0.447062121415789 K[-1 + t] +      0.365904814859147 eps,      Inv ==      0.4186970784697240 + 0.902059574107021 A[-1 + t] -      0.0225290917630828 Inv[-1 + t] - 0.0848957841160119 K[-1 + t] +      1.12757446763378 eps,      K == 1.431977509390795 + 0.238836154208396 Inv[-1 + t] +      0.900000000000000 K[-1 + t],      r == 0.01010101010101003 + 0.0880808080808080 A[-1 + t] -      0.01840727127888952 Inv[-1 + t] - 0.0693636363636363 K[-1 + t] +      0.110101010101010 eps,      Welf == -988.913562642210 + 5.22803270579111 A[-1 + t] +      0.893524510010050 Inv[-1 + t] + 3.36704491694070 K[-1 + t] +      6.53504088223889 eps,      Y == 0.4295932528172384 + 0.800000000000000 A[-1 + t] +      0.0716508462625189 Inv[-1 + t] + 0.270000000000000 K[-1 + t] +      1.00000000000000 eps}      All variables except investment (Inv) are in logs. eps is the technology shock (i.e., A=0.8*A[t-1]+eps where A is log total factor productivity). I also have a list of steady state values {0, 0.1114834992288968, 0.4186970784697240, 1.431977509390795, \ 0.01010101010101003, -988.913562642210, 0.4295932528172384}. So my question is, given these lists, how do I assign the steady state as starting values for the model, assign a random sequence to eps, and simulate the model?


title: Finding all possible solutions to a math mind game

text: In the example below the letters shall be replaced by numbers. The numbers are from `1` to `9`, and each letter has the same number (e.g. `E = 4` all the time. Different letters must have different numbers, so `E = W = 4` is not allowed): ![Problem](http://i.stack.imgur.com/5uJAf.png) If one choose e.g. `E = 4` (and some other numbers for the other letters), it can be easily seen that ![Wrong solution](http://i.stack.imgur.com/uSGGK.png) is not a correct solution because E is in the first two rows 4 but not in the third row! After some attempts I found that ![One possible solution](http://i.stack.imgur.com/A69t4.png) is a solution. I know that there are also some other solutions which solve this problem correctly. So, my question is: How can I find with _Mathematica (9.0.1)_ ALL possible solutions? My approach is the following: I create an array with all possible combinations:               values =      Table[{(z*1000 + w*100 + e*10 + i), (v*1000 + i*100 + e*10 + r),      (z*1000 + w*100 + e*10 + i) + (v*1000 + i*100 + e*10 + r)},      {z, 1, 9}, {w, 1, 9}, {e, 1, 9}, {i, 1, 9}, {v, 1, 9}, {r,1, 9}];      And then I want to search in the array `values` for the correct combinations. But I have some problems to write a nice searching-program for this. Could anybody help? I also have doubts if it is a good idea to create such a big `values`-array because I create numbers like `1111` which are forbidden. Is there a way that I can create a leaner array? Or does anybody have another nice idea how I could find all correct solutions for this problem? I would be very happy about any help!


title: Utterly confounding behaviour in Mathematica 9 DSolve

text: I've been baffled by a lot of the behaviours of _Mathematica 9_ — so much that I regret upgrading my copy of _Mathematica 8_ (I would downgrade but I'm currently on vacation). Here is an example:               DSolve[{x^2*y''[x] + x*y'[x] - y[x] == 0}, y[x], x]      should return the simple answer of C1*x + C2/x. In fact, this is what Wolfram Alpha returns and also Mupad (a Maple within Matlab). However, _Mathematica_ returns ![Mathematica picture](http://i.stack.imgur.com/PX7gW.png) Yes, I know you can simplify this for real output, but it baffles me why it doesn't do it in the first place. Moreover, once your differential equations become messy, this can be hard to do. I have encountered other examples where the output from Mathematica's `DSolve` seems to very strange indeed. This isn't an isolated example, and I encounter examples of these very simple DEs that _Mathematica_ fails to simplify in any sort of obvious way. I don't remember these difficulties in _Mathematica 8_ or previous versions. Does anybody know what is an easy fix or what's going on? I have also documented similar bugs in the series expansions here and here.


title: Exporting large png results in completely black image

text: When trying to export an `Image` as PNG the resulting file is a completely black image. This happens only for certain images I have not been able to determine exactly which, so I uploaded a notebook that triggers it. Is this a known bug with a known fix? ![brokenness screenshot](http://i.stack.imgur.com/thXBI.png) Some system info:               Fedora 19 3.9.9-302.fc19.x86_64     Mathematica 8.0.4     8Gb RAM


title: select subsets of elements of a list under a certain condition

text: I am new in _Mathematica_ and am stuck on a simple problem. Please advise: I have the following list:               list = {     {"1", 1000},     {"2", 800},     {"3", 800}     };      I want to select subsets of the first elements `Subsets[list[[All,1]]]` when the `Total` of coresponding second elements is for example $>= 1000$. So in this example the expected result is: > >      {{"1"}, {"1", "2"}, {"1", "3"}, {"2", "3"}, {"1", "2", "3"}} >   I solved it using @Kuba's answer below, and added DeleteDuplicates to make it work better (produce less output) on large datasets:               lst = DeleteDuplicates[     If[     Total[#[[;; , 2]]] >= 1000,          #[[;; , 1]]] & /@ (Rest@ Subsets[list]) /. Null -> Sequence[]     ]      // TableForm


title: How can I remove text headers when importing a numeric table

text: I have a file let's say 1.txt having numbers like:               fgdgfdg     fhdfdh     0.000105533 1.00E-04     0.222281    1.00E-04     0.444456    1.00E-04     0.666631    1.00E-04     asdas       ddfdsfsd     0.111193    0.166733     0.333369    0.166733     sadsd       dfffsas     0.777719    0.166733      I want to delete all this unknown string during the import process. It would be great help if you can provide me some solutions. I have tried various commands like delete, replace, cases but it doesnt work .... thanks


title: How can I share objects with dynamic content with non-Mathematica users?

text: Often when I construct some cool `Manipulate[]` function, I would like to share it with others--non-Mathematica users. Some software, notably Cinderella, supports exporting some dynamic calculations to a Java applet. I can see why this would be very difficult to achieve with Mathematica, for it would require exporting all the under-the-hood calculations to Java. Nevertheless, how do you all share dynamic results from Mathematica to others on the web? Often I resort to `Export["filename.gif", {img1, img2, ...}, "GIF"]` to share animations. What better alternatives are available?


title: RowReduce for symbolic matrices

text: I'd like to invoke `RowReduce` on some matrices with a time parameter. For example consider               A = {{1, 0}, {0, t}}      If `t = 0`, we have               RowReduce[A /. t -> 0] = {{1, 0}, {0, 0}}      but `RowReduce[A]` always returns the identity matrix. How can I tell _Mathematica_ to distinguish cases where there might be division by zero? **Edit** : Maybe I need to clarify my problem a bit more. I don't know much about the matrices, except that they contain some time dependence. Now, whatever form the given matrix has, I want to perform some operation to attain a (time-depending) row-echelon form of my matrix that is valid for all $t \in I\subseteq\mathbb{R}$.


title: Inputting a big structured matrix in Mathematica

text: Hi this is my first post and this is a problem that has bothered me a lot. Suppose we have the $2012\times2012$ square matrix: $\begin{bmatrix}-3&1&1&1&1&1&\ldots&1&1&1&1\\\1&2&1&1&1&1&\ldots&1&1&1&1\\\1&1&-3&1&1&1&\ldots&1&1&1&1\\\1&1&1&2&1&1&\ldots&1&1&1&1\\\1&1&1&1&-3&1&\ldots&1&1&1&1\\\1&1&1&1&1&2&\ldots&1&1&1&1\\\\\vdots&\vdots&\vdots&\vdots&\vdots&\vdots&\ldots&\vdots&\vdots&\vdots&\vdots\\\1&1&1&1&1&1&\ldots&-3&1&1&1\\\1&1&1&1&1&1&\ldots&1&2&1&1\\\1&1&1&1&1&1&\ldots&1&1&-3&1\\\1&1&1&1&1&1&\ldots&1&1&1&2\end{bmatrix}$ How can I write it using _Mathematica_? Of course I need to define something like a function which will assign elements to the positions of the matrix.


title: Listing all usage messages from a loaded package

text: I am writing several packages in collaboration with others. In order to help the group use my packages, I want to provide them with a simple reference of function names and usage messages. How can I best do this? ### Additional information: Although I didn't originally ask for it, I'd like to be able to do the following:   1. save the function names with their usage messages   2. into some text-based file (e.g. LaTeX, HTML, markdown, plain text)   3. that organizes the functions under section headings that specify which package they came from. Here's what it might look like in plain text:               PackageName1          function1 :: does something     function2 :: does something else          PackageName2          function3 :: does it do something?     function4 :: does, perhaps, something      Formatted versions like LaTeX that require compiling are, perhaps, less useful to the community, but they just look so nice :)


title: Export Graphics[] without white edges

text: I am trying to generate & Export[] Image with the below code, but as shown in the images I get some white border around my rectangle. How could I export an images that stopes right at the edge of my Rectangle[] edges ? ![enter image description here](http://i.stack.imgur.com/hZ1VA.png)               c0 = {RGBColor[23/85, 29/255, 142/255], RGBColor[244/255, 1, 59/255],            RGBColor[1, 0, 32/85], RGBColor[18/85, 72/85, 197/255]}               Export[FileNameJoin[{Directory[], "DropBox", ToString[#] <> ".jpg"}],     Graphics[{EdgeForm[Thick],      White, Rectangle[{0, 0}, {160, 90}],      Flatten@({Flatten@(Table[               RandomChoice[{GrayLevel[.15], c0[[#]]}], {3}] & /@              Range[2, 4, 1]),          MapThread[           Function[{Xs, Ys},            Rectangle[{Xs, Ys}, {Xs + 16, Ys + 9}]],           {Flatten@Table[Range[0, 32, 16], {3}],             Flatten@(Table[#, {3}] & /@                Range[63, 81, 9])}]}\[Transpose]),      Black, Thick, Line[{{0, 63}, {160, 63}}]}, ImageSize -> 300]] & /@      Range[100]


title: Can Mathematica use a MySQL ODBC connector?

text: I have a MySQL database that I connect to using Mathematica and would like to distribute my Mathematica code to others. We already have ODBC DSNs setup on peoples machines using the MySQL ODBC connector. I've done a similar thing before in R using RODBC. I attempted to use this;               Needs["DatabaseLink`"];     JDBCDrivers["ODBC(DSN)"]     conn = OpenSQLConnection[JDBC["ODBC(DSN)", "DatabaseName"]];      Which looked like it was going to work but after reading the documentation it seems that it uses a JDBC-ODBC bridge which I can't assume people have installed. My question is can Mathematica use a ODBC connection (without a bridge) and if so how? If I have to use a JDBC connection then that's fine but I want to make sure that I'm not missing something.


title: Making time differentials look like the textbook

text: I need to have time differentials to look like the 'textbook'. My code is               Dt[x y^2] /. {Dt[x] -> dx/dt, Dt[y] -> dy/dt}       which gives the output               (2 dy x y)/dt + (dx y^2)/dt.       This is very hard to follow. My question is how can the output be made to look like               2 x y dy/dt + y^2  dx/dt       (only with `dy/dt` and `dx/dt` vertical). Thanks.


title: creating vectors with normal distribution of lengths

text: First consider vectors of unit length, say on the unit sphere. Now I want to give some magnitude to these vectors and I want the magnitude to be chosen from the normal distribution. In one dimension that is easy:               RandomReal[NormalDistribution[0,x]]      However, if my vector is arbitrarily pointed I cannot take from this distribution since I cannot have a negative magnitude. The only way I can think of giving the vector a normal distribution of lengths is by using               RandomReal[HalfNormalDistribution[y]]      which forces the randomly chosen quantity to be > 0. Does this seem like the proper procedure?


title: Using Mathematica to find poles of Gamma functions

text: I am concerned about the expression on the RHS of equation A.5 (page 19) in this paper: $$\int\frac{d^d q}{(q^2)^{\nu_1}[(\vec{k}-\vec{q})^2]^{\nu_2}}=\frac{\Gamma(d/2-\nu_1)\Gamma(d/2-\nu_2)\Gamma(\nu_1+\nu_2-d/2)}{\Gamma(\nu_1)\Gamma(\nu_2)\Gamma(d/2-\nu_1-\nu_2)}\pi^{d/2}k^{d-2\nu_1-2\nu_2}$$   * Can I use _Mathematica_ to find a Laurent kind of expansion of the RHS in the limit of $d-3 = \epsilon \rightarrow 0$? I would guess that it has poles in $\epsilon$ and I would like to know the residues.    * And could I have used _Mathematica_ to do this integral and give me the value as stated in equation A.5?


title: Storing data in the Notebook in readable form

text: The common problem in my theretical work is a need to import some experimental data to work with. This means that my notebook depends on some external files which makes it difficult to share it with others and inconvenient when I return to it after time. These data are generally very much smaller than the notebook I get after analysing it. What I wish is to have a way to store the data inside the notebook in collapsable cells in order to have an ability to view the data in tablular form and to re-import the data file manually if I change it. Generally, the data inside of the notebook should look as on the sceenshot: ![screenshot](http://i.stack.imgur.com/IuKM8.png) The output cells are regenerated by pressing Shift + Enter when the data files change. What I need is a way to retrieve the data sets from the output cells in the section `"The data cells"`. Something like this:               dataSet1 = getData["Data set 1"];     dataSet2 = getData["Data set 2"];      where `"Data set 1"` and `"Data set 2"` are the text strings in the `Subsubsection` cells from the section `"The data cells"`. How to achieve this?


title: Make good looking histograms from frequency data

text: I allways do my calculations in _Mathematica_ and I make my histograms using ROOT language. However I am wondering is it possible to make good looking histogram inside _Mathematica_? A sample of what I mean is the following figure (made by ROOT): ![enter image description here](http://i.stack.imgur.com/ZC406.jpg) Some sample data (not identical to the one used in the above plot) which can be used:               data = {154.081, 468.999, 648.538, 776.386, 899.310, 766.234, 596.229, 527.160, 443.315,              300.393, 216.542, 105.620, 53.7748, 29.0068, 21.4696, 8.92971, 8.63114, 5.70516,              60.5296};      using as the red pluses inside histogram and               montecarlo = {180.836, 492.187, 739.735, 894.031, 915.812, 841.874, 699.237, 556.588,                    426.208, 303.230, 212.114, 133.295, 71.6399, 36.9657, 21.9234, 9.20245,                   6.13829, 5.20975};      using as the best fit to the data. Note that both data sets are final frequency values and not the original data set on which `Histogram` could work.


title: Generate Random Text within a Rectangle

text: I would like to generate images such as the four below. That is: some text of different length fit within a `Rectangle[]` using `Graphics[]`. But I don't know how to "go to the next line" at the edge of the `Rectangle[]`. The text could either be a random length of "Lorem Ipsum" or alternatively some random text. ![enter image description here](http://i.stack.imgur.com/hYJT3.png) **EDIT** Provided kguler figured out my plan, here it is : I need to fit the text as below. I have yet not been able to place any solution well in my Graphics[], code below. ![enter image description here](http://i.stack.imgur.com/T3PdA.png)               c0 = {RGBColor[23/85, 29/255, 142/255], RGBColor[244/255, 1, 59/255],            RGBColor[1, 0, 32/85], RGBColor[18/85, 72/85, 197/255]}               Graphics[{       EdgeForm[Thickness[.005]], White,       Rectangle[{0, 0}, {160, 90}],       Black, Opacity[.7],       Rectangle[{0, 0}, {80, 63}],       Opacity[1],       Flatten@({Flatten@(Table[            RandomChoice[{GrayLevel[.15], c0[[#]]}], {3}] & /@           Range[2, 4, 1]),       MapThread[        Function[{Xs, Ys},         Rectangle[{Xs, Ys}, {Xs + 16, Ys + 9}]],        {Flatten@Table[Range[0, 32, 16], {3}],          Flatten@(Table[#, {3}] & /@             Range[63, 81, 9])}]}\[Transpose]),       Black, Thickness[.005], Line[{{0, 63}, {159, 63}}]},        Method -> {"ShrinkWrap" -> True},       ImageSize -> 500]


title: WYSIWYG table creating and editing

text: In Microsoft Office OneNote 2010, creating and editing tables is easy. There are simple toolbar controls for creating tables: ![Creating a table](http://i.stack.imgur.com/yptMM.png), and editing them once they exist: ![Editing a table](http://i.stack.imgur.com/DelBl.png). My question is, what's an easy way to get the same functionality for a _Mathematica_ notebook? I would like to be able to create tables containing text, images, or inline math writing. Editing a cell in a table should be just like editing the contents of a text cell. Ideally, the appearance of the table would be customizable, e.g. cell border and background colors. Maybe a palette would help.


title: I need to multiply a series of matrices

text: I need to perform a dot product on a large number of 2 x 2 matrices that I have defined to differ by even/odd subscripts (Ex: D-odd=x but D-even=y). The $\Pi$ function will not work because it does not perform dot products. Does anyone know how I can carry out this large series of matrix multiplications. Thanks


title: ListPlot Inset coordinates problem

text: Inset seem better suited for ad-hoc labels and legends than for precision, programmatic placement of annotation. Given the following 'bottom-up' graphic expression:               Graphics[{       Darker@Blue,        Point /@ Table[{k, Last@CountSelectMouseEvents["049", k]}, {k, -10,           10, 0.1}],       Red, Line[{{0, 0}, {0, 55}}], Text["55", {0, 55}, {2, 0}],        Darker@Green, Line[{{1.3, 0}, {1.3, 37}}],        Text["37", {1.3, 37}, {-2, 0}]       }, AspectRatio -> 1/GoldenRatio, Frame -> True]      Which yields: ![enter image description here](http://i.stack.imgur.com/06HNJ.jpg) How can the annotation graphics:               Red, Line[{{0, 0}, {0, 55}}], Text["55", {0, 55}, {2, 0}],            Darker@Green, Line[{{1.3, 0}, {1.3, 37}}]       be `Inset` in `ListPlot` to create the same graphic? (use random points in lieu of CountSelectMouseEvents). I can never get the placement precise enough given the oblique syntax and placement rules.


title: Making a wav file from a list of numbers in Mathematica

text: I have a list of numbers from a simulation of acoustic pressure generated by a virtual musical instrument by another program (Comsol multiphysics). I would like to "hear" the tone produced by different settings in the virtual instrument. How can I do this? In particular, can I convert the data into a .wav file?


title: Map a function over the columns of an M x N array

text: I have a $N \times M$ list of lists, or rather, a list of records and I want to map a function over its columns (e.g. find the mean temperature, age, etc.). `Map` would apply the function to each list within the list, but I want to slice vertically, rather than horizontally. How can I do this? Example: Return a list of means for `{{1, 4, 7}, {2, 5, 8}, { 3, 6, 9}}` rather than `{1,2,3}`, etc. The list:               {{1, 2, 3},       {4, 5, 6},      {7, 8, 9}}


title: Why does OS X need permission to allow JLink connections each time it starts?

text: I understand that JLink loads each time _Mathematica_ launches or each time a kernel starts, and that this can require permission from the firewall, if it is enabled ![enter image description here](http://i.stack.imgur.com/jOZpl.png) but OS X provides settings the provide this permission by default, so that I don't have to provide it each time _Mathematica_ starts (a process that seems to cause delays and even crashes _Mathematica_ in some cases). However, even if I give this permission, I still get asked for it again, each time. ![enter image description here](http://i.stack.imgur.com/AD44l.png) _Mathematica_ is is the only application on my system that does this. Why? Is there some way to configure _Mathematica_ so that it behaves as it should; or is this a bug? What does _Mathematica_ need "incoming network connections" for anyway? Can turn off the need for them in _Mathematica_ somewhere?


title: Exporting a 3D plot into a 3D viewing format and axis scaling

text: I've been trying to export a Plot3D into an X3D (JVX, VRML) file using the Mathematica's Export function. The problem is that when the PlotRange is large compared to the other two dimensions the output is essentially stretched into a thin line. Is there a way to maintain the original scaling? Try the following:               Export["file.x3d", Plot3D[x^2+y^2,{x,-10,10},{y,-10,10}]];      The `VerticalAxis` option does not seem to help... Thanks.


title: VertexList ordering of a simple graph

text: Given a simple graph like               g=Graph[{b -> c, a -> b}]      I would like to have `f[g]` resulting in `{a,b,c}` but for instance `VertexList[g]` results `{b,c,a}` which's not wanted. Is there any simple way to do this?


title: How to set default save directory for notebooks?

text: Based on certain previous questions, I figured that if my `NotebookBrowseDirectory` looked like this               Options[$FrontEnd, NotebookBrowseDirectory]     {NotebookBrowseDirectory -> "/Users/brian/mma"}      then the OSX front end would default to saving new notebooks there. Instead it defaults to saving them in the home directory `/Users/brian`. Does there exist a variable I can set to make the UI default to saving into a different directory from my homedir?


title: Graphics3D model of the human body and organs?

text: Does someone have a 3D model for a man (or woman) that can be displayed in _Mathematica_ using `Graphics3D`? I have tried importing free .3DS models but they look pretty awful and you lose opacity, etc. Is there a complete model of a human built from graphics primitives? I've seen the demonstration by Stewart Dickson but I need the whole body (and ideally some organs.)


title: Circle as a function parameter

text: ![enter image description here](http://i.stack.imgur.com/JFVw5.png) What I want to do is to find a circle which is tanget to the three big ones. I tried the code below:                   findSmallCircle[c1_Circle, c2_Circle, c3_Circle] :=      But how do I get the center point and radius of each circle c1, c2, c3, and if this cannot be done, what else can I try? Excuse me if this is a silly question -- I am new to _Mathematica_


title: Symbolic FindInstance

text: I'm wondering if there is any way of doing something like the following: `FindInstance[x < y, {x}, Reals]` and getting, as a possible return value, `{x -> y - 1}`. Currently `FindInstance` will complain that y is a non-constant expression..


title: Combining Cos[ ] terms

text: A function that is the sum of two Cosine terms of the same frequency                x[t_] := a1 Cos[w0 t + b1] + a2 Cos[w0 t + b2];      can be simplified to a single `Cos`. By hand, I can calculate that this is equal to `a3 Cos[w0 t + b3]` where               a3 = Sqrt[(a1 Cos[b1] + a2 Cos[b2])^2 + (a1 Sin[b1] + a2 Sin[b2])^2]     b3 = ArcTan[a1 Cos[b1] + a2 Cos[b2], a1 Sin[b1] + a2 Sin[b2]]      As a check, if you pick numbers, you can see that the plots lie right on top of each other. I would like to have Mathematica give the simplified one-term form (rather than the sum) but can't figure out how to make this happen. More generally, I would like to have many such terms in an expression (including `Sin`s as well as `Cos`s) and to be able to simplify them all. I have tried the obvious things like: `TrigToExp[x[t]]` and `TrigExpand[x[t]]` and `FullSimplify[x[t]]` but Mathematica doesn't seem to want to combine them into the single `Cos` term. Even if I supply numerical values for the constants (`a1`, `b1`, `a2`, and `b2`) it still does not do the simplification. Any help is appreciated.


title: How to define a variable as a function of another variable?

text: I want to define a variable `q` which is a function of `t`. And I want to define another variable `qdot = dq/dt`. Then what I want to archive is that if I have a function `f = a*Sin[q]`, and when I take the derivative `df = D[f,t]`, _Mathematica_ returns: > >     a*qdot*Cos[q]. >   Is there a way to do this?


title: Find polynomial equation for set of 3D data

text: data was given in columns in the order {y, x, z}, with y dependent on x, z               points = {{144, 18, 52}, {142, 24, 40}, {124, 12, 40}, {64, 30,          48}, {96, 30, 32}, {74, 26, 56}, {136, 26, 24}, {54, 22,          64}, {92, 22, 16}, {96, 14, 64}, {92, 10, 56}, {82, 10, 24}, {76,          6, 48}, {68, 6, 32}};          equation2 = A + Bx + Cz + D*x^2 + Ez^2 + Fx*z;     nlm = NonlinearModelFit[points, equation2, {A, B, C, D, E, F}, {x, z}, Method -> NMinimize]      I get errors, and nothing that gives the values of the coefficients A,B,C,D,E,F... What am I doing wrong?


title: why I can not find the correct derivative with D

text: the coupled ODE is               f[a_?NumericQ] := NDSolve[{(x[r] (192 + (20 r^3 y''[r])/y[r]))/     r^4 == 5 x''[r]/r,      1000 (2 (x'[r])^2 + 2 x[r] x''[r]) +        250 (2 (y'[r])^2 + 2 y[r] y''[r]) == -5/(4 r),      x[1] == 0,      y[1] == 1/10 Sqrt[1/2 Log[5/2]],      y'[1] == -((1 - Log[5/2])/(20 Sqrt[2 Log[5/2]])),      x'[1] == a,      WhenEvent[y[r] < 10^(-6), end = r; "StopIntegration",       "DetectionMethod" -> "Interpolation"]},      {x, y}, {r, 1, 5/2},      Method -> {"ExplicitRungeKutta", "StiffnessTest" -> False}];      I want to plot this expression:               g[a_?NumericQ] := NIntegrate[Evaluate[{(Pi (256 x[r]^2 + 16 y[r]^2))/(2 r^3) +         5/2 Pi ((x'[r])^2 + (y'[r])^2)} /.       f[a]], {r, 1, end}][[1, 1]]      the plot of `g[a]` with respect to `a` in the region `{a, 0.0026, 0.008}` ![enter image description here](http://i.stack.imgur.com/MeM3R.png) there is a minimum there, so I use `D` the find the derivative at `a=0.0028`               D[g[a], a] /. a -> 0.0028      0.0500445      the result is rather surprising, since the figure show the slope at `a=0.0028` should be negative. what's wrong with `D`? thanks a lot one more fact, `findminimum` and `NMinimize` give me the correct answer of `a` where the slope is `0`


title: How to split compound polygons into convex polygons?

text: Is it possible to split non-convex polygons into convex plygons with Mathematica 9? For example:               pts={{-5, 29.6537}, {-4, 16.3031}, {-3, 13.8614}, {-2, 9.22332}, {-1,        6.89646}, {0, 6.76047}, {1, 9.20436}, {2, 6.65919}, {3,        18.2084}, {4, 18.9102}, {5, 31.6521}}      ![enter image description here](http://i.stack.imgur.com/R5ajO.png)


title: Solving Complex Equation Over Reals

text: I want to solve the equation $\frac{abi}{a+bi}=4-2i$, where $a$ and $b$ are real numbers. I know from hand-solving the answer is $a=5$, $b=-10$. How do I get _Mathematica_ to tell me this? I tried:               Solve[a b I/(a + b I) == 4 - 2 I, {a, b}]      but this returns               {{b -> -(((2 + 4 I) a)/((-4 + 2 I) + a))}}.      I tried               Solve[a b I/(a + b I) == 4 - 2 I, {a, b},Reals]      but this returns               Solve[a b I/(a + b I) == 4 - 2 I, {a, b},Reals].      Is there a simple way of getting _Mathematica_ to solve this, without knowing lots of special _Mathematica_ commands? In searching out the answer on this site, I see workarounds that a newbie to _MMA_ would never think of themselves, nor understand what they are doing that gives the right answer.


title: Image Processing: Isolating areas of an image with internal irregularity

text: I am trying to isolate each of the blue painted fingernails in the image. However, I am not sure what approach should be considered due to the white design on each nail interrupting the otherwise uniform nail color. This of course, makes `EdgeDetect` a lot harder to apply. Any suggestion would be appreciated.               i = Import["http://i.stack.imgur.com/46JAy.jpg"]      ![Mathematica graphics](http://i.stack.imgur.com/EMCMt.png) **+++++++++++++++++++++++++++++++++ UPDATE +++++++++++++++++++++++++++++++++++++** Thanks to both Belisarius and Vitaliy Kaurov for your in depth responses. I am trying to consider a more general case such as the following image. I would like to use an edge detection approach to find the area of the nails. using a `MedianFilter` does help a lot and isolates the nail areas. However, what would be the next step in using the result to detect the nail areas? I am guessing that I would need to 'complete' the circles of these lines first. Is there a better approach? Perhaps measuring the density of the lines would be the best...               i = Import["http://i.stack.imgur.com/6khSE.png"]      ![Mathematica graphics](http://i.stack.imgur.com/6khSE.png)               EdgeDetect[MedianFilter[i, 4]]      ![Mathematica graphics](http://i.stack.imgur.com/FFNy5.png)


title: Mathematica takes too long to solve this

text: I have the following system of equations:               x = -(1/3) + 4/3 Cos[1/3 π (-t1 - 2 t2)] Cos[1/3 π (-t1 + t2)] Cos [1/3 π (2 t1 + t2)]     y = 4/3 Sin[1/3 π (-t1 - 2 t2)] Sin[1/3 π (-t1 + t2)] Sin[1/3 π (2 t1 + t2)]      and I know that t1,t2 >= 0 and t1+t2<=1. I wanted to ask _Mathematica_ to give me `t1` and `t2` in terms of `x`, `y` \- sort of inverse map the above function. so I did this:               Clear[Evaluate[Context[] <> "*"]];     Assuming[t1 >= 0 && t2 >= 0 &&        t1 + t2 <=         1, {Solve[-(1/3) +            4/3 Cos[1/3 π (-t1 - 2 t2)] Cos[1/3 π (-t1 + t2)] Cos[             1/3 π (2 t1 + t2)] == x &&          4/3 Sin[1/3 π (-t1 - 2 t2)] Sin[1/3 π (-t1 + t2)] Sin[            1/3 π (2 t1 + t2)] == y, {t1, t2}]}]      But it takes too long to solve, and keeps running.. I left it for half an hour and closed the kernel. Is something wrong?


title: warnings shows up in message window

text: I have no idea why, but suddenly all my evaluation with warnings like "sum does not converge" has begun to show up in a message box. Since always they appeared between In[] and Out[]? How do I make it act normally again?


title: How to find the package file that stores a certain symbol?

text: Is it possible to figure out in what file a certain packaged symbol lives in (assuming there is no shadowing between multiple identical symbol names)? I would like to have a function that if, given a context or a symbol from a context, opens up the relevant package file. With `Needs` _Mathematica_ automatically loads all symbols in each package file of the given context if directories are set correctly with `$Path`. It seems though that I cannot access the information **from which file** _Mathematica_ pulls each symbol. It is an overkill to scan through all directories in `$Path` and through all files in each directory to find the given symbol. Is there an easier method?


title: Why BoundedDiagram fails?

text: I have a set of points:               pts={{2.28571, 2.79821}, {2.28571, 3.79821}, {2.28571, 4.79821}, {3.57143,        1.1375}, {3.57143, 2.1375}, {3.57143, 3.1375}, {3.57143,        4.1375}, {4.85714, 0.316071}, {4.85714, 1.31607}, {4.85714,        2.31607}, {4.85714, 3.31607}, {4.85714, 4.31607}, {6.14286,        0.316071}, {6.14286, 1.31607}, {6.14286, 2.31607}, {6.14286,        3.31607}, {6.14286, 4.31607}, {7.42857, 1.1375}, {7.42857,        2.1375}, {7.42857, 3.1375}, {7.42857, 4.1375}, {8.71429,        2.79821}, {8.71429, 3.79821}, {8.71429, 4.79821}}      And I am trying to make its Bounded Voronoi Diagram. When using DiagramPlot I get proper result: ![enter image description here](http://i.stack.imgur.com/k1Stb.png) But when using BoundedDiagram with bound: `{{0, 0}, {10, 0}, {10, 6}, {0, 6}}` following error occurs:               RowReduce::luc: Result for RowReduce of badly conditioned matrix {{-10.,0.,600.},{-7.99361\[CenterDot]10^-15,3.12639\[CenterDot]10^-13,-1.60087\[CenterDot]10^-12}} may contain significant numerical errors. >>      And actually description of this error hardly suggests why this occurs. How to workaround this? EDIT: when points are moved randomly just a bit in random direction function doesn't fail.


title: Merging two line graphs into manipulate command

text: Ultimately the goal is to make a manipulate command and turn a line into a circle. So I am supposed to take a line that is segmented into 12 equal lengths.               M = {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 0}, {8,      0}, {9, 0}, {10, 0}, {11, 0}, {12, 0}, {13, 0}};     Graphics[{Thin,      Line[M, VertexColors -> {Red, Blue, Orange, Green, Red, Blue,       Orange, Green, Red, Blue, Orange, Green}]}]      Then there is the circle               L = {{1, 0}, {Cos[Pi/6], Sin[Pi/6]}, {Cos[(2 Pi)/6],      Sin[(2 Pi)/6]}, {0, Sin[Pi/2]},  {-Cos[(2 Pi)/6],      Sin[(2 Pi)/6]}, {-Cos[Pi/6], Sin[Pi/6]},   {-1,      0} , {-Cos[Pi/6], -Sin[Pi/6]},    {-Cos[(2 Pi)/6], -Sin[(2 Pi)/       6]}, {0, -1},   {Cos[(2 Pi)/6], -Sin[(2 Pi)/6]}, {Cos[      Pi/6], -Sin[Pi/6]}, {1, 0}} ;          Graphics[{Thin,      Line[ { L   },      VertexColors -> {Yellow, Red, Blue, Orange, Green, Red, Blue,       Orange, Green, Red, Blue}]}]      Now I am trying to merge the two. I noticed whenever I start of with the line command I can't get it to work with manipulate.               Manipulate[Thin,      Line[ Plot[{{1, 0}, {2, 0}}, {x, 0, 3}], {a, 0, 2 Pi}  ]      So now I am not sure how to go about the problem since I can't even begin on it. Should I just use the equation of a line? That doesn't seem probably given the question **If you take a fraction f of a final vertex and a fraction 1-f of the corresponding initial vertex, and vary f between zero and one, you will find that a shape evolves from the initial shape to the final shape. Construct a Manipulate[] function with a slider that varies f that shows your straight line curling up into a circle.** Which makes me think that I need to have the individual vertices's in. Please help, thank you


title: Want actual cell data from CellEvaluationFunction

text: Let's say I print a cell like so.               CellPrint@Cell[       BoxData[" "], "Input", Evaluatable -> True,        CellEvaluationFunction -> Function[Print[#];]       ]      Now I type in several lines of text in the `Cell` in _Mathematica_. For example               1               2      I hit `Shift`+`Enter` and get the following output.               BoxData[List["1","3"]]      But when I do `Ctrl`+`Shift`+`e`, the `Cell`s content is really               BoxData[       RowBox[{" ",           RowBox[{            "1", "\[IndentingNewLine]", "\[IndentingNewLine]", "3"}]}]]      Why doesn't `CellEvaluationFuction` receive the actual cell data? Is there a hidden function/argument that might give me such information?


title: How to iteratively integrate a function and sum the result of each iteration

text: I want to repeatedly integrated a function and add the result of each iteration. Suppose I start a with a function $f(x) = x$ , I want to integrated it, it will be $x^2/2$, and again integrating, it will be $x^3/6$, and at the end I want to get the result $x^2/2+x^3/6$. Please help me how to do that.


title: Solve the quadratic equation?

text: I can't seem to solve the general quadratic equation:                Solve[ax^2 + bx + c == 0, x]           Out[299]= {}      It just outputs the empty list. How do I solve this equation?


title: Resolution problem of ContourPlot

text: I met a tricky problem with `ContourPlot`, which is when I change the range of my variable, I get a totally new figure. For example:               ContourPlot[2.` c^4 - 1.693 c^4 x - 0.861 x^2 + 0.0417 Log[10^(-6)] x^2 +         0.25` x^2 Log[1/c^(2/3)] + (1.` c^4 + 0.673 x) x Log[x] -         0.125` x^2 Log[x]^2 == 0, {x, 3, 100}, {c, 1, 5}, PlotRange -> All]      ![enter image description here](http://i.stack.imgur.com/UpAe0.gif) But if I change the range of `c` from `{1,5}` to `{1,50}` the figure is different: ![enter image description here](http://i.stack.imgur.com/fN7Kc.gif) Anyone knows the reason? Which figure is correct?


title: Avoid unnecessary truncation

text: Is there any way to change the general settings in Mathematica so that when I type e.g.               0.34*60000000      I get the output               20400000.      as opposed to the (for me not useful) representation               2.04*10^7      ? i.e. I want the raw number, not the formatted/adjusted form. And I do not want to use operators like SetPrecision. Ideally, I just want to change the settings so that whenever I type in a number I get the full answer. Is this possible? Perhaps using some command like SetOptions[$FrontEnd, ... ?


title: How can I build a GraphicsGrid of fixed size that rearranges the empty plots?

text: OK, let's make one final attempt; they say the third time is the lucky one! Following @rm-rf 's suggestions, I will try to be as clear as I can. My Mathematica code reads and plots simultaneously some data files. The output of the function `plo` below can be either a `Graphics` object (`ListPlot`) or a null string (`""`) if the data it reads doesn't exist. I want to arrange the 20 plots below in a grid of fixed dimensions ($ 4 \times 4 \times 4 \times 4 \times 2 \times 2$) like so:               P0 = Show[GraphicsGrid[{     {plo[1, 1], plo[2, 1], plo[4, 1], plo[7, 1]},     {plo[1, 2], plo[3, 1], plo[5, 1], plo[7, 2]},     {plo[1, 3], plo[3, 2], plo[6, 1], plo[8, 1]},     {plo[1, 4], plo[3, 3], plo[6, 2], plo[8, 2]},     {plo[1, 5], plo[3, 4]},     {plo[1, 6], plo[3, 5]}}]]      Since some data files may not exist, I would like the plots to rotate so that there are no blank spaces in between the plots but all the `Null` plots get moved to the end of the grid. For example, if `plo[2, 1]`, `plo[7, 2]` are missing I would like them to take up the last two slots in my grid while the rest of the plots preserve their ordering.


title: How to simplify Sqrt[1/x] Sqrt[x]?

text: In my expression, there appear terms of the form `A^(B Sqrt[1/C] Sqrt[C])`. _Mathematica_ doesn't realize that this is just simply `A^B`. I tried telling it explicitly by some replacement rule. This works for simple cases, but somehow if the form above is embedded in a larger expression it does not do this replacement rule. For example,               (9 + 9 E^((4 t Sqrt[Λ])/Sqrt[3]) -       12 y^2 Λ - 12 z^2 Λ +       6 y^2 Sqrt[1/Λ] Λ^(3/2) +       6 z^2 Sqrt[1/Λ] Λ^(3/2) +       x^4 Λ^2 + y^4 Λ^2 +       2 y^2 z^2 Λ^2 + z^4 Λ^2 +       2 x^2 Λ (-6 +          3 Sqrt[1/Λ]           Sqrt[Λ] + (y^2 + z^2) Λ) +       6 E^((2 t Sqrt[Λ])/Sqrt[       3]) (3 - 2 z^2 Λ +          x^2 (-2 +             Sqrt[1/Λ]              Sqrt[Λ]) Λ +          y^2 (-2 +             Sqrt[1/Λ]              Sqrt[Λ]) Λ +          z^2 Sqrt[1/Λ] Λ^(3/2)))/(9 +       9 E^((4 t Sqrt[Λ])/Sqrt[3]) -       12 y^2 Λ - 12 z^2 Λ +       6 y^2 Sqrt[1/Λ] Λ^(3/2) +       6 z^2 Sqrt[1/Λ] Λ^(3/2) +       x^4 Λ^2 + y^4 Λ^2 +       2 y^2 z^2 Λ^2 + z^4 Λ^2 +       2 x^2 Λ (-6 +          3 Sqrt[1/Λ]           Sqrt[Λ] + (y^2 + z^2) Λ) -       6 E^((2 t Sqrt[Λ])/Sqrt[       3]) (-3 + x^2 Sqrt[1/Λ] Λ^(3/2) +          y^2 Sqrt[1/Λ] Λ^(3/2) +          z^2 Sqrt[1/Λ] Λ^(3/2)))/. A_^(B_. Sqrt[1/Λ] Sqrt[Λ]) :> A^B      Could anyone help me?


title: How can I programmatically remove tagged cells without scrolling to them?

text: I've learned a rather succinct way to delete tagged cells using `NotebookLocate`, but I would prefer the notebook did not scroll to the selection just for a delete operation. How can I delete tagged cells without the notebook scrolling? Minimal example:               CellPrint[ExpressionCell[x^2, CellTags -> "oldcell"]];          Button["Remove old cell", {       NotebookLocate["oldcell"];       NotebookDelete[];     }]


title: Why does Mathematica not seem to know that $i^x$ cannot be equal to $0$?

text: I am experiencing a curious behaviour of `Simplify` when handling expressions involving powers of $\mathbf{i}$, such as $\mathbf{i}^x$ where $x$ is unknown. For example, when I take the equation `2^x a == 0`, and I ask Mathematica to simplify it for me by calling `Simplify[2^x a == 0]`, it rightly answers that the original equation is equivalent to `a==0`; hence clearly Mathematica's `Simplify` "knows" that taking a power of something non-zero cannot produce a zero. However, if I ask about `I^x a == 0`, then the result of `Simplify` is merely `I^x a == 0`, i.e. what I started with. This remains true after adding the assumption that $x$ is an integer or changing `Simplify` to `FullSimplify` (i.e. `FullSimplify[I^( x) a == 0, Assumptions -> {Element[x, Integers]}]`. It would be much more convenient if This is obviously not a serious problem, but it can be a nuisance when I need to simplify a number of equations and would like to quickly see the result in a relatively uncluttered form. Also, I am curious about why things work the way they do, i.e. why complex powers are treated so much differently than real powers. Thank you for any solution to the problem, and/or explanation of this phenomenon. (A solution would be a way to "teach" Mathematica to eliminate factors like `I^( x)` in equations like `I^( x)*(something)==0`).


title: Given a list of lists, build a list in which lists with equal first and last elements are grouped together

text: I have a list of lists, and I'd like to build a new list, in which lists are in the same list if they have the same first and last element. Here's an example. Suppose I have               {{1, 2, 4}, {1, 3, 4}, {1, 2, 4, 5}, {1, 3, 4, 5}, {2, 4, 5}, {3, 4, 5}}      After some magic has happened, I would like to have               { {{1, 2, 4}, {1, 3, 4}}, {{1, 2, 4, 5}, {1, 3, 4, 5}}, {{2, 4, 5}}, {{3, 4, 5}} }      I was looking at `Select` and the others, but I can only come with ugly explicit loops that achieve this. I'm sure there's a nicer way of doing this. What could that be?


title: How do I calculate the probability of reaching mean residual life

text: I need to understand the Survival Analysis concept of "mean residual life (MRL)" and calculating probabilities for reaching it. From another discussion: > The MRL at time t is the mean additional time after time t that you expect > an entity to survive, given that it has survived until time t. It does not > include the time from time 0 to time t that the entity has already lived > through, so it is possible for it to be less than the mean lifetime if t>0. > It must equal the mean lifetime if t=0. I've worked up a Manipulate model to illustrate some of this:                MRL[variable_, distribution_] :=        NExpectation[X \[Conditioned] X > variable,          X \[Distributed] distribution] - variable;          mrlPlot = Plot[        MRL[x, LogNormalDistribution[1.75, 0.65]], {x, 0, 40},        ImageSize -> 400,        PlotRange -> All,        AxesLabel -> {"Time", None}, ImagePadding -> {{20, 40}, {10, 0}}];          Manipulate[       Module[{mrl, dist, mean, cdf, cdfMean, cdfMRL, pdf, pdfMRL,         pdfMean},       dist = LogNormalDistribution[1.75, 0.65];       mrl = MRL[t , dist] + t;       mean = Mean[dist];       cdf = N[CDF[dist, t], 3];       cdfMRL = N[CDF[dist, mrl], 3];       cdfMean = N[CDF[dist, mean], 3];       pdf = N[PDF[dist, t ], 3];       pdfMRL = N[PDF[dist, mrl], 3];       pdfMean = N[PDF[dist, mean], 3];            Column[{         "PDF",         Show[          {           Plot[PDF[dist, x], {x, 0, 40},            ImageSize -> 400,            PlotRange -> All,            AxesLabel -> {"Time", None},             ImagePadding -> {{20, 40}, {10, 0}},            Prolog -> {Text["Expectation", {mean + 3.5, .01}],               Text["t", {t + 1, pdf - .003}],               Text["MRL+t", {mrl + 3, pdfMRL - .003}]}],           Plot[PDF[dist, x], {x, t, mean}, PlotRange -> All,             AxesOrigin -> {Automatic, 0}, Filling -> Axis],           ListPlot[{{t, pdf}, {mean, pdfMRL}}, PlotRange -> All,             PlotStyle -> PointSize[0.015]],           ListPlot[{{mrl, pdfMRL}}, PlotRange -> All,             PlotStyle -> {Red, PointSize[0.015]}]           },          GridLines -> {{{t, {Dashed}}, {mean, {Dashed,                LightGray}}, {mrl, {Dashed, Red}}}, {{pdfMean, LightGray},              pdf, pdfMRL}}],         "", "CDF",         Show[{           Plot[CDF[dist, x], {x, 0, 40},            ImageSize -> 400,            PlotRange -> All,            AxesLabel -> {"Times", None},             ImagePadding -> {{20, 40}, {10, 0}},            Prolog -> {Text["Expectation", {mean + 3.5, .075}],               Text["t", {t + 1, cdf - .03}],               Text["MRL+t", {mrl + 3, cdfMRL - .03}]}],           ListPlot[{{t, cdf}, {mean, cdfMean}}, PlotRange -> All,             PlotStyle -> PointSize[0.015]],           ListPlot[{{mrl, cdfMRL}}, PlotRange -> All,             PlotStyle -> {Red, PointSize[0.015]}]},          GridLines -> {{{t, {Dashed}}, {mean, {Dashed,                LightGray}}, {mrl, {Dashed, Red}}}, {{cdfMean, LightGray},              cdf, cdfMRL}}],         "", "MEAN RESIDUAL LIFE",         mrlPlot         }]],      {{t, 0, "t"}, 0, 40, .01, Appearance -> "Labeled"},      TrackedSymbols :> {t},      FrameLabel -> {None, None,         "SURVIVAL ANALYSIS & MEAN RESIDUAL LIFE"},      LabelStyle -> Medium]      Snapshot of the Manipulate follows: ![snapshot](http://i.stack.imgur.com/BZacr.png) The last of the plots in the Manipulate[] shows a static plot of mean residual life. You can see how at time, t = 0 its value is just over 7 which equals the mean lifetime (expectation). It shows how MRL drops then rises as t varies from 0 to 40. The PDF and CDF plots show something else, t + MRL, or how much the person has lived until now (t) plus the mean of the lifetime remaining to it. Given the timeframe shown (0 to 40) t + MRL will vary its distance as t increases, but will always remain beyond t. I think this makes sense, given that someone or something has survived to some point, t, and has no absolute limit of life, they have some additional time to live. 1st question: Does this make sense so far? Just working my way through these ideas, so I may not have them all right just yet. 2nd question: _I now need to calculate the probability of someone reaching t + MRL given that they have already reached t_. This seems like it should be straight forward, but I don't have a good intuition for the answer. I've thought I could do one of these:               MRL[variable_, distribution_] := NExpectation[X \[Conditioned] X > variable, X \[Distributed] distribution] - variable;     t = 5;     expectedLife = MRL[t, LogNormalDistribution[1.75, 0.65]] + t          p1 = NProbability[x >= t && x <= expectedLife, x \[Distributed] LogNormalDistribution[1.75, 0.65]]     p2 = NProbability[x <= expectedLife, x \[Distributed] LogNormalDistribution[1.75, 0.65]]      Does either p1 or p2 makes sense? Have I missed something fundamental here? How should I go about this? Any help and explanation much appreciated.


title: How can I plot a polynomial at a specified set of x values?

text: I want to plot the following polynomial:               6.09125E15 - 1.12464E16*x^1 + 1.35607E16*x^2 + -1.73465E16*x^3 + 2.6004E16*x^4 -        2.65074E16*x^5 + 1.55669E16*x^6 + -5.1382E15 *x^7 + 8.90337E14*x^8 - 6.31447E13*x^9      for the following set of x values > 0.10674, 0.11393 , 0.1216, 0.1298, 0.13854, 0.14788, 0.15784, 0.16847, > 0.17982, 0.19194, 0.20487, 0.21867, 0.23341, 0.24913, 0.26591, 0.28383, > 0.30295, 0.32336, 0.34515, 0.3684, 0.39322, 0.41972, 0.44799, 0.47818, > 0.51039, 0.54478, 0.58148, 0.62066, 0.66247, 0.70711, 0.75475, 0.8056, > 0.85987, 0.9178, 0.97964, 1.04564, 1.11609, 1.19128, 1.27154, 1.35721, > 1.44865, 1.54625, 1.65042, 1.76162, 1.8803, 2.00698, 2.1422, 2.28653, > 2.44058, 2.605, 2.78051, 2.96784, 3.16779, 3.38122, 3.60902, 3.85217, > 4.1117, 4.38872, 4.6844 I also want to get the corresponding y values. How can this be done? Please suggest a method.


title: Mathematica policy for correctness of results

text: Does Mathematica provide any kind of warranty that their calculations are correct? Say I'm running a billion dollar company, and I relied on Mathematica to do calculations, like aerodynamics or car accidents simulations, etc. After releasing my product, I found that Mathematica is buggy and provided me with wrong results, and I lost a few Millions because of that. What kind of warranty will Wolfram provide?


title: How to combine multiple Graphics3D scenes into a single Graphics3D scene?

text: `ProteinData["A2M", "MoleculePlot"]` gives you a `Graphics3D` object below. I'd like to display multiple of these proteins in **a single** Graphics3D scene. Is there a way to place the `Graphics3D` object returned by `ProteinData[...]` at a specific location and orientation in another 3D scene? Alternatively, is there a `ProteinData` API that (I'm somehow missing and) would give me an object that I could place (rotated and translated) in a new `Graphics3D` scene? ![](http://i.stack.imgur.com/xKOMX.png)


title: I am not able to plot legends in list density plot using c program. Getting blank legend

text: I have tried to load the "PlotLegends'" package. Here is my code,               MLPutFunction(lp,"EvaluatePacket", 1L);          MLPutFunction(lp, "Get", 1);     MLPutString(lp, "PlotLegends`");     while((pkt = MLNextPacket(lp),pkt) && pkt != RETURNPKT)     {         MLNewPacket(lp);              if(MLError(lp))             error(lp);          }     MLNewPacket(lp);             MLPutFunction(lp, "ToString", 1);     MLPutFunction(lp, "ToExpression", 1);          inputStr = "ListDensityPlot[Transpose[{{1, 2, 3, 5, 6}, {1, 2, 3, 5, 6}}],DataRange -> {{0, 500}, {900, 5100}}, ColorFunction -> \"Rainbow\",PlotLegends -> Automatic]";               func_str="Export[\"D:/test_colour_plot.gif\","+ inputStr + "]";          const_func = func_str.c_str();     MLPutString(lp,const_func);     MLEndPacket(lp);          while((pkt = MLNextPacket(lp),pkt) && pkt != RETURNPKT)     {         MLNewPacket(lp);              if(MLError(lp))             error(lp);          }      ![](http://i.stack.imgur.com/vPBv8.gif)


title: Plotting a family of contour plots

text: How can I plot the following equation with $k$ assumed to be an integer"? I tried something like this, but it doesn't work:               ContourPlot[{Element[k,Integers], Sqrt[x^2 + y^2] == 4 + k*Pi},{x, -17, 17}, {y, -17, 17}]


title: How can I reproduce some surface plots in Mathematica?

text: ![enter image description here](http://i.stack.imgur.com/clTjo.jpg) I am not really familiar with _Mathematica_. I wonder if some one can help me draw any of the following surfaces. I will be appreciative if you tell me how to use equations and `PlotRange` to draw those.


title: Behavior of Graphics`Mesh`InPolygonQ with self-intersecting polygons

text: Playing around with some of the answers in the question How to check if a 2D point is in a polygon? I noticed that:               Graphics`Mesh`InPolygonQ[poly,pt]      Displays different behavior than the procedure that explicitly uses winding numbers (where a non-zero winding number implies polygon inclusion), for example the function in rm -rf♦'s answer to the aforementioned question:               inPolyQ[poly_, pt_] := Graphics`Mesh`PointWindingNumber[poly, pt] =!= 0      We can see this in the case where we define a self-intersecting polygon that has a "hole" in it:               PointWindingNumberInPolygonQ[poly_, pt_] := Graphics`Mesh`PointWindingNumber[poly, pt] =!= 0;          numRandPoints = 10^4;          testPolygon = {{65.4`, 439.5`}, {233.4`, 524.5`}, {364.40000000000003`, 433.5`}, {382.40000000000003`, 377.5`}, {354.40000000000003`, 293.5`}, {258.40000000000003`, 239.5`}, {94.4`, 207.5`}, {40.400000000000006`, 271.5`}, {18.400000000000002`, 356.5`}, {149.4`, 383.5`}, {187.4`, 330.5`}, {199.4`, 258.5`}, {136.4`, 130.5`}};          boundingBoxCoordinates = {{Min[testPolygon[[All, 1]]], Min[testPolygon[[All, 2]]]}, {Min[testPolygon[[All, 1]]], Max[testPolygon[[All, 2]]]}, {Max[testPolygon[[All, 1]]], Max[testPolygon[[All, 2]]]}, {Max[testPolygon[[All, 1]]], Min[testPolygon[[All, 2]]]}};          randomPoints = Table[{RandomReal[{Min[boundingBoxCoordinates[[All, 1]]], Max[boundingBoxCoordinates[[All, 1]]]}], RandomReal[{Min[boundingBoxCoordinates[[All, 2]]], Max[boundingBoxCoordinates[[All, 2]]]}]}, {k, 1, numRandPoints}];               windingNumPointsInPolygon = {};     inPolygonQPointsInPolygon = {};          For[i = 1, i <= Length[randomPoints], i++,            If[PointWindingNumberInPolygonQ[testPolygon, randomPoints[[i]]] == True,         windingNumPointsInPolygon = Append[windingNumPointsInPolygon, randomPoints[[i]]];       ];           If[Graphics`Mesh`InPolygonQ[testPolygon, randomPoints[[i]]] == True,         inPolygonQPointsInPolygon = Append[inPolygonQPointsInPolygon, randomPoints[[i]]];      ];          ];               Graphics[Polygon[testPolygon]]     ListPlot[windingNumPointsInPolygon]     ListPlot[inPolygonQPointsInPolygon]      Notice how -               inPolyQ[poly_, pt_] := Graphics`Mesh`PointWindingNumber[poly, pt] =!= 0      Counts points inside the polygon "hole" as being inside the hole, while -               Graphics`Mesh`InPolygonQ[poly,pt]      Counts points inside the polygon "hole" as being outside the polygon, consistent with the shading for -               Graphics[Polygon[testPolygon]]      How can we characterize the behavior/algorithm of InPolygonQ? While I can understand how the winding number test method works, the trouble is that inPolygonQ is an undocumented function that doesn't give me any hints as to what it is doing.


How to find the solution of differential equation with complex roots For example of   [{y^2 n[t]+ 2 k y n'[t] + n''[t]= M p sin(o t), n[0]==0, n'[0]==0}, n,t]   given k lies between 0 to 1 which makes the roots complex.


title: Color Histogram3D by Bin Location

text: I am using a `Histogram3D` plot to view the correlation of the R & G of an RGB image. Naturally, I want the bins to have a color corresponding to their $x$, $y$ (R,G) position on the chart. Unfortunately, `ColorFunction` for `Histogram3D` only supplies one argument, height, not $x$ or $y$ position. Is there a way to color each bin based on its $x$ and $y$ position within the histogram? (i.e. `RGBColor[x,y,0]`) Here is how I am generating my (uncolored) histogram:                   Histogram3D[Transpose[{                                Flatten[ImageData[jpeg][[All,All,1]]]                               ,Flatten[ImageData[jpeg][[All,All,2]]]                                }]]


title: Report: IgnoringInactive: a bug?

text: Just to report. `IgnoringInactive`should work with `Cases`. In agreement with the things written at the Documentation Center this:                Cases[{Cos[a], Inactive[Cos][b]}, IgnoringInactive[Cos[x_]]]      works correctly yielding               (*   {Cos[a], Inactive[Cos][b]}   *)      exactly as expected. However, this               Cases[{Cos[a], Inactive[Cos][b], Tan[c]}, IgnoringInactive[Cos[x_]]]      works (as I think) incorrectly returning               (*  {Cos[a], Inactive[Cos][b], Tan[c]}  *)      while I would expect again `{Cos[a], Inactive[Cos][b]}`.


title: Help with programming(using list)

text: I would like to make a program which gives me what is the greater natural number "n" less than an arbitrary given natural number "k" which satisfy: for each prime divisor "p" of n, p^2-1 divides n. I have solved the problem theoretically and now I need to implement the algorithm. In order to do that I need to calculate the prime factorization of a number "q", for each prime factor p of q calculate p^2-1 and check if p^2-1 divides n. If the conditions holds, then I want to print the number q and exit the program. Else, continue with the program and do the same for q-1. I have read the documentation and I can calculate the prime factorization of q but then I don't know how to get the elements of the list that I need. I explain it with an example:               FactorInteger[2434500]          {{2, 2}, {3, 2}, {5, 3}, {541, 1}}      And now I don't know how to get 2, 3, 5, 541 Thanks and excuse me for my poor English I hope you understand what I am asking for.


title: DSolve expression not evaluating

text: I entered the following into _Mathematica_ :               p[x_] := 4 x     q[x_] := 4 Sqrt[x] - 3     f[x_] := E^-Sqrt[x]     DSolve[y''[x] + p[x] y'[x] + q[x] y[x] == f[x], y[x], x]      > >      DSolve[ >         (-3 + 4 Sqrt[x]) y[x] + 4 x Derivative[1][y][x] + >           (y^\[Prime]\[Prime])[x] == E^-Sqrt[x], >         y[x], x] >   Why is Mathematica refusing to evaluate my DSolve expression?


title: Possible to apply a function without brackets?

text: I was just playing around with entering two dimensional forms of some expressions. As an example, I wanted to write `Integral[Cot[t],t]`. I got as far as `\[Integral]Cot[t] \[DifferentialD]t`. But I would love to make it look even more natural by omitting the brackets around the `t`. Is there any `\[]` character that helps me do that?


title: Efficiently searching a list for the position of the closest number to a specified number

text: Searching by closest and position I wasn't able to find an answer--but found `Nearest` by guessing. `Nearest`, however, returns the closest number itself, not the position. After some more looking around, I learned about `MapIndexed` and `Rules`, and came up with this:               NearestPosition[haystack_, needle_] := Nearest[haystack, needle] /. MapIndexed[Rule, haystack];      Is there a more efficient way, in general? (And what if it's guaranteed the list comes sorted--can that be leveraged?) The reason I'm concerned about efficiency is that I intend to use `NearestPosition` in a `DynamicModule` where it may be triggered by every `mouseover` event. (I'm still trying to solve this problem.)


title: how to solve an optimization problem in terms of matrices as the argument

text: How can I minimize an expression of the form `a^T A a` where `a` is a matrix. The following approach does not work if `a` is a matrix and `a^T` is a transposition of `a`.               Minimize[ a^T Aa, {a^T a = 1}, a]      It works only for simple variables.


title: How to effectively compare two sentences and say both are equal

text: want to compare two text file. Suppose file AA contains following text                  1.The onunload event occurs once a        2.page has unloaded (or the browser window has been closed).        3.onunload occurs when the user        4.navigates away from the page (by clicking on a link, submitting        5.text One        6.text two        7.text three      And file BB contains following text                  1.The onunload event occurs once a        2.page has unloadd (or the browser window has been closed).        3.onunload the when  occurs user        4.navigates away from the page (by clicking on a link, submitting        5.text two        6.text One        7.text three      What I want is               -Line 1 in AA and 1 in BB is exact match         -Line 2 in AA and 2 in BB is match but contains error (see word "unloadd" in BB content)        -Line 3 in AA and 3 in BB is match but words are swaped in BB content         -Line 4 in AA and 4 in BB is exact match         -Line 5 in AA is swapped to Line 6 in BB .         -Line 6 in AA is swapped to Line 5 in BB.        -Line 7 is exact match with line 7 in BB.      How to achieve this ? Is there any pattern matching algorithm?


title: Recovering intermediate results from a Table after an interruption

text: I am interested in knowing if it is possible to recover intermediate results from a `Table` after an interruption. Let us say I want to produce a really useful table               tt = Table[Pause[0.1*i]; i, {i, 50}]      and since _Mathematica_ takes too long to evaluate it, I get impatient. Is it possible to interrupt the calculation and recover what it has already calculated? I am guessing the answer is no, but would like to be proven wrong.


title: Converting to machine precision

text: There are multiple ways to convert an expression to machine precision, for example:               In[1]:= a = Sqrt[2]     Out[1]= Sqrt[2]          In[2]:= {1.a, 1`a, N@a, SetPrecision[a,MachinePrecision]}     Out[2]= {1.41421,1.41421,1.41421,1.41421}          In[3]:= Precision /@ %     Out[3]= {MachinePrecision,MachinePrecision,MachinePrecision,MachinePrecision}      My question is whether or not these methods are absolutely equivalent. Is it just a matter of personal taste which one to use, or are there examples where they behave differently?


title: Understanding NDSolve::ndsz

text: I'm working on a largeish system of differential equations where I encounter the `NDSolve::ndsz step size is effectively zero; singularity or stiff system suspected` error. Since this error arises from the complexity of the system I'm not able to distill a minimum example, but there might still be some useful general information we can share. In particular I'd like to know:   * What's the difference between stiffness and a singularity? How can I tell whether my sysetm is singular or stiff?   * What quantity is Mathematica calculating to decide if the system is stiff/singular? Can I calculate this quantity myself to see what property of my system is causing problems?


title: How to create a multi-selectable setterbar with colored buttons

text: Background: consider the following code-snippet.                 Dynamic@Grid[         Table[Setter[Dynamic[idx, (idx = #1) &],           i*6 + j,          Graphics[{Blue, Disk[]}, ImageSize -> 20]],          {i, 0, 1}, {j, 6}]]      This code creates two rows of clickable disk images. So if idx=10 is run, the 10th disk looks pressed. I want to make this control multi-selectable. So if idx={1,12} run, the first and last disks look pressed. ( In my application the disks may have different colors, edge properties and opacity. ) - See also: What is an efficient way of selecting multiple colors via Manipulate? **Question: How to create "a multi-selectable setterbar with colored buttons" ?** ( preferably based on the snippet above, but not necessarily ).


title: How to create locked sliders with the ability of unlocking them?

text: This creates two locked sliders               DynamicModule[{p = {2 π, 0}, r},      {Slider2D[Dynamic[r]], Slider2D[Dynamic[1 - r, (r = 1 - #) &]]}]      ![enter image description here](http://i.stack.imgur.com/2P9Id.png) How can I add a check box so that I can control whether to lock them or not? If the check box is check, the second slider sync to the first one and then they are locked as above, and if the check box is unchecked, they they can move independently. I tried something like this               DynamicModule[{p = {2 π, 0}, checked = True, r,r2 },      {Slider2D[Dynamic[r]], Slider2D[Dynamic[If[checked, 1 - r, r2]]],        Checkbox[Dynamic[checked]]}]      or this               DynamicModule[{p = {2 π, 0}, r, r2, checked = True},      {Slider2D[Dynamic[r]],        Refresh@If[checked, Slider2D[Dynamic[1 - r, (r = 1 - #) &]],          Slider2D[Dynamic[r2]]], Checkbox[Dynamic[checked]]}]      but neither of them worked.


title: Ignore $MinPrecision when using Print

text: I have a function that contains a `For` loop and sometimes takes several hours to run. It's important that I keep a high precision, and I insert `Print` statements throughout to check the status. Here is a simplified example:               f[x_] := Block[{$MinPrecision = 500},         For[i = 0, i < x, i++;             y = i/2;             Print[N[y, 10]]         ];     ];      Is there a way to ignore or suppress `$MinPrecision` when `Print` is used? I'd like to make the printed output easier to read.


title: How to make a Dynamic Calculator to solve a quadratic equation?

text: Taking my first steps in the world of Mathematica Programming. The aim of my program was to modify Wolfram's dynamic calculator   (which performs an addition subtraction and a product - in response to the user inputting two values used to perform these operations)   to now take three input and display on the three outputs: [1] the quadratic equation to be solved   [2] the roots of this quadratic equation   [3] the discriminant of this equation The three things (in red text) which you have to input are: first input box is coefficient a   second input box is coefficient b   third input box is coefficient c These coefficients represent a,b and c in the quadratic equation $ax^2 + bx +c$ So the Wolfram Demonstration & My attempt (the code below) look like this: http://www.controlmanchester.com/2013/08/01/quadratic-equation-images/ The code for the original program is available here: http://reference.wolfram.com/mathematica/example/ConstructADynamicCalculator.html This is the code that I have written (modified really):                DynamicModule[            {a = 0, b = 0, c = 0},            Deploy[             Style[              Panel[               Grid[                Transpose[             {             {             Style["input a ", Red],             Style["input b", Red],             Style["input c", Red],         "here is the equation",         "here is the value of the discriminant",         "here are the roots"},               {InputField[Dynamic[a], Number],          InputField[Dynamic[b], Number],          InputField[Dynamic[c], Number],          InputField[Dynamic[a*x^2 + b*x + c],Enabled -> False],          InputField[Dynamic[b]^2 - (4*Dynamic[a]*Dynamic[c]) , Enabled -> False],          InputField[Dynamic[a b], Enabled -> False]}                 }                     ]         , Alignment -> Right]         , ImageMargins -> 10]            ,          DefaultOptions -> {InputField -> {ContinuousAction -> True,          FieldSize -> {{5, 30}, {1, Infinity}}}}]         ]         ]      I have discovered, via trial and error, that within an input field I cannot simply try something like   `Solve[x^2 + a x + 1 == 0, x]` or `Roots[ ]`. I think this is where the heart of my problem lies. At the moment the variables I put in do propagate down and show the coefficients of the quadratic, but I cannot get any further with it. Any help, or guidance to things I should read are most welcome. Many Thanks, David p.s. I have seen from the answer by Mike Honeychurch that I have not described the problem as clearly as possible. I have edited the post :) I hope this makes my problem easier to understand


title: Image Processing: Edge detection of the tumor on tomogram. Сalculation area of the tumor

text: The task is to identify the image region of the tumor. ![tomography of kidneys with tumor \(white area on the left kidney\)](http://i.stack.imgur.com/mZ4fR.jpg) I try to use example from documentation centre:               tom1 = Import["http://i.stack.imgur.com/mZ4fR.jpg"];     tumor = SelectComponents[               DeleteBorderComponents[ Binarize[ tom1, {0.75, 1}]],                {"Area", "Holes"}, 2800 < #1 < 2900 && #2 > 0 &];     circle = ComponentMeasurements[                 ImageMultiply[ tom1, tumor],                 {"Centroid", "EquivalentDiskRadius"}][[All, 2]];     Show[ tom1, Graphics[{Red, Thick, Circle @@ # & /@ circle}]]      but get unsatisfactory result: ![tumor detection](http://i.stack.imgur.com/NoUAu.png) i try to identify tumor like this but selection was noisy:               SelectComponents[       DeleteBorderComponents[ Binarize[ tom1, {0.75, 1}]],        {"Area", "Holes"}, 2800 < #1 < 2900 && #2 > 0 &]      ![tumor](http://i.stack.imgur.com/6YIGK.png) So, can you help me to make clearer allocation of the tumor and then calculate the area of selection?


title: How to annotate a Grid?

text: I have the following grid, which is a partial table for the linear function f[x]:               f[x_] := 2 x + 3     Grid[Join[{{x, y}}, Table[{i, f[i]}, {i, 0, 4}]],       Dividers -> {{2 -> Directive[Red, Thin]}, {2 ->       Directive[Red, Thin]}}, Alignment -> {Right, Center}]      What I'd like to do is annotate this grid, to indicate the slope and y-intercept of f[x], as the following graphic shows: ![enter image description here](http://i.stack.imgur.com/mLB4s.png) I can figure out how to draw the dashed ellipse and colored arrows on my own. What I can't figure out is how to add these graphical annotations to the grid. Is this possible? (Note that f[x] will be defined "on the fly", and so including a static image is not a possible solution.)


title: Even Fibonacci numbers

text: Today, I found the Euler Project. Problem #2 is > Each new term in the Fibonacci sequence is generated by adding the previous > two terms. By starting with 1 and 2, the first 10 terms will be: >   >   >      1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... >   > > By considering the terms in the Fibonacci sequence whose values do not > exceed four million, find the sum of the even-valued terms. I have two solutions:               For[i = 1, i < 100, i++, If[Fibonacci[i] > 4000000, Break[]]];     Plus @@ Select[Fibonacci /@ Range[i - 1], Mod[#, 2] == 0 &]      > 4613732               Plus @@ Select[     Fibonacci /@ Select[Range@100, Fibonacci@# < 4000000 &],      Mod[#1, 2] == 0 &]      > 4613732 However, I feel my solutions are not good and efficient. So my question is: can you show me more concise and efficient methods? Also, how cam I test whether a number is a Fibonacci number？


title: Failing to get a coloured coordinate in 4D plot

text: I am trying to get a colour data plotted according to a coordinate. I am working with 4D vectors, with three spatial and one temporal coordinate. I tried the accepted answer at Plot 4D data with color as 4th dimension, but didn't get it to work. My data is stored as an array, whose spatial components depend on time only. As asked, the data basically looks like this:               Vector[t_]:={Vx[par1, par2, t], Vy[par1, par2, t], Vz[par1, par2, t], t}      where Vx, Vy and Vz are functions of par1, par2 and t. par1 and par 2 are time-independent parameters (that I vary from plot to plot), and they already have fixed values. The parameter t corresponds to time and has not yet been evaluated.   Next, I create an array               data = Array[Vector, 1000]      where the 1000 points are taken at t=0, t=1, t=2... , t=1000. The values of the spatial coordinates remain close to 1. When I plot the array from t=0 to t=1000 with               Graphics3D[ Point[data[[All, 1 ;; 3]], VertexColors -> Hue /@ data[[All, 4]]], Axes -> True, BoxRatios -> {1, 1, 1}]      it just makes all of the data points red. When I try to rescale exactly as suggested               Graphics3D[ Point[data[[All, 1 ;; 3]], VertexColors -> Hue[Rescale[#,{0,100}]] /@ data[[All, 4]]], Axes -> True, BoxRatios -> {1, 1, 1/GoldenRatio}]      all of the datapoints are now plotted as black. I looked through other solutions as well, and tried to guess the rescaling from them, but I didn't get it to work. I don't undestand the notation around "Hue" very well, so I suppose my tries were clumsy. For example, I also tried using arrays formed from 3D vectors, and defining own function for time, and trying to rescale like [taken from another example]               (Hue /@ Rescale[f[##] & @@@ data])         where I tried to define simply               f[t_]=t;      but it didn't work, unfortunately. What is wrong with my syntax? What does work?


title: Series expansion for $\frac{x}{1- \frac{1}{x}}$

text: I would like to expand $\frac{x}{1- \frac{1}{x}}$ as $$\frac{x}{1- \frac{1}{x}} = x \left( 1+ \frac{1}{x} + \frac{1}{x^2} +\frac{1}{x^3} + \cdots \right) = x + 1 + \frac{1}{x} + \frac{1}{x^2} + \cdots $$ However, I tried               Series[1/(1 - 1/x), {1/x, 0, 2}]      it doesn't work or               1/(1 - 1/x) /. 1/x -> t          Series[%, {t, 0, 3}]          % /. t -> 1/x          Expand[x*%]      it ends up to $x \left( 1+ \frac{1}{x} + \frac{1}{x^2} +\frac{1}{x^3} + \cdots \right) $ cannot be expanded to break the bracket. How should I do to arrive at $x + 1 + \frac{1}{x} + \frac{1}{x^2} + \cdots $?


title: How to dynamically change the Appearance of a control in Manipulate?

text: How can I dynamically change the appearance of b? Strangely it works for the Enabled state but not for the Appearance. Thanks.               Manipulate[       bAppearance = If[a > 1, "Open", "Closed"];        bEnabled = If[a > 2, False, True];       Plot[Sin[a x + b],        {x, 0, 6}], {a, 1, 4}, {b, 0, 10, Appearance -> Dynamic@bAppearance}]


title: Manipulate freezing on large calculations

text: I have a sum that ordinarily takes some time (2 - 3 seconds) to calculate. When I put it into a manipulation though, it becomes very temperamental. It will work on some very small calculations, but completely refuses to output anything for larger values. Is this a characteristic of `Manipulate`, or is there some way to work around it? I looked here, but can't get it to work on `Manipulate`.


title: Understanding performance: graph connected components

text: I need to analyze directed graphs with 10M edges, 1M vertices, and 300K strongly connected components, so that the largest one contains 400K vertices. I read some explanations of Leonid Shifrin here, here and here. Although I don't quite understand why his code `merge` is so blazingly fast, I learned two things: no recursions only iterations, linked lists are cool. Trying to mimic his approach, I prepared two function for finding strongly connected components. The first one is Kosaraju's algorithm:                ClearAll[readEdge, SowDFS, DFS, kosaraju]           readEdge[{a_, b_}] := (adjOut[a] = q[b, adjOut[a]]; adjIn[b] = q[a, adjIn[b]]);           (* Sow as a postvisit vertex function *)      SowDFS[q[v_?newQ, rest_]] := SowDFS[newQ[v] = False; adjIn[v] /. q[] -> q[Sow[v], rest]];      SowDFS[q[v_, rest_]] := SowDFS[rest];           (* deep first scan *)      DFS[q[v_?newQ, rest_]] := DFS[Sow[v, tag]; newQ[v] = False; adjOut[v] /. q[] -> rest];      DFS[q[v_, rest_]] := DFS[rest];           (* finding connected components *)      kosaraju[graphList_] := Block[{adjOut, adjIn, order, newQ, q, tag = 1, $IterationLimit = Infinity},      (* construction of adjacency lists *)      adjOut[v_] = q[]; adjIn[v_] = q[]; Scan[readEdge, graphList];      SetAttributes[q, HoldAllComplete];      (* the first scan: topological sort of the reverse graph *)      newQ[v_] = True;      order = Reverse[Reap[Scan[SowDFS[q[#, q[]]] &, DeleteDuplicates@Flatten[graphList]]][[2, 1]]];      (* the second scan: finding components *)      Clear[adjIn, newQ]; newQ[v_] = True;      Last@Reap[Scan[(tag++; DFS[q[#, q[]]]) &, order], _, #2 &]      ]      The second one is based on Tarjan's algorithm, as it is described in Wikipedia. I only adapted it in non-recursive way:                (* reading edge *)      readOut[{a_, b_}] := (adj[a] = q[b, adj[a]]);           (* test to start component *)      strongQ[v_] := index[v] == link[v];           (* pop from stack *)      pop[v_, q[v_, rest_]] := (inQ[Sow[v, v]] = False; rest);      pop[v_, q[a_, rest_]] := pop[v, inQ[Sow[a, v]] = False; rest];           (* deep first scan with two stacks *)      biDFS[q[v_?newQ, rest_], stack_] := biDFS[         (* previsit function *)         newQ[v] = False; index[v] = link[v] = ++idx; {p[v], root} = {root, v};         adj[v] /. q[] -> q[h[v], rest], inQ[v] = True; q[v, stack]];           biDFS[q[h[v_?strongQ], rest_], stack_] := biDFS[rest, pop[v, stack]];      biDFS[q[v_?inQ, rest_], stack_] := biDFS[link[root] = Min[link[root], index[v]]; rest, stack];      biDFS[q[v_, rest_], stack_] := biDFS[rest, stack]           (* postvisit vertex function *)      h[a_] := (root = p[a]; link[root] = Min[link[root], link[a]]; a);           (* start scan *)      start[v_?newQ] := Block[{p, root = v, inQ, link, index, idx = 0},      (* p is for parent *)p[a_] := a; inQ[a_] = False;      biDFS[q[v, q[]], q[]]]          (* finding connected components *)     tarjan[graphList_] := Block[{adj, newQ, q, $IterationLimit = Infinity},     (* construction of adjacency out-lists *)     adj[v_] = q[]; Scan[readOut, graphList]; SetAttributes[q, HoldAllComplete];     (* finding components *)     newQ[v_] = True;     Last@Reap[Scan[start, DeleteDuplicates@Flatten[graphList]], _, #2 &]     ]      I try not to use WM build in functions for graph analysis in order to have a clear comparison. To test the performance I chose Google+ graphs from Stanford Large Network Dataset Collection. The renamed version of one of them is available here.               SetDirectory[NotebookDirectory[]];     graphList = Import["edges.dat"];      This graph contains 5126172 edges but only 16405 vertices. The structure of SCC is not completely trivial: a single connected component with 11064 vertices, another one — 11 vertices, one more — 5 vertices, three ones — 3 vertices each, ten components with 2 vertices, and 5296 vertices which are not strongly connected. On the one hand, WM somehow requires a lot of time to form the graph:               result2 = ConnectedComponents[     Graph[DirectedEdge @@@ graphList]]; // AbsoluteTiming     (* {139.523577, Null} *)      and only half of a second to find the strongly connected components. On the other hand, reading the graph takes 29 seconds in my function `tarjan`, and 12 seconds to find the components, thus 42 second in total:               result1 = tarjan[graphList]; // AbsoluteTiming     (* {42.207118, Null} *)      Hence, my question is it possible to speed up the `tarjan` function so that it will be at least 10 times slower than the built-in function `ConnectedComponents`? My nb-file is available here.


title: Putting ticks with values on a parametric plot

text: I need to plot ticks with values on the following `ParametricPlot[]` ![Parametric Plot of A2\(gamma\) and A4\(gamma\)](http://i.stack.imgur.com/CZq2W.png) The ellipse can be obtained by               F[k_, x_, y_, z_, w_] = (-1)^(z + w - 1) ((2 x + 1) (2 y + 1) (2 w + 1) (2 k      + 1))^(0.5) ThreeJSymbol[{x, 1}, {y, -1}, {k, 0}] SixJSymbol[{x, y, k}, {w, w, z}];          A[k_, x_, y_, z_, w_, d_] = (F[k, x, x, z, w] + 2*d*F[k, x, y, z, w] +      d*d*F[k, y, y, z, w])/(1 + d*d);               ParametricPlot[{A[2, 1, 2, 2, 2, d]*F[2, 2, 2, 0, 2],      A[4, 1, 2, 2, 2, d]*F[4, 2, 2, 0, 2]}, {d, -2000,      2000}, (*Frame->True,*) FrameLabel -> {"A_{22}", "A_{44}"},       PlotRange -> {{-0.5, 0.5}, {-0.5, 0.5}}, PlotPoints -> 1000]      I tried it with Meshpoints, even though I need thicks with the values, and could not even figure this out. As the uploaded pictures says: The curve is labelled with values of the parameter `delta' = delta/(1+|delta|)`. In my case `delta` is `d`.


title: Pick elements of largest absolute value

text: For example, given               list = {{1, -3, -5}, {2, 1, 6}, {0, 2, 4}, {-9, 2, 6}}      should return:               {-5, 6, 4, -9}      **Updated** I found a undocumented function called "Internal`MaxAbs",but it only accept two args，for example：               Internal`MaxAbs[2, -3]     Internal`MaxAbs[{1, -3, -5}, {2, 1, 6}]     (*      3      {2, 3, 6}     *)      How can I make it can accept Multiple parameters?


title: Natural boundary conditions variational methods

text: I am working on a problem of the calculus of variations. From the Variational Methods package, I can very conveniently use `EulerEquations` to get stationarity conditions in the form of Euler-Lagrange equations for my problem. Is there also a way to obtain expressions for the natural boundary conditions that are involved in making the functional stationary?


title: Transforming a CopulaDistribution only works with the Product Copula

text: **What I want to do:**   1) Define a joint distribution function using CopulaDistribution   2) then transform it with TransformedDistribution   3) to get the new Culmulative Distribution Function (CDF).   **The problem:**   If I choose correlation 0 or the Product Copula, everything is working perfectly, I obtain a CDF. If I choose a copula different from independence, I don't get a result anymore. In the code below, change the parameter for the copula from 0. to e.g. 0.2, then there's no result for the CDF anymore. (I'm using _Mathematica_ Version 8.0) **The code:**               dist = CopulaDistribution[{"Binormal", 0.}, {UniformDistribution[{0, 10}],          UniformDistribution[{0, 10}]}];           f[x_, y_] =        Piecewise[{{x - 3, x > 3 && y > 3}, {x - 6 + y,           x > 3 && y <= 3 && x + y - 6 >= 0}}];           transdist =        TransformedDistribution[f[x, y], {x, y} \[Distributed] dist];          CDF[transdist, 2.]


title: How can I plot a Chebyshev spiral?

text: The Chebyshev polynomials T_n of the first kind are a certain set of orthogonal polynomials. They can be defined by T_n(cos(x))=cos(nx), the first of them are   * T_0(x) = 1    * T_1(x) = x    * T_2(x) = 2x^2 - 1    * T_3(x) = 4x^3 - 3x    * T_4(x) = 8x^4 - 8x^2 + 1    * T_5(x) = 16x^5 - 20x^3 + 5x    * T_6(x) = 32x^6 - 48x^4 + 18x^2 - 1   * T_7(x) = 64x^7 − 112x^5 + 56x^3 − 7x A plot in the cartesian plane looks like this, seen on Wolfram Mathworld: ![Chebyshev polynomials](http://i.stack.imgur.com/3eflY.gif) On the same page, I found a beautiful polar plot of those polynomials: ![Chebyshev spiral](http://i.stack.imgur.com/UZrTD.gif) There they wrote, referring to "Graphica 1" by Michael Trott: > A beautiful plot can be obtained by plotting T_n(x) radially, increasing the > radius for each value of n, and filling in the areas between the curves > (Trott 1999, pp. 10 and 84). A version without filling, posted by Paul Kemper: ![Chebyshev spiral without filling](http://i.stack.imgur.com/DsFYf.jpg) I would like to understand the way that plot is generated. The filling doesn't matter to me, I just would like to know how I could plot such a polynomial radially. As the domain ranges from -1 to 1, I should take pi as a factor. Does anybody know a formula to display those functions in polar coordinates in such a way with increasing radius?


title: Differential Equation help

text: I have a differential equation that looks like this:                DSolve[(D[R[r, t], t])^2/(2*c) - (G*M1[r, z])/(        c^2*R[r, t]) - (λ*(R[r, t])^2)/3 - E1[r] == 0, ... "boundary conditions etc go here"]      I need to get `R[r, t]` using my values of `E1[r]` and `M1[r]`. However, my `M1[r]` is defined as:               M1[r_] :=  NIntegrate[(1 + f*Exp[-(r/y)^2])*(r)^2, r]      Herein lies the problem. I realise that `DSolve` uses `Integrate` internally, but the function I want it to solve has an `NIntegrate` in it and this causes problems. I'm not sure how else to evaluate an error function. Any ideas?


title: Plotting the direction field of a differential equation

text: I have to sketch the direction field for the following differential equation: $$\frac{dy}{dx}=\frac{-0.02 y +0.00002 xy}{0.08 x-0.001xy}$$ This is the code I used, which gives an incorrect plot:               StreamPlot[Normalize[{1, (y (-0.016 + 0.00008 x))/(x (0.12 - 0.006 y))}],          {x, -200, 200}, {y, -200, 200}, Axes -> True]      ![](http://i.stack.imgur.com/R72Bi.png) The following picture shows what I need to get: ![enter image description here](http://i.stack.imgur.com/OlBj6.jpg)


title: How to put the tensor product of two operators onto two variables?

text: I am trying to make an intuitive Mathemtaica program to show the principle of quantum walking. The idea of quantum walking is very simple and direct, but when I try to transfer it into Mathemitca codes, I meet several difficulties. The principle of quantum walk is introduced here http://susan- stepney.blogspot.jp/2014/02/mathjax.html and here http://xxx.tau.ac.il/abs/quant-ph/0303081 There are two operations in one step:   1. Coin operation (Hadamard coin H) ![enter image description here](http://i.stack.imgur.com/TDGx6.png)   2. Step operation (S) ![enter image description here](http://i.stack.imgur.com/khlvJ.png) With these two operations, bellow shows the first three steps of a quantum walk ![enter image description here](http://i.stack.imgur.com/suzFK.png) I hope to express this process in an intuitive Mathematica codes. The result of one step can be expressed as ![enter image description here](http://i.stack.imgur.com/jslqP.png) The two operators, H and S, are put on these two variables ![enter image description here](http://i.stack.imgur.com/b0JFA.png) I do not know how to realize such a tensor product in Mathemcatica. ![enter image description here](http://i.stack.imgur.com/67afI.png), where S and H are two operators; x and y are two variables; x is an array; y is an integer. But I guess this equation is correct, because similar equation is shown in wiki( http://en.wikipedia.org/wiki/Tensor_product) ![enter image description here](http://i.stack.imgur.com/X1otL.png) To realize this equation in Mathematica, I test an example first, as shown below . ![enter image description here](http://i.stack.imgur.com/hxwHX.png) My expected result is ![enter image description here](http://i.stack.imgur.com/248Zr.png) But I cannot obtain this result. My questions are:   1. How can I realize ![enter image description here](http://i.stack.imgur.com/LDbEK.png) in Mathematica？   2. How to intuitively express the first three steps of quantum walk using Mathematica codes? I have tried to solve this problem for several days, but made no progress. Any help or suggestion will be highly appreciated,


title: Issues with zero frequency component in discrete Fourier transform

text: I'm having trouble with the Fourier function at the moment. I'm solving a set of differential equations with NDSolve, then need to extract the spectrum associated with the curve below: ![enter image description here](http://i.stack.imgur.com/G3PNG.jpg) So i use table to generate a list of data from the output of NDSolve, called 'list', and then use the following code to do generate the Fourier transform:               T = 800;     dt = T/(10000 - 1);     n = Length[list];     ssf = RotateRight[Range[-n/2, n/2 - 1]/(n dt), n/2];     fft = Fourier[list, FourierParameters -> {-1, 1}] // Chop;     Fourdata = Transpose[{ssf, Abs[fft]}];      this gives the spectrum: ![enter image description here](http://i.stack.imgur.com/HfsaA.jpg) it seems like something weird is happening at zero frequency, with a small discontinuity, and a line running along at zero for all frequencies. I've messed around with both the propagation time and time steps, but it doesn't seem to go away. Does anyone have any insight into this? Thanks in advance, Jake PS. I hope i have included enough detail here, but let me know if you need more...


title: Bug in Solve (Mathematica 9)

text: Just came across the strangest bug under both _Mathematica_ 9.0.0 and 9.0.1. If one enters:               Solve[m == p Sin[x] && -Pi/2 < x < Pi/2, x]      ... then _Mathematica_ whirrs and whirrs (running on my Mac Pro with OS X 10.6.8), and doesn't seem to produce any answer (I gave up after a few minutes). But if one changes symbol p to something that 'sorts' earlier than an m, such as an 'a' or 'b', then it works correctly:               Solve[m == b Sin[x] && -Pi/2 < x < Pi/2, x]      > Solve::nsmet: This system cannot be solved with the methods available to > Solve. Obviously, one can add assumptions on p or b to make it solve, but that is not the issue being raised. Is this just a Mac issue, or are others experiencing the same on other platforms?