How to ask Mathematica to display answer in "$\LaTeX$" form

I am not sure how to explain it, but whenever I compute something in _Mathematica_ , the output always spits back the result in a _Mathematica_ language as opposed to easy-to-read equations. It's troublesome if my answer contains multiplies of parentheses and if my matrix is large. Is there a way to make _Mathematica_ display answers in "$\LaTeX$" form? So for instance, if i compute               RowReduce[{{1, 0}, {0, 1}}]      How do I make it spit out a square matrix instead of giving me back `{{1, 0}, {0, 1}}`?


naturalcolor stylesheet not working between linux and windows

I have encountered a weird problem with Mathematica 9. I have it installed on my laptop running Windows 7 and on my work computer now running Debian Wheezy. I am also using dropbox to access my work files and folders on the two systems. On both windows and linux I have setup the NaturalColour stylesheet as my default stylesheet for mathematica. I had no problems with this system until a few weeks ago when every time I open in linux a notebook written in windows, mathematica starts with that beep and the window with the error about the file could not be found. When I press OK on that window, the notebook opens in a new notebook with a really basic stylesheet: no title, subtitle and cell groups. Any help would be great! Update: Output of the function in the suggested post: /home/lucian/.Mathematica/SystemFiles/FrontEnd/StyleSheets/NaturalColor.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/ArticleClassic.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Article/JournalArticle.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Article/LaTeX- Article.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Article/LaTeX- Report.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/ArticleModern.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Article/Preprint.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Book/Compilation.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Book/LaTeX- Book.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Book/Monograph.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Book/Textbook.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Classic.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Classroom.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Core.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Creative/NaturalColor.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Creative/PastelColor.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Creative/PrimaryColor.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Default_8.0.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Default.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Demo.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/DemoText.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Dialog.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/EnvironmentMenuClear.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/HelpBrowser.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/HTML.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/InlineModifier.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/NaturalColor.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/NotepadMono.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Notepad.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Package.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Palette.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/PastelColor.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/PrimaryColor.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/PrivateStylesheetFormatting.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/PublicationDefault.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Report/AutomatedReport.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Report/ConfidentialReport.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Report.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Report/StandardReport.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/SlideShow/Earth.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/SlideShow/Garnet.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/SlideShow/Opal.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/SlideShow/Sapphire.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/SlideShow/Steel.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/SlideShow/Sunrise.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/SlideShow/Water.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/StyleMenuClear.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/StylesheetFormatting.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/SystemDialog.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/SystemPalette.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Textbook.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/TutorialBook.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Utility/Correspondence.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Utility/Memo.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Utility/Notepad.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Utility/Outline.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Wolfram/Demonstration.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Wolfram/HandsOn.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Wolfram/Legacy/Reference-v8-ja.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Wolfram/Legacy/Reference-v8.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Wolfram/Legacy/Reference-v8-zh.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Wolfram/Reference-2.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Wolfram/Reference- ja.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Wolfram/Reference.nb, /home/programs/Wolfram/Mathematica/9.0/SystemFiles/FrontEnd/StyleSheets/Wolfram/Reference- zh.nb I am sorry about the non-formatted text but I have no idea how to format an entire block of pasted text to make it look pretty here.


How can I calculate all irreducible polynomials of 31 degree in $\mathbb Z_2[x]$?

How can I calculate all binary irreducible polynomials of degree 31? or how i calculate all irreducible $f$ in $\mathbb Z_2[x]$? (The irreducible polynomial in $\mathbb Z_2[x]$ and $\mathbb R$ are distinguish; for example, in $\mathbb Z_2[x]$, we have $x^2+1=(x+1)(x+1)$.)


Microsoft SQL DatabaseLink connection using Windows Authentication from Mac

We know that Mathematic doesn't natively support Windows Authentication connect. But as we can see in this post, the problem can be easily solved when your Mathematica is in Windows version (I have just made it). The company that I work is now changing to Windows Authentication, and the problem is that I use both **Mac** and Windows. ## Question: There is someway that I could connect into SQL Server database using Windows Authentication from my Mac Mathematica? So I could pass my Windows Domain/User and Password together with the jDBC connections string? PS: I don't want to use Windows version of Mathematica in my Mac by Parallels, this will be my last shot.


Single-Window-UI not possible?

I'm still very frustrated about the separation of the menubar (File, Edit, Insert, ...) and the open notebooks in different windows. I would prefer to have the menubar directly above each notebook in the same window, following the "normal" user interface principles of Windows and resulting a minimum of one window after startup instead two ones. Is there any command argument or preference option I didn't find so far?


Is it possible to render Graphics with more than "Byte" bitdepth?

I wonder is it possible to render `Graphics` in _Mathematica_ with bitdepth higher than `"Byte"` which is the maximum bitdepth supported by the Windows XP operating system (it is so-called "True Color")? Tracing the rasterization with the option `TraceInternal->True` shows that `Graphics` is always rendered to a matrix of `Integers` in the range from 0 to 255, then it may be converted to `Reals` if requested but such conversion does not increase the bitdepth, of course: it changes only the internal representation of the `Image`. For example, let us consider rendering of `VertexColors`:               Cases[Trace[       Image[Graphics[         Polygon[{{-1, 0}, {1, 0}, {0, Sqrt[3]}},           VertexColors -> {Red, Green, Blue}], ImageSize -> 4], "Real"],        TraceInternal -> True],       x_List /; MatrixQ[Unevaluated@x, NumberQ], {1, Infinity}]      One can see matrixes of values between 0 and 255 in spite of requested `"Real"` bitdepth. Let us compare the results of rendering with different requested bitdepths:               In[21]:= Image[       Graphics[Polygon[{{-1, 0}, {1, 0}, {0, Sqrt[3]}},          VertexColors -> {Red, Green, Blue}], ImageSize -> 4], "Real"] ===       Image[Image[        Graphics[         Polygon[{{-1, 0}, {1, 0}, {0, Sqrt[3]}},           VertexColors -> {Red, Green, Blue}], ImageSize -> 4], "Byte"],        "Real"]          Out[21]= True      It is obvious that the requested bitdepth does not change the real rendering bitdepth. So the question is: is it possible to render `Graphics` with bitdepth higher than `Byte`?


Open and search Documentation-Center

In notebooks you can press `F1` (or `Shift`+`F1` for a new window) to:   1. **open** the help page of the marked `Symbol` or the `Symbol` under the cursor in the Documentation Center   2. to **search** the Documentation Center, if no direct page was available **Question:** Is it possible to achieve exactly this behavior with a function `searchDoc[input_String]`? ## Related issues **Related 1:** As stated in the documentation to `Hyperlink`, this here opens the documentation of `Plot` in a new window               NotebookOpen["paclet:/ref/Plot"]      but if the "paclet" does not exist, an error message appears instead of a search in the docs. **Related 2:** It's possible to mimic the behavior of `F1` with a `FrontEndToken`.               Button["HEEELP!!", FrontEndExecute[FrontEndToken["SelectionHelpDialog"]]]      This button shows the help of marked symbols or of symbols under the cursor. Problem here is, that it searches always the selected expression. Maybe there exists something similar which can take an input string. **Related 3:** One of the probably biggest resource of information can be found in package               $InstallationDirectory/AddOns/Applications/DocumentationSearch      This seems to contain the functions and helpers which are actually used in the Documentation Center. See for instance what               DocumentationSearch`SearchDocumentation["Graphics"]      gives.


Best Practice to write ::usage for own package functions

I'm writing an own package with _Mathematica_ , that I would like to make available for others. In order to do that (and for my own usage of the package), I would like to write `::usage`-strings for all my public functions. I would like to use a formated string for `::usage` in order to refer to some mathematical background in the explanations, e.g. if one of the inputs is a matrix, the `::usage` may contain $\mathbf{M}\in\mathbb Z^{d\times d}$ or something like that. The way I'm generating these up to now is, to take a cell and change it's style to text, then write the text and copy it into the `::usage="..."` cell of the package. On saving the package, that gets transformed into the classic commands, like in the following example:               DirichletKernel::usage = "DirichletKernel[\!\(\*StyleBox[\"mM\",\nFontWeight->\"Bold\"]\)]           provides a dirichlet kernel with respect to the regular integral matrix mM       in Fourier coefficients. The same options as for the function \!\(\*       StyleBox[\"deLaValleePoussinKernel\", \"Code\"]\)\!\(\*       StyleBox[\"[\", \"Code\"]\)\!\(\*StyleBox[\"]\", \"Code\"]\) apply.";      Where the last part at least seems a little messed up. There are two questions arising: 1) Is there an easier way to write such a usage message? because if I want to change something, I usually have to write the whole text again, because the format is quite verbose. What workflow do you use to write `::usage` messages? 2) Sometimes the copy&paste stuff generates errors (hmpf, if you want to demonstrate something, of course, it works, I'll edit this, if I can get the actual message), that occur in the message window. Since _Mathematica_ 9 that already happens if the autocomplete-box occurs. So what has to be taken into account copying formated cells (text with math formula and e.g. bold face and code parts) into strings - in order to not get messed up (erroneous) strings?


While-Loop Linear Projection

I'm would like to do a linear progression for a recursive relation of a consumption function. Combining my program skills and my sparse knowledge of mathematica, I was thinking about doing it in a while-loop as follows:                While[\[CapitalDelta]Cp < 1,      Cp = 0.4 \[CapitalDelta]Y +         0.407 (0.9 Subscript[Yl, -1] + 0.1 Subscript[Wl, -1] - Subscript[           Cp, -1]) + Subscript[Cp, -1];      \[CapitalDelta]Cp = Cp - Subscript[Cp, -1];      W = Subscript[Wl, -1] + (\[CapitalDelta]Y + Subscript[Yl, -1]) - Cp;      Subscript[Wl, -1] = W;      Subscript[Cp, -1] = Cp;      ]      Though, it doesn't work. **EDIT: Clearifying----** I have to functions, one that determines consumption (Cp) and one that determines the fortune (Wp). They are recursive in that I need to determine the consumption before I can determine the fortune. $$ Cp=0.4\Delta Y+0.407(0.9Y_{-1}+0.1Wp_{-1}-Cp_{-1})\\ Wp=Wp_{-1}+Y-Cp $$ The symbol $_{-1}$ states that the data are lagged meaning that it is last years value. Initially I append the following data to the variables in order for the loop to start, since I would like to project the value of Cp and Wp ten year ahead. $$ Y_{-1}=1\\ Wp_{-1}=1\\ Cp_{-1}=1\\ \Delta Y=1\\ $$ Then I would like to make a loop that iterates through the functions 10 times, whereas they after each iteration automatically assign the newly calculated value to the lagged variables, being: $$ Y_{-1}=Y\\ Wp_{-1}=Wp\\ \vdots $$ I would like for $\Delta Y$ to increment by 1% each year automatically as well. How is this possible? Please ask if the question is still unclear. **OBJECTIVE** The purpose of this whole head-ache of mine is to make a prototype of a consumption model of a given society. Therefore, I would like to be able to write the acquired data in a graph, with the percentage of change in the different variables on the Y-axis and the years of projection on the X-axis (i.e. 1, 2, 3, ... 10). In short, the consumption equation is defined as: $$ dlog(C)=0.4 dlog(Y)+0.407(log(Y_{-1}^{0.9} W_{-1}^{0.1})-0.200 log(C_{-1}))+0.011 $$ Whilst the fortune equation corresponds to: $$ W=W_{-1}+Y+C $$ The reason I've used the above annotation is because I wanted to linearize the consumption equation with the purpose of placing both of the equation in a matrix system (correspondingly $dlog(C)=log(C)-log(C_1)=\Delta C_l,\text{where}C_l=log(C)$). Firstly, though, I wanted to get it to work. The initial values of the lagged variables are set to 1. In my first example I left out the parameters to simplify the projection. Then, when the system worked, I wanted to add them. Hope it clarifies it well enough. **OBJECTIVE END** **----EDIT END** How can I solve this?


Filling for ListPolarPlot

I want to use `Filling` for `ListPolarPlot` in such a way that the points in the list are joined to the origin with a line colored same as in the `Filling -> Axis` of `ListPlot`. I could do it up to a certain stage, but I couldn't set the color of the lines. Here is what I have done. Suppose that               pl = Table[{k, Sin[k]}, {k, 0, 10}]      is the point list. I can connect them to the origin in a tricky way by               Show[Table[ListPolarPlot[{{0, 0}, pl[[k]]}, Joined->True], {k,1,Length[pl]}],          ListPolarPlot[pl]]      but I can not set the color of the joining lines as the following code would do.               ListPlot[pl, Filling -> Axis]      I would be very glad if someone would tell me how to color the lines.


Changing the number of locators with SetterBar

Typically when adding locators I would use a button i.e. something along the lines               DynamicModule[{pt={{0,0}}},         Column[{LocatorPane[Dynamic[pt],             Dynamic[                 Graphics[{Red,Point[pt]},PlotRange->{{-2,2},{-2,2}}]                 ]             ],         Button["Add locator",AppendTo[pt,{0,0}]]}]     ]      However, say I wanted to do the same, but within a manipulate and with a `SetterBar[]` (or `Slider[]` or `PopupMenu[]`). I have tried several approaches, but the best I have come up with is at best sketchy. The following code works, but you have to move a locator before a new one shows up (or goes away).               Clear[update]          update[list_, i_] :=If[Length[list] < i, Append[list, {0, 0}], Take[list, i]]<          Manipulate[         DynamicModule[             {pt={{0,0}}},             LocatorPane[Dynamic[pt,(pt=update[#,nrPts])&],                 Dynamic[                     Graphics[{Red,Point[pt]},PlotRange->{{-2,2},{-2,2}}]                 ]             ]         ],         {nrPts,{1,2,3,4},SetterBar}     ]      I have tried to place `Dynamic[]` in various places, but to no avail. Is there some way to use `SetterBar[]` and get as smooth results as with `Button[]`?


Issue with ListConvolve

I am a new _Mathematica_ user, learning the intricacies of functional programming. I have issues withe applying a function over a moving list. My function seems to work and give correct results but it also shows a syntax error. Can you advise how I can get rid of the syntax errors?               movingMap[f_, mylist_, args_, r_] :=        ListConvolve[ConstantArray[1, r], mylist, {-1, 1}, {}, Times, f &];          yalist = {a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10};          testfunction[x_, y_, z_, w_] := w/6*(x + 4 y + z);          movingMap[testfunction[##, 1], yalist, t, 3]      This gives me the correct results but also gives a syntax warning. > {1/6 (a0 + 4 a1 + a2), 1/6 (a1 + 4 a2 + a3), 1/6 (a2 + 4 a3 + a4), 1/6 (a3 + > 4 a4 + a5), 1/6 (a4 + 4 a5 + a6), 1/6 (a5 + 4 a6 + a7), 1/6 (a6 + 4 a7 + > a8), 1/6 (a7 + 4 a8 + a9), 1/6 (a10 + a8 + 4 a9)} I would appreciate advice on getting rid of the syntax error.


Evaluating FindRoot at different starting points on a grid

I'm trying to evaluate the roots of a complex function at different starting points on a grid using `Do[Do[FindRoot[g[z], {z, j + k*I}], {j, 10}], {k, 10}]`. However, it gives me the following error messages:               FindRoot::jsing: Encountered a singular Jacobian at the point {z} ={-17.0839+14.7475 I}. Try perturbing the initial point(s). >>     FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>     FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>     FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>     General::stop: Further output of FindRoot::lstol will be suppressed during this calculation. >>     FindRoot::jsing: Encountered a singular Jacobian at the point {z} = {-16.872+27.5137 I}. Try perturbing the initial point(s). >>     FindRoot::jsing: Encountered a singular Jacobian at the point {z} = {-17.5117+54.0621 I}. Try perturbing the initial point(s). >>     General::stop: Further output of FindRoot::jsing will be suppressed during this calculation. >>      After the error messages it stops displaying any output. I know most of the starting points will generate those errors. I'm trying to use the Do loop so I can get past those errors to the valid starting points. Does anyone know how to suppress the errors and keep the loop running? I tried 'Off[General::stop]', but that doesn't seem to work.


Drawing pairs (graph, circle packing)

Circle packing theorem states: _For every connected simple planar graph G there is a circle packing in the plane whose intersection graph is (isomorphic to) G._ **How to use Mathematica to draw examples of such pairs (graph, circle packing)?** More specifically: Generate a random connected simple planar graph with given number of nodes N (this can be done lets say using adjacency matrix; in a way another parameter affecting resulting graph could be "density" of links). Draw its usual graphical representation containing nodes and links. Then draw its circle packing representation. In other words, lets say there is N slider, and "density" slider (variable parameters). Based on that, get regular graph drawing and its circle packing. * * * NOTE ON GENERATING PLANAR GRAPHS: To my knowledge, this is not a trivial problem, and there is no built-in Mathematica solution. Though, there are several questions and answers here. One of best is Create triangular mesh from random list of points :               SeedRandom[1];     pts = RandomReal[{0, 12}, {100, 2}];     Needs["ComputationalGeometry`"];     dt = DelaunayTriangulation[pts];     dt // Column     toPairs[{m_, ns_List}] := Map[{m, #} &, ns];     edges = Flatten[Map[toPairs, dt], 1];     Graphics[GraphicsComplex[pts, {Line[edges],        Red, PointSize[Large], Point[pts]}]]      ![enter image description here](http://i.stack.imgur.com/yAiPy.png) * * * NOTE ON GENERATING CIRCLE PACK CORRESPONDENT TO THE PLANAR GRAPH: See: Collins, Stephenson: A circle packing algorithm. * * * This question is not an assignment. It is an intellectual experiment, related to aestetics and structure. I am not requesting code. I am seeking ideas, approaches, and solutions. * * * Visual examples: * * * ![enter image description here](http://i.stack.imgur.com/omIfc.png) * * * ![enter image description here](http://i.stack.imgur.com/gSPBW.png) * * * ![enter image description here](http://i.stack.imgur.com/2Z7pz.jpg)


When to use memoization concept in Mathematica?

I have recently learnt memoization concept. But I am not sure in what scenarios i need to use this concept. if someone can help me out with different scenarios it would help me a lot to develop a complete understanding


Decapitating "explicit" and "implicit" heads

This is a follow up to this question. So far, I named "explicit" heads to those that appear explicitly in the expression. For example, `f[x]` has an explicit head. I called "implicit" heads to those that are returned by `Head` but do not appear in the expression. For example, `5` has `Integer` as implicit head. In the comments of the original question, rcollyer pointed out that the head of `Complex[1,2]` is explicit but `f@@Complex[1,2]` is not "decapitated" because `AtomQ@Complex[1, 2]` returns `True`. Then, I came up with the following code:               myAtom /: AtomQ[myAtom[__]] := True     f @@ myAtom[1, 2, 3]     (*f[1,2,3]*)      _How does`Apply` know when the head can be replaced?_ According to the documentation of Apply: > Applying to atomic objects that do not have subparts effectively does > nothing Thus, it seems that checking with `AtomQ` is not enough. One should also check for the existence of parts. For example, `Complex[1,2][[1]]` returns an error but `myAtom[1, 2, 3][[1]]` does not. Incidentally, `TreeForm[Complex[1, 2]]` shows "parts". Hence the question: **Is there a function that makes both checks at once?** * * * Follow up: **Is there any way to make a head non-decapitable?** Is there a statement similar to `myAtom /: AtomQ[myAtom[__]] := True` such that               Map[f, {1, {2, myAtom[3]}}, {-1}]      will return `{f[1], {f[2], f[myAtom[3]]}}`?


I can't solve this set of equations

I am having trouble solving a set of equations in mathematica. I do not get any errors, but i don't get any answers as well. I have some restrictions on my parameters and variables in the equations which i try to implement too. I have tried to implement them using $Assumptions and Assuming[], but it seems like Mathematica ignore it. However, all my parameters and variables are real and non-negative. g is a known positive constant which i define earlier in my notebook. Here is what i type in Mathematica 8 (this is copy-pasted from my program):               g:=6.45161;     Solve[{u == 1/3 μb - 2/3*e, d == 1/3 μb + 1/3*e,      2*(u^2 - (g x/2)^2)^(3/2) - (d^2 - (g x/2)^2)^(3/          2) - (d^2 - (g y/Sqrt[2])^2)^(3/2) - (e^2)^(3/2) == 0,      x >= 0, y >= 0,μb > e, μb >= 0, u >= 0, d >= 0, e >= 0}, {u, d, e},      Reals]      μb is a parameter and x and y are variables in some other functions. So what i want is for u,d and e to be functions of x and y, and dependent of μb. Is there an easy way to solve this in Mathematica 8? This is my first post here, so please let me know I make things unclear or something. I have tried to find the solution elsewhere, but have not succeeded.


Algorithm to generate a certain matrix

I am looking for a convenient way to generate a matrix of the following symmetric form (numbers could also run from -3 to +3 or just from -1 to +1): ![enter image description here](http://i.stack.imgur.com/plRJi.jpg) Tips, anybody?


Sublists of Random Permutations

What is an efficient way to create a list of (psudo)randomly chosen permutations? I'm trying to create a list like below:               x = 5;     RandomChoice[Permutations[Range[1, x]], {x}]          {{1, 2, 4, 5, 3}, {5, 3, 1, 2, 4}, {5, 2, 3, 1, 4}, {1, 3, 2, 4, 5}, {3, 2, 4, 5, 1}}      However, this eats up a lot of memory and doesn't work after x=11. Each sub-list does not necessarily have to be unique, but in this case it was.


Finding a number which has the same remainder when dividing certain other numbers

I am having some trouble with formulating my problem in _Mathematica_ for this question: > Is there a number greater than 1 which leaves the same remainder when it > divides into 1716, 2154, and 4271? (For example, 4 does not work because if > we divide it, we get remainders of 0, 2 and 3). Answer the question by > checking all numbers starting at 2 and ending at 1716. I am a bit confused on how to set it up. I want to say it will be a `While` command that starts at `n = 2` but I don't know how to proceed.


position image combined with other graphics

Is there a way to directly transform an image? This works but seems klunky :               Graphics[{Translate[ Raster@ImageData@image, {x,y}], .. other graphics objects .. }]      Just wondering if there is a better way.. Per JM.s comment, you can sort of do this with `ImageForwardTransformation` I actually looked at those before asking the question and didn't think they would work, but now I went back and figured it out.. here is a simple translation:               {w, h} = ImageDimensions[img]     ImageForwardTransformation[ img , (# + {x, y}) &, Background -> 1,              DataRange -> Full, PlotRange -> {{0, w + x}, {0, h + y}}]      This creates a new larger image, large enough to contain the transformed result but still anchored with a corner at {0,0}, so isn't really equivalent to simply translating the image.


How to keep ItemSize effect when export to HTML

Here's the simple code               Grid[Table[Item[1,ItemSize->{5,10}],{2},{2}],ItemSize->{5,10},Background->Red]      After saving the output cell as .html file, `ItemSize` makes no effect. Here in _Mathematica_ ![enter image description here](http://i.stack.imgur.com/V6G1I.png) Here in _Html_ ![enter image description here](http://i.stack.imgur.com/snQIS.png) How to make the `ItemSize` keep the effect in the .html file? And I don't mean the gif effect something like what this code done.               Text@Grid[Table[Item[1,ItemSize->{5,10}],{2},{2}],ItemSize->{5,10},Background->Red]


undisputed FrontEndTokenExecute

Thanks to this great topic, I've found the `FrontEndToken` that I was looking for: `"DeleteGeneratedCells"` (well, it is also written in `Help` but I've found it later :) **Question:** I would love to execute it in `NotebookObject` without confirmation through the automatically displayed `ChoiceDialog["Do You really want to..."]`. Is it maybe a case of `FrontEndTokenExecute` **parameters**? I suspect I can deal with it by setting some global options for _Mathematica_ but I would rather leave them.


Remove the white margins of a Graphics3D figure

If the option `Boxed` is set to be `False` in `Graphics3D`, additional white margins may appear as shown in the following figure. Is it possible to remove the useless margins such that the borders touch the _contents_?               smallarray =       With[{L0 = 300, r0 = 50, unitcellsize = 400, origin = {0, 0, 0},         la = 800, ra = 50 },       Graphics3D[{EdgeForm[None], Yellow,          Table[{Cylinder[{{ix*unitcellsize, iy*unitcellsize - L0/2,               0}, {ix*unitcellsize, iy*unitcellsize + L0/2, 0}}, r0]}, {ix,            1, 5}, {iy, 1, 5}], Arrowheads[0.1], Red,          Arrow[Tube[{origin, origin + {la, 0, 0}}, ra]], Magenta,          Arrow[Tube[{{0, 0, 0}, origin + {0, la, 0}}, ra]], Cyan,          Arrow[Tube[{origin, origin + {0, 0, la}}, ra]]}, Boxed -> False,         Lighting -> Automatic, ViewPoint -> {Pi, Pi/2, Pi},         ImageSize -> {Automatic, 400}]]      ![enter image description here](http://i.stack.imgur.com/NuZ0R.png)


How can I detect an ellipse in a photo?

I tried to detect the rim of the following cup as an ellipse. ![some cup](http://i.stack.imgur.com/H63BK.jpg) I've tried the solutions given in How to find circular objects in an image? to detect the ellipse, but the detection result was not quite what I wanted. The reason might be that `ChanVeseBinarize` function can't separate the rim from the body. Therefore `SelectComponents` will view the whole cup as one component and consequently detect nothing. Then I tried to use edge detection. After manipulating the parameters, I can detect the edge of the rim like this: ![edge detection attempt](http://i.stack.imgur.com/SPiTW.png) But I can't find an algorithm that detect the line of an ellipse. How might I do that?


How can I use Manipulate[] to click on a Graphics3D output and generate $(x,y)$ outputs on a projection plane parallel to my screen?

Say I have some Graphics3D object that I'm looking at from a top down perspective, e.g.:               Graphics3D[{Sphere[{-1, 3, 0}, 1], Sphere[{0, 1, 0}]}, ViewPoint -> Top]      How might I use Manipulate[] so that I can click somewhere on this image and generate an ${x,y}$ output corresponding to the position of the mouse on a projection plane parallel to my screen with respect to the coordinate system in the image? In the above example, for instance, clicking on the center of first sphere would output $(-1, 3)$, while clicking on the center of the latter would output $(0,1)$.


How to avoid Transpose in output

I would like to have               a[i_, j_] := Piecewise[{{HoldForm[A], i == j && i < 2},               {HoldForm[A], i == j - 1}, {-HoldForm[A],           i == j && i >= 2},               {0, True}}];      W = Array[a, {2, 2}]     a[i_, j_] := Piecewise[{{HoldForm[Msub], i == j}, {0, True}}];      M = ArrayFlatten[Array[a, {2, 2}]]     TransP[M_] := Map[Transpose[#1] /. Transpose[0] -> 0 & , Transpose[M],             {2}];      G = MatrixForm[ArrayFlatten[{{M, W}, {TransP[W], 0}}]]      such that the Transpose[A] is printed in "Pretty" with a T in superscript in the output? How can I achieve this?


Sierpinski carpet with GraphData

Is this graph in the list among the so-called "standard" structures used in `GraphData`? However, I have not found, yet, anything like "Carpet" or "Sponge" in the list of the object that can be built. Maybe, this graph has a different name? For me, using `GraphData` helps to save time for constructing adj. matrix, therefore, I would rather prefer using this function than drawing the graph... Thank you very much in advance!


Using bin values and metadata in ChartElementFunction in histograms

The `DensityHistogram` command lets you specify a `ChartElementFunction` which according to the documentation: > The arguments supplied to `ChartElementFunction` are the bin region > `{{xmin,xmax},{ymin,ymax}}`, the bin values _lists_ , and metadata > `{m1,m2,...}`. My question is how can I use the bin values lists and the metadata? When I try to access them all I get something like               System`DensityHistogramDump`thisBinList$270262


BarChart and Log Scale results in different bar origins

I want to create a bar chart from two different data sets.               data = {{38, 4.637, 88.3238, 2.26935}, {277, 75.724, 1442.36, 5.07813}, {561, 72.623, 1383.3, 2.39955}, {253, 32.727, 623.371, 2.39955}, {1305, 181.438, 3455.96, 2.58557}}      and               data = {{27, 93.14, 1816.67, 67.2842}, {92, 248.898, 4854.7, 52.7685}, {510, 1681.48, 32796.8, 64.3075}, {234, 933.986, 18217.2, 77.8512}, {443, 4117.78, 80316.2, 181.301}}      These two charts have to have the same range on the y axis (0, 100000), so they can be compared easily. So I can still see the bars for the lower values, I set the ScalingFunctions to "Log". I plot them both with this code:               plot1 = BarChart[data, PlotRange -> {0, 12}, ScalingFunctions -> "Log"]      However, when I create the first plot, the bars don't start at the y-axis, but below, whereas the second data set has the bars start at 10, not at 0. I am using Mathematica 8. If I use PlotRange-> {Automatic, 12}, then I don't have the problem of the bars being off the x axis, however they still start at different values (0 and 10). Look: ![Mathematica graphics](http://i.stack.imgur.com/E4vVo.png) Does somebody know what I am doing wrong?


How to get mathematica to simplify a result

I have the following output $\text{Li}_2\left(3-2 \sqrt{2}\right)-4 \text{Li}_2\left(-1+\sqrt{2}\right)$. This turns out to be equivalent to $\displaystyle\log^2(1+\sqrt{2})-\frac{\pi^2}{4}$. How can I get mathematica to simplify the first result to the second? I have other (more complicated) results like this that I need to simplify. `FullSimplify` and `Simplify` don't do anything, it just throws the same thing that I put in back at me...               FullSimplify[PolyLog[2, 3 - 2 Sqrt[2]] - 4 PolyLog[2, -1 + Sqrt[2]]]          Log[1+2^(1/2)]^2-Pi^2/4


Any rule of thumb for converting a simple mathematical expression into a pure function?

By simple mathematical expression I mean one with a few functions and few variables copied into MMA in a mechanical way from a math book. For example this one, giving the distance between two points in a rectangular cartesian coordinate plane:               u = {-3, 3}; v = {1, 5};     d = (( Abs[ u[[1]]] - Abs[v[[1]]] ) ^2 +  (Abs[u[[2]]] -         Abs[v[[2]]])^2  )^(1/2       Except for the use of the Abs built-in function (I found no way in InputForm to type in the vertical bars on each side of the variable which is possible in TraditionalForm ), you recognize at a glance what this is about with an elementary knowledge of MMA. Now I read in MMA documentations that it is advised to convert any "math-like" expression into a pure functions but apart from many examples suited to a specific expressions - mine is another sure - I did not read any guidelines which generalises the approach to take. So I proceeded in a an empirical way, a "down-up" up approach:               Abs[#] &@ {u, v}      Thread[Plus[Abs[#] &@ % ]]     Apply[Subtract[##] &, %, {1}]     (#^2) & [ %]     Sqrt[Apply[Plus[##] & , %]]      Only pure functions here which can be condensed by copy/pasting the origination expression in place of % like that :               Sqrt[Apply[     Plus[##] & , (#^2) & [      Apply[Subtract[##] &, Thread[Plus[Abs[#] &@ {u, v} ]], {1}]]]]      I'm sure that if I read this last expression in a week's time, I'll be perplexed unless I trace it! Is it easy to simplify this concatenation of 4 pure functions into one single pure function, and if so, how? I feel that the way the data is presented before you start writing MMA code is of prime importance: Instead of two lists, I could have used one list with sublists, or a flattened out list (ie {u1,u2,v1,v2) and each of this choice has a strong bearing to what you will code afterwards. Are there any guidelines about what is the less messy or more elegant in the way lists are to be constructed for a given problem?   Thanks for your answers


How to memoize a function with Options?

Consider the following modified fibonacci function:               tempHist = $History     $History = 0     ClearAll[fibon]     Options[fibon] = {k -> 1}     fibon[0] = 0;     fibon[1] = 1;     fibon[n_, OptionsPattern[]]:= fibon[n-1] + OptionValue[k] * fibon[n-2]          fibon[30] // Timing           (* {4.111894, 832040} *)     fibon[30, k -> 2] // Timing   (* {4.161676, 1149851} *)      The modification involves a coefficent that multiplies the second term of the recursive definition. Can the idiom `f[x_]:=f[x]= ...` be used to implement memoization in this case? I tried with no luck the following naive approaches for `c`-aching `fibon`               ClearAll[cfibon]     Options[cfibon] = {k -> 1}     cfibon[0] = 0;     cfibon[1] = 1;     cfibon[n_, OptionsPattern[]]:= cfibon[n, OptionsPattern[]] = cfibon[n-1] + OptionValue[k] * cfibon[n-2]          cfibon[30] // Timing          (* {2.1999999997746045*^-5, 832040} *)     cfibon[30, k -> 2] // Timing  (* {2.899999999961267*^-5, 832040} *)      _Something_ is being memoized, but this is not the wanted behavior (note that the two calls return the same value `832040`, the second call is meant return `1149851`). Here is another try:               ClearAll[cfibon]     Options[cfibon] = {k -> 1}     cfibon[0] = 0;     cfibon[1] = 1;     cfibon[n_, OptionsPattern[]]:= cfibon[n, k -> OptionValue[k]] = cfibon[n-1] + OptionValue[k] * cfibon[n-2]          cfibon[30] // Timing     (* {10.664260999999998, 832040} *)          cfibon[30, k -> 2] // Timing     (* {10.677505, 1149851} *)      Now, the results are as expected, by the computation is slower than the non- cached version! So... How to memoize a function with `Options`?


Help with 1-dimensional random walk

I would like to simulate the evolution of a bankroll of a 2 player game where you have the probability of winning p. If a player wins, the bankroll grows by 1 unit minus a fee that each player pays, let's say the fee is r. So, when a player wins a game the bankroll grows by 1-2*r, since each player pays the fee. If a player loses the game obviously the bankroll diminishes by 1 unit. In the example below p=0.517 and the fee is such that the player wins 0.959 units. When I generate the plot I am surprised to see that the line decreases while I would expect that it would increase. Am I generating the NestList incorrectly? Thanks.               RandomWalk[n_] :=         NestList[(# + If[RandomReal[] >= 0.517, 0.959, -1]) &, 0, n]          ListPlot[RandomWalk[3000], Joined -> True


What are these strange shapes in my Plot3D[]?

Plotting a function, I noticed some strange spots away from the main feature, the dark purple here: ![1](http://i.stack.imgur.com/QF7l2.png) You can see that they don't actually have any curvature themselves: ![2](http://i.stack.imgur.com/Bjwmk.png) Strangely, you don't see them if you look from the bottom: ![3](http://i.stack.imgur.com/YKYUl.png) What are they from? Something about lack of precision or overflow or divergence?


An example of how to compute numerically the KL-divergence in mathematica

I wanted to compute an exact number for two probabilities that I am comparing. These are two normal distributions as: $$Normal(\mu = 5, \sigma = 4)$$ $$Normal(\mu = 5, \sigma = 5)$$ I decided to try to use mathematica and I inputed the following after I simplified a little bit: ![enter image description here](http://i.stack.imgur.com/EkDXa.png) but when I press shit enter to compute, it doesn't actually compute it numerically for me. I was wondering if anyone knew why it wasn't computing it. (I tried wolfram first and it said it exceeded time to compute it)


Fixed Point Math in MMA

I am working with a library that needs input in a Fixed Point notation. I’d like to figure out a way to convert the floating point results into fixed point representation. The fixed point length is 16 bit. Numbers can be represented with a variable number of bits and I can specify the format of the bits. For instance, I can represent a number as Signed[3.13], upto 3 bits are used to represent the integer portion, and 13 bits are used for the fraction (resolution of 2^-13). Q1. What is the best method to convert Mathematica floating point output into a 16 bit number. Ideally, I’d like a function like:               f[x_, signbits_, integerbits_, fractionbits_]      Q2. Given a set of numbers, what is the best method to determine the ideal number of integer bits and fractional bits used for the representation in order to minimize truncation errors               data = {0.0000618365, 0.0000701533, -0.0000747471, 0.0000595436, 0.0000705533, \     0.0000728675, 0.0000711056, 0.0000684559, 0.0000753624, -0.0000557638}


Optimum number of cog teeth for two step helical gearbox

**Note:** Cross-posted at http://community.wolfram.com/groups/-/m/t/137895?p_p_auth=8QnKtT9I. I am to design a two step gearbox. The first step is to choose the number of teeth in each cog wheel in order to achieve a gear ratio of 17.3. In other words:                (N1 N2)/(n1 n2) == 17.3      where N1 and N2 are the number of teeth in gear 1 and 2, and n1 and n2 are the number of teeth in pinion 1 and 2. Is it possible to get _Mathematica_ to "guess" the lowest number of teeth possible and still get as close as possible to 17.3? The number of teeth in the pinions must not be lower than 20. In addition, the number of cog teeth in the gears must not be divisible, i.e. only common factor has to be 1.


Gravatars/identicons with Mathematica

The default avatar/identicon is based on an MD5 hash of your e-mail address. With some e-mail providers (e.g., GMail) the address `gmailuser+foo@gmail.com` is still delivered to `gmailuser@gmail.com`, so this trick can be used to change the hash of your e-mail and thus get a different identicon, but there is no guarantee that it looks better than the original. How can we semi-automate the search for your preferred identicon using Mathematica?


A suspicious result of an integral

I integrated this term in _Mathematica_ : $$\int_{-\infty}^{\infty} d\omega*\sin(s*\omega)*\frac{1}{e^{\beta*\hbar*\omega}-1}*\frac{\omega}{\omega^{2}+\gamma^{2}}$$ The code in _Mathematica_ :               Integrate[Sin[s*ω]*(1/(Exp[β*ℏ*ω] -1))*ω/(ω^2 + γ^2), {ω, -Infinity, Infinity},       Assumptions -> {ℏ > 0, s >= 0, γ > 0, β > 0}]      The result is: $\frac{-\pi}{2}*e^{-s*\gamma}$ Where is $\beta*\hbar$?


A problem with functions and Infinite expression 1/0 encountering

Following code (function) makes integrals and then replace `f[x]` with `Cos` functions and calculate the definite parametric integrals as it is shown below :               DoGenerateIntegrals[Number_] :=          Block[{GeneratingIntegrals, COS, LimitCOS},          GeneratingIntegrals =      Array[Integrate[        Symbol["f"][x], {x, Symbol["x" <> ToString[2 # - 1]],          Symbol["x" <> ToString[2 #]]}] &, Number];          COS = Total[      GeneratingIntegrals /.        f[x] -> Cos[((i \[Pi])/L) x] Cos[((j \[Pi])/L) x]];     LimitCOS = Limit[COS, i -> j];          {COS, LimitCOS}];      Then :               In[1]:= Produce = DoGenerateIntegrals[2]      By using the results of the `In[1]` :               CosInt = Which[i != j, Produce[[1, 1]], i == j, Produce[[1, 2]]];      Which `CosInt` is to avoid encountering Infinite expression (`1/0`). Now it will use in a code like below in a matrix :               List1 = Table[0, {i, 1, 6}, {j, 1, 6}];               Do[Do[List1[[i + 2, j + 2]] = CosInt, {j, 1, 2}], {i, 1, 2}];          List1 // MatrixForm      In `DoGenerateIntegrals[]` when the integrals evaluates with mentioned `f[x]`, there will `i-j` in their denominator of their fractions which cause Infinite expression in `List1` calculation. In order to avoid encountering Infinite expression (`1/0`), I use `LimitCOS` and `CosInt` to calculate the circumstances of `i=j` . But after calculation, it will face encountering Infinite expression (`1/0`) with following error:               Power::infy: Infinite expression 1/0 encountered.>>     Infinity::indet: Indeterminate expression 0 ComplexInfinity encountered.>>      I wonder why this is happening; however, I have used some strategies to avoid it.


Time-series decomposition in Mathematica

I'm studying time-series in R with this book, and there is a nice command in R that creates decompositions. Inside _Mathematica 9_ the command can be executed as:               Needs["RLink`"]     InstallR[];     REvaluate["{         url <- \"http://www.massey.ac.nz/~pscowper/ts/cbe.dat\"         CBE <- read.table(url, header = T)         Elec.ts <- ts(CBE[, 3], start = 1958, freq = 12)         plot(decompose(Elec.ts, type = \"multi\"))      }"]      and creates this plot: ![enter image description here](http://i.stack.imgur.com/W6FeJ.png) The first part of my attempt to reproduce this in _Mathematica_ is:               url = "http://www.massey.ac.nz/~pscowper/ts/cbe.dat";     CBE = Import[url];     elecTS = TemporalData[CBE[[2 ;; -1, 3]], {{1958}, Automatic, "Month"}];     DateListPlot[elecTS["Path"], Joined -> True, AspectRatio -> 0.2]      ![enter image description here](http://i.stack.imgur.com/x472D.png) How do I continue this to perform the decomposition wholly within _Mathematica_?


Label each panel of Grid

I have a set of figures that I would like to show as grid for a publication. I currently just export the figure as an eps and use another software package to add Labels (A,B,C,D) to each panel of the figure. This is rather tedious to do. Is there a way to label each panel in Mathematica? For example is it possible to label each panel of the following grid?               a = Plot[Sin[x], {x, -Pi, Pi}];          b = Plot[Cos[x], {x, -Pi, Pi}];          c = Plot[ArcSin[x], {x, -Pi, Pi}];          d = Plot[ArcCos[x], {x, -Pi, Pi}];          Grid[{{a, b}, {c, d}}, Spacings -> {1, 2}, Frame -> All]


Find list position and mapping list

Sorry, my English is not very good. I have two lists:               tt = {197, 173, 23, 151, 69, 90, 12, 192, 158, 32, 6, 147, 99,        199, 131, 10, 59, 144, 141, 24, 178, 58, 106, 25, 155, 153}           ii = {{46, 154}, {93, 158}, {125, 214}, {160, 112}, {184, 200}, {203,        137}, {230, 266}, {271, 128}, {317, 153}, {362, 251}, {369,        252}, {385, 136}, {424, 195}, {503, 139}, {538, 181}, {582,        268}, {602, 227}, {621, 108}, {660, 147}, {695, 245}, {739,        132}, {766, 242}, {786, 161}, {822, 239}, {857, 128}, {904, 171}}      I can find elements of list `tt` that are > 150:               Select[tt, # > 150 &]     (*{197, 173, 151, 192, 158, 199, 178, 155, 153}*)      > Q1 : How can I find the positions of these elements in `tt`? I want find answer, such as: location = `{1,2,4,8,9,14,21,25,26}`   or location = `{1,1,0,1,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,1,1}` > Q2 : How can I mapping to the same location to `ii` list which get data? please help me and thank you :)


Manipulating named patterns inside replacement rules

When I evaluate the following expression, ` {a -> "value1", b -> "value22"} /. {Rule[x_, y_] -> Rule[x, y]} ` I get `{a -> "value1", b -> "value2"}`, as expected. But when I evaluate the same expression with a `ToString[]` wrapper around a named pattern, it is no longer recognized as a named pattern: ` {a -> "value1", b -> "value2"} /. {Rule[x_, y_] -> Rule[x, ToString[y]]} ` Result: `{a -> y, b -> y}`. Why is `y` not replaced with the corresponding right-hand side values in replacement rules? How can I fix this?


What's wrong with my rule?

Consider a simple code to form a SparseArray:               Q = 5;     a = Table[i, {i, Q}];     SparseArray[{{j_} /; j > 2 -> a[[j]]}, {Q}]      > Part::pspec: Part specification j is neither a machine-sized integer nor a > list of machine-sized integers. >> What is wrong with the rule? It seems I can not address any matrix element without getting such a warning. Sorry for such a minor question.


How can I avoid this ReplaceAll trap?

I am having some difficulties with the `ReplaceAll` function. When I write:               {1, 2, 3, 4, 5} /. x_?OddQ -> x^2      I expect: > >     {1,2,9,4,25} >   But if I write:               x = 1;     {1, 2, 3, 4, 5} /. x_?OddQ -> x^2      I have: > >     {1,2,1,4,1} >   How can I avoid this? I mean, even using:               x = 1;     Module[{x},{1, 2, 3, 4, 5} /. x_?OddQ -> x^2]      The output still: > >     {1,2,1,4,1} >   Thanks in advance! Edit: Thanks again! I never quite understood this `RuleDelayed`.


Trouble with Replacements

I have the following line of code:               Plus @@ Table[p[x], {x, 0, 20}] /. p[x_] -> Boole[MemberQ[{0, 5}, x]]      The first part of this produces               p[0] + p[1] + p[2] + p[3] + p[4] + p[5] + p[6] + p[7] + p[8] + p[9] + p[10] +     p[11] + p[12] + p[13] + p[14] + p[15] + p[16] + p[17] + p[18] + p[19] + p[20]      What I thought the second part would do is to check each argument to p that occurs in this sum and replace `p[x]` with `1` if `x` is either `0` or `5` and with `0` if `x` is anything else. I thought, in short, the result would be 2. That's not, however, what I get. Instead _Mathematica_ returns 0. What am I doing wrong?


How to randomly select and open a notebook using CDFPlayer

I have a lesson notebook for a class I am teaching. I'd like to separate the lesson content and the practice problems. Students are using the CDFPlayer program, not _Mathematica_. I created a button that will open a specific notebook…               Button[       "open",       NotebookOpen[FileNameJoin[{NotebookDirectory[ButtonNotebook[]], "sample.nb"}]]]      and this works fine in the CDFPlayer. However, selecting a "random" question from a list of files doesn't. Something in my code doesn't work in the free player. (The same code works fine in _Mathematica_ ) This is what I tried:               Button[       "open",       NotebookOpen[RandomChoice[FileNames[{"*.nb"}, {NotebookDirectory[ButtonNotebook[]]}]]]]      I'm wondering if someone could offer a suggestion? I'd like a button that when clicked, will open a notebook from a folder of practice problems, and work in the CDFPlayer. Any suggestions are appreciated. I see (and appreciate) the feedback that the free CDFPlayer is NOT able to open files. So that answers my question...


What is the value Re[Sqrt[1+I*2*x]]?

When I try to evaluate `Re[Sqrt[z]]`, for some values of _Mathematica_ fails to evaluate it. For example,               Re[Sqrt[2 + I*x]]`      > `Re[Sqrt[2 + I x]]` How can I get the real number in `Sqrt[complex number]`?


How to create a button that colors a selected piece of text in a cell?

I use _Mathematica_ 9.0.1 and I want change the color of a selection in a **text** cell using a button. But when I use this code it changes the color of the entire cell.               Row[Button[Graphics[{#, Rectangle[]}, ImageSize -> 20],      SetOptions[NotebookSelection[InputNotebook[]], FontColor -> #], Appearance -> None] & /@         {ColorData["HTML"]["RoyalBlue"], ColorData["HTML"]["OliveDrab"],         RGBColor[0.419608, 0, 0.733333], Black}]      What do I do wrong? It used to work in _Mathematica_ 8 and 9.0.0. I want it to work **exactly like the Text Color command in the Writing Assistant palette** (or the **Format >> Text Color** menu command).


Tuning ParallelMap when IO and computationally bound

I'm currently doing work on processing a number of images taken frame-by-frame from a video. As a result, I have a directory of around 16K PNG images that at most ~300K. That said, I have a routine, `analyze` which I map in the following way:               analyse /@ FileNames[ "captures\\*.png" , nbDir];      `analyse` is a `Module` with calls to a number of image-processing functions that are computationally bound:   * `ColorSeparate`   * `Binarize`   * `ImageCorrelate`   * `ColorNegate`   * `ColorConvert`   * `BitCounts`   * Possibly some mask operations using `ImageAdd`, `ImageMultiply` and `Dilation`   * Assembling the images using `ImageAssemble` That said, I'm heavily computationally bound for the the process I perform on each image, but also heavily disk/IO bound because there are so many images. To that end, I've started using `ParallelMap` like so:               ParallelMap[analyse, FileNames["captures\\*.png" , nbDir]];      However, I know of the `Method` parameter which allows one to specify just _how much_ parallelization should take place in `ParallelMap`. My gut instinct here is to go with the `CoarsestGrained` option for the `Method` parameter but I can't really put together why the approach would be valid (or invalid, if it were not). For this situation, what approach can I take to tune this call to `ParallelMap` in order to get the best performance (to be specific, I'd like it to be done as soon as possible, with a disregard for resource consumption if sacrifices are to be made).


Maximum of Minimum of a two variable function

I have               F[x, y] := (y/2)(2 Cos[2x] + 2 Cos[x] + 1)/5 + ((1 - y)/2)(2 Cos[x] + 1)/3.      I am looking for the maximum of the minimum of `F`. More precisely I am looking for $$\underset{0\leq y\leq 1}{Maximum} \left(\underset{x\in [0,2\pi]}{Minimum} F(x,y)\right).$$ I typed `Findminimum / FindMaximum` together into _Mathematica_ , but that did not work. I now feel that I need more advanced tools to make it work. The answer for my example is -1/9.


Arrows on axes in Plot3D

I use the following code to draw arrows on arrows in 2D graphics:               Plot[Sin[x],{x,-10,10},AxesStyle->Arrowheads[Automatic]]      But such code doesn't work with `Plot3D[…]` and 3D graphics. Is there any way to get axes with arrows on 3D graphics?


Fitting fractional complex data with NonlinearModelfit

I've difficulites with the `NonlinearModelFit` function. In principle Mathematica should be able to deal with complex data. E.g. if I define the following table               set = Table[{i, (3*i^2*I + 1*I)}, {i, 0, 10}]      and perform `NonlinearModelFit`, Mathematica has no problem finding the right values               NonlinearModelFit[set, (a + b*x^2*I), {a, b}, x]     (* {a -> 0. + 1. I, b -> 3. + 0. I} *)      But I need to fit some fractional functions, so I tried to fit just the inverse of the above set of data (I don't change any syntax, besides putting `1/` in front)               set = Table[{i, 1/(3*i^2*I + 1*I)}, {i, 0, 10}]     NonlinearModelFit[set, 1/(a + b*x^2*I), {a, b}, x]      Then Mathematica comes up with an error:               FindFit::nrlnum: The function value {1.-1. I,0.5-4.5 I,<<7>>,0.000152393-244.012 I,     <<1>>} is not a list of real numbers with dimensions {11} at {a,b} = {1.,1.}. >>      So now I'm confused- there is no syntax or misspelling problem – is Mathematica just not able to perform such a fractional fit? Or are there any mathematical restrictions, which I have not considered? I'm using Mathematica 7.


X3D Export - adding a title

Is there a way to add a title to an X3D (3D) plot that is exported using `Export[]`? I didn't have much success with exporting a `Text[]` into an X3D file. I also know that X3D files have several properties (meta tags) that could be helpful, but I don't know how to specify them in the `Export[]` command.               plot = Plot3D[x^2 + y^2, {x, -2, 2}, {y, -2, 2}, PlotLabel -> "MyPlot"];     scaledPlot = plot /. Graphics3D[gr_, opts___] ->         Graphics3D[GeometricTransformation[gr, ScalingTransform[{1, 1, 0.5}]], opts];     Export["plot.x3d", Show[scaledPlot, Graphics3D[Text["MyPlot"]]]]


Quartic equation

After using Solve I am choosing the physical root of my equation and dealing further with this root. However, when I am changing parameters using Manipulate, I clearly see not smooth behaviour. Is there a way to cure it? I think, there should be a way of controlling the branch of the square root by adding $\pm i0$.


Difficulties with Importing PDFs in Mathematica

I am trying to import a group of PDFs that I have downloaded (it is in the realm of 1,000+). They are a group of doctoral dissertations that I'm trying to automatically extract bibliographic information from. They open perfectly in Preview and Adobe Acrobat Reader. Unfortunately, when I go to `Import[]` them, I receive the following errors like so:               Import["1997-01.pdf","Elements"]          Import::general: Expected cross reference table >>     Import::general: Expected cross reference table >>     Import::general: Could not find document trailer >>     General::stop: Further output of Import::general will be suppressed during this calculation. >>      I have never encountered this with `Elements` before, which is normally my first step in figuring out how to tackle a file. The same holds for `Plaintext`, etc. If I `Import["1997-01.pdf","Text"]` it generates a file akin to this:               %PDF-1.2     %BHIL-SC:0014503155,00391,00004,00008,00399,00790,00004,00004,00009,00400,00791,00004,00004,00010,00401,00792,00004 ... etc. etc.      The file itself is downloaded from an online repository, however, but is of high quality. ![enter image description here](http://i.stack.imgur.com/YZxnx.png) My end goal is to try `TextRecognize[]` on it, but I cannot even get to that stage. Does _Mathematica_ offer any workarounds for PDFs like this? FWIW, the PDF claims that I have full permissions to edit, alter, etc., but there is no built-in text layer. --- Edited to Clarify --- The PDF is version 1.2. It is an image layer, not a text layer. Hope that this helps!


Custom Format for "constructors"

Say I have a the typical Mathematica linked list structure defined like so:               Attributes[Pair] = {HoldAllComplete};          Nil = Pair[];          Cons = Pair[#1, #2]&;      It's well-known that turning a regular `List` into a linked list is easy:               ToLinkedList[list_List] := Fold[Cons[#2, #1]&, Nil, Reverse@list];      With some caveats that aren't relevant to this problem, converting back to a regular list is even easier:               Pair /: Normal[p_Pair] := List @@ Flatten[p];      We can use this to make a "constructor":               LinkedList[args___] := ToLinkedList@{args};      Right now, the output looks pretty terrible               In[43]:= ToLinkedList@{1, 2, 3}     Out[43]= Pair[1, Pair[2, Pair[3, Pair[]]]]      It would be really nice if we could have output that looks like `LinkedList[1, 2, 3]` instead. Attempts to do simple things with `Format` have provided me with no joy. For instance this looks great:               Format[p : Pair[_, _]] :=       Row[{"LinkedList", "[", Row[p // Normal, ","], "]"}, BaseStyle -> "Output"];     Format[Nil] := Row[{"Nil"}, BaseStyle -> "Output"]          In[45]:= LinkedList[1, 2, 3]     Out[45]= LinkedLits[1, 2, 3]      But it completely falls apart when you try to copy and paste. Indeed, I had to type the stuff after `Out` by hand, because when I tried to paste into the text area, what actually showed up was:               Row[{"LinkedList", "[", Row[{1, 2, 3}, ","], "]"},       BaseStyle -> "Output"]      This was not really what I wanted. Cutting and pasting inside a notebook appears to work OK, but when I try to evaluate a pasted expression as input, I get awful stuff like this:               MakeExpression::boxfmt: InputForm in MakeExpression[FormBox[RowBox[{Row,[,RowBox[{RowBox[{<<3>>}],,,RowBox[{<<3>>}]}],]}],InputForm],InputForm] is not a box formatting type. A box formatting type is any member of $BoxForms. >>      I know I could use `MakeBoxes` to do what I want, but that only works for `StandardForm` or `TraditionalForm`, and this seems like a perfectly sensible textual representation. I have a feeling I'm using `Format` _completely wrong_ , but I'm not sure what using it right looks like. **EDIT** in response to rcollyer: I have tried the `Notation`` package, but it's box-oriented, and I can't figure out how to flatten out the `Pair` structures for outputting inside the `LinkedList`. **EDIT** again in response to ruebenko: you're right; it's been fixed. **EDIT** to fix an arguable bug in the implementation of `Normal` for `Pair`s, discovered while playing around trying to create a custom format. As it stands right now:               In[49]:= LinkedList[LinkedList[1, 2], LinkedList[3, 4], LinkedList[5, 6]]     Out[49]= LinkedList[1, 2, 3, 4, 5, 6]      I don't want this auto-flattening behavior for `Normal` in any event, but it's particularly terrible in the case of formatting output because the output is totally wrong. Here's a fix:               FromLinkedList[list_Pair] :=       NestWhileList[List @@ #[[2]] &, {Null, list}, #[[2]] =!= Nil &][[2 ;;, 1]];          Pair /: Normal[p_Pair] := List @@ FromLinkedList[p]      This is a bit uglier, especially that `Null` placeholder at the beginning, but it does the right thing:               In[63]:= LinkedList[LinkedList[1, 2], LinkedList[3, 4], LinkedList[5, 6]]     Out[63]= LinkedList[LinkedList[1, 2], LinkedList[3, 4], LinkedList[5, 6]]      It's the best I could come up with; other solutions involved `Reap` and `Sow`, which seemed like a real shame when working with a nice functional data structure like this one.


How to constrain memory usage on HPC?

I found the performance of built-in function `MemoryConstrained` is very poor. It stops the evaluation after the memory limit has already been exceeded greatly than the values I set. There are several other questions on how to constrain memory usage during an evaluation. For example, this one. But the method seems not working for parallel situation(for example, if you perform`ParallelTable`), because `MemoryInUse` is specific to each kernel. No bother, there is another way, that is use Jlink to get the system's free physical memory information( see here ). So I combined these two method. Reach the following code:               Needs["JLink`"];     InstallJava[];     LoadJavaClass["java.lang.management.ManagementFactory"];     intervalBetweenTests = 1;     RunScheduledTask[If[(         JavaBlock[          java`lang`management`ManagementFactory`getOperatingSystemMXBean[]\     @#[] &@getFreePhysicalMemorySize]) < 1*1024^3,        Quit[]], intervalBetweenTests]      **After running this code, mathematica launch a watchdog, and any evaluation (no matter parallel or not) will be aborted if the free physical memory in current machine is below 1GB.** The code just mentioned works on a single machine. But I have to work on HPC, every parallel evaluation is performed on several different machine simultaneously, and **I have to make sure that free physical memory won't below a threshold on every machine I use during a parallel evaluation** , otherwise the machine will be dead, the admin will be very unhappy and mad about me:) I tried `ParallelEvaluate` the above code, intended to launch watchdogs on all available kernels. That is               ParallelEvaluate[Needs["JLink`"];     InstallJava[];     LoadJavaClass["java.lang.management.ManagementFactory"];     intervalBetweenTests = 1;     RunScheduledTask[If[(     JavaBlock[     java`lang`management`ManagementFactory`getOperatingSystemMXBean[]\     @#[] &@getFreePhysicalMemorySize]) < 1*1024^3,      Quit[]], intervalBetweenTests]]      but didn't work. **The above code output a list of same ScheduledTask object, and evaluate`ScheduledTasks[]` shows no running scheduledtask at all**. And of course the The free physical memory is not constrained as expected when doing calculation. **questions:**   1. it seems that `RunScheduledTask` can't been parallelized, is that true?    2. why built-in function `MemoryConstrained` is so poor?   3. finally, **how to achieve memory control across machines in mathemaica**? * * * **edit** as OleksandrR said, an HPC usually equipped with a job management system, it provide resource control of the job. for example in PBS job system, `pmem` can constrain the memory usage per process of a job. **But to constrain memory usage inside mathematica itself is much more adaptive**. There are cases   1. some small cluster doesn't equipped with a job management system   2. the way to use the HPC is variable. Very often we can use mathemaica interactively on HPC by submitting an interactive PBS job, and if the pmem is set at the beginning, then all the calculations doing in this interactive job is restricted per process, while we should have been able to use more memory if we didn't set the pmem when submit the job. and other cases you can think of, but I think these two is enough.


Fitting data set with series expansion

I have a function given in a form of a list: > ScalarField={{$\epsilon$,$y_1$},..{1,$y_{3000}$}} It is defined in the range $(\epsilon,1)$ (spacing between grid points is homogeneous), where $\epsilon=10^{-5}$, and I know that as $z\rightarrow \epsilon$ it behaves as > $y(z)\sim C1\cdot z^5+C2\cdot z^7+B1\cdot z^{7.2}+C3\cdot z^{9}+B2\cdot > z^{9.2}+...$ So, its series expansion contains integer valued powers $5+2k$ and fractional valued powers $7.2+2k$, $k=0...\infty$. I need to know first three coefficients in this expansion - $C1,\,C2,\,B1$. Standard fitting procedure can give me precise value for $C1$, reasonable $C2$, but $B1$ is highly fluctuating and strongly dependent on the number of points near the left boundary of the interval that I use for fit. Does anybody know how $B1$ can be extracted? Thank you in advance! Andrey **UPD!** Before coming to the real data set, which contains some extra numerical uncertainties, let's analyze simpler case. The following list has asymptotic behaviour $A1\cdot z^5+A2\cdot z^7+A3\cdot z^9+...$ near zero. How to extract A3? > {{1/100000, -8.53187*10^-25}, {51499/ 149950000, -1.60222*10^-17}, {202997/ > 299900000, -4.76459*10^-16}, {75749/ 74975000, -3.52989*10^-15}, {80599/ > 59980000, -1.46917*10^-14}, {251497/ 149950000, -4.45028*10^-14}, {602993/ > 299900000, -1.10188*10^-13}, {43937/ 18743750, -2.37313*10^-13}, {802991/ > 299900000, -4.61446*10^-13}, {90299/ 29990000, -8.29812*10^-13}, {1002989/ > 299900000, -1.40295*10^-12}, {275747/ 74975000, -2.25638*10^-12}, {1202987/ > 299900000, -3.48225*10^-12}, {651493/ 149950000, -5.19099*10^-12}, {280597/ > 59980000, -7.51297*10^-12}, {187873/ 37487500, -1.06002*10^-11}, {1602983/ > 299900000, -1.46279*10^-11}, {851491/ 149950000, -1.97962*10^-11}, {1802981/ > 299900000, -2.63319*10^-11}, {95149/ 14995000, -3.44898*10^-11}, {2002979/ > 299900000, -4.45549*10^-11}, {1051489/ 149950000, -5.68435*10^-11}, > {2202977/ 299900000, -7.17052*10^-11}, {71968/ 9371875, -8.95242*10^-11}, > {96119/ 11996000, -1.10721*10^-10}, {1251487/ 149950000, -1.35756*10^-10}, > {2602973/ 299900000, -1.65126*10^-10}, {675743/ 74975000, -1.99373*10^-10}, > {2802971/ 299900000, -2.39079*10^-10}, {290297/ 29990000, -2.84873*10^-10}, > {3002969/ 299900000, -3.37429*10^-10}, {387871/ 37487500, -3.9747*10^-10}, > {3202967/ 299900000, -4.65768*10^-10}, {1651483/ 149950000, > -5.43146*10^-10}, {680593/ 59980000, -6.30481*10^-10}, {875741/ 74975000, > -7.28704*10^-10}, {3602963/ 299900000, -8.38804*10^-10}, {1851481/ > 149950000, -9.61825*10^-10}, {3802961/ 299900000, -1.09887*10^-9}, {48787/ > 3748750, -1.25111*10^-9}, {4002959/ 299900000, -1.41978*10^-9}, {2051479/ > 149950000, -1.60615*10^-9}, {4202957/ 299900000, -1.81161*10^-9}, {1075739/ > 74975000, -2.03757*10^-9}, {880591/ 59980000, -2.28553*10^-9}, {2251477/ > 149950000, -2.55705*10^-9}, {4602953/ 299900000, -2.85378*10^-9}, {587869/ > 37487500, -3.17744*10^-9}, {4802951/ 299900000, -3.5298*10^-9}, {98059/ > 5998000, -3.91275*10^-9}, {5002949/ 299900000, -4.32822*10^-9}, {1275737/ > 74975000, -4.77825*10^-9}, {5202947/ 299900000, -5.26495*10^-9}, {2651473/ > 149950000, -5.79051*10^-9}, {1080589/ 59980000, -6.35722*10^-9}, {171967/ > 9371875, -6.96743*10^-9}, {5602943/ 299900000, -7.62361*10^-9}, {2851471/ > 149950000, -8.32831*10^-9}, {5802941/ 299900000, -9.08417*10^-9}, {295147/ > 14995000, -9.89392*10^-9}, {6002939/ 299900000, -1.07604*10^-8}, {3051469/ > 149950000, -1.16865*10^-8}, {6202937/ 299900000, -1.26753*10^-8}, {787867/ > 37487500, -1.37299*10^-8}, {1280587/ 59980000, -1.48535*10^-8}, {3251467/ > 149950000, -1.60495*10^-8}, {6602933/ 299900000, -1.73212*10^-8}, {1675733/ > 74975000, -1.86723*10^-8}, {6802931/ 299900000, -2.01064*10^-8}, {690293/ > 29990000, -2.16272*10^-8}, {7002929/ 299900000, -2.32386*10^-8}, {443933/ > 18743750, -2.49446*10^-8}, {7202927/ 299900000, -2.67493*10^-8}, {3651463/ > 149950000, -2.86569*10^-8}, {296117/ 11996000, -3.06718*10^-8}, {1875731/ > 74975000, -3.27984*10^-8}, {7602923/ 299900000, -3.50412*10^-8}, {3851461/ > 149950000, -3.7405*10^-8}, {7802921/ 299900000, -3.98947*10^-8}, {197573/ > 7497500, -4.2515*10^-8}, {8002919/ 299900000, -4.52712*10^-8}, {4051459/ > 149950000, -4.81685*10^-8}, {8202917/ 299900000, -5.12121*10^-8}, {2075729/ > 74975000, -5.44075*10^-8}, {1680583/ 59980000, -5.77604*10^-8}, {4251457/ > 149950000, -6.12764*10^-8}, {8602913/ 299900000, -6.49615*10^-8}, {271966/ > 9371875, -6.88217*10^-8}, {8802911/ 299900000, -7.2863*10^-8}, {890291/ > 29990000, -7.70918*10^-8}, {9002909/ 299900000, -8.15146*10^-8}, {2275727/ > 74975000, -8.61378*10^-8}, {9202907/ 299900000, -9.09683*10^-8}, {4651453/ > 149950000, -9.60129*10^-8}, {1880581/ 59980000, -1.01279*10^-7}, {1187863/ > 37487500, -1.06773*10^-7}, {9602903/ 299900000, -1.12503*10^-7}, {4851451/ > 149950000, -1.18475*10^-7}, {9802901/ 299900000, -1.24699*10^-7}, {99029/ > 2999000, -1.31181*10^-7}, {10002899/ 299900000, -1.3793*10^-7}, {5051449/ > 149950000, -1.44953*10^-7}, {10202897/ 299900000, -1.5226*10^-7}, {643931/ > 18743750, -1.59857*10^-7}, {2080579/ 59980000, -1.67755*10^-7}, {5251447/ > 149950000, -1.75962*10^-7}, {10602893/ 299900000, -1.84486*10^-7}, {2675723/ > 74975000, -1.93337*10^-7}, {10802891/ 299900000, -2.02524*10^-7}, {1090289/ > 29990000, -2.12056*10^-7}, {11002889/ 299900000, -2.21944*10^-7}, {1387861/ > 37487500, -2.32196*10^-7}, {11202887/ 299900000, -2.42824*10^-7}, {5651443/ > 149950000, -2.53836*10^-7}, {2280577/ 59980000, -2.65244*10^-7}, {2875721/ > 74975000, -2.77058*10^-7}, {11602883/ 299900000, -2.89288*10^-7}, {5851441/ > 149950000, -3.01946*10^-7}, {11802881/ 299900000, -3.15043*10^-7}, {74393/ > 1874375, -3.28589*10^-7}, {12002879/ 299900000, -3.42597*10^-7}, {6051439/ > 149950000, -3.57078*10^-7}, {12202877/ 299900000, -3.72044*10^-7}, {3075719/ > 74975000, -3.87506*10^-7}, {99223/ 2399200, -4.03478*10^-7}, {6251437/ > 149950000, -4.19971*10^-7}, {12602873/ 299900000, -4.36998*10^-7}, {1587859/ > 37487500, -4.54572*10^-7}, {12802871/ 299900000, -4.72706*10^-7}, {1290287/ > 29990000, -4.91413*10^-7}, {13002869/ 299900000, -5.10707*10^-7}, {3275717/ > 74975000, -5.30601*10^-7}, {13202867/ 299900000, -5.51109*10^-7}, {6651433/ > 149950000, -5.72246*10^-7}, {2680573/ 59980000, -5.94024*10^-7}, {843929/ > 18743750, -6.16459*10^-7}, {13602863/ 299900000, -6.39566*10^-7}, {6851431/ > 149950000, -6.63359*10^-7}, {13802861/ 299900000, -6.87854*10^-7}, {695143/ > 14995000, -7.13065*10^-7}, {14002859/ 299900000, -7.39009*10^-7}, {7051429/ > 149950000, -7.65701*10^-7}, {14202857/ 299900000, -7.93157*10^-7}, {1787857/ > 37487500, -8.21393*10^-7}, {2880571/ 59980000, -8.50426*10^-7}, {7251427/ > 149950000, -8.80272*10^-7}, {14602853/ 299900000, -9.10949*10^-7}, {3675713/ > 74975000, -9.42473*10^-7}, {14802851/ 299900000, -9.74862*10^-7}, {298057/ > 5998000, -1.00813*10^-6}, {15002849/ 299900000, -1.0423*10^-6}, {471964/ > 9371875, -1.07739*10^-6}, {15202847/ 299900000, -1.11342*10^-6}, {7651423/ > 149950000, -1.1504*10^-6}, {3080569/ 59980000, -1.18836*10^-6}, {3875711/ > 74975000, -1.22731*10^-6}, {15602843/ 299900000, -1.26727*10^-6}, {7851421/ > 149950000, -1.30826*10^-6}, {15802841/ 299900000, -1.3503*10^-6}, {397571/ > 7497500, -1.39341*10^-6}, {16002839/ 299900000, -1.43762*10^-6}, {8051419/ > 149950000, -1.48293*10^-6}, {16202837/ 299900000, -1.52938*10^-6}, {4075709/ > 74975000, -1.57698*10^-6}, {3280567/ 59980000, -1.62576*10^-6}, {8251417/ > 149950000, -1.67573*10^-6}, {16602833/ 299900000, -1.72692*10^-6}, {1043927/ > 18743750, -1.77936*10^-6}, {16802831/ 299900000, -1.83305*10^-6}, {1690283/ > 29990000, -1.88802*10^-6}, {17002829/ 299900000, -1.94431*10^-6}, {4275707/ > 74975000, -2.00192*10^-6}, {17202827/ 299900000, -2.06089*10^-6}, {8651413/ > 149950000, -2.12124*10^-6}, {696113/ 11996000, -2.18299*10^-6}, {2187853/ > 37487500, -2.24616*10^-6}, {17602823/ 299900000, -2.31078*10^-6}, {8851411/ > 149950000, -2.37687*10^-6}, {17802821/ 299900000, -2.44447*10^-6}, {895141/ > 14995000, -2.51359*10^-6}, {18002819/ 299900000, -2.58425*10^-6}, {9051409/ > 149950000, -2.6565*10^-6}, {18202817/ 299900000, -2.73034*10^-6}, {571963/ > 9371875, -2.80581*10^-6}, {3680563/ 59980000, -2.88294*10^-6}, {9251407/ > 149950000, -2.96174*10^-6}, {18602813/ 299900000, -3.04226*10^-6}, {4675703/ > 74975000, -3.1245*10^-6}, {18802811/ 299900000, -3.20852*10^-6}, {1890281/ > 29990000, -3.29432*10^-6}, {19002809/ 299900000, -3.38194*10^-6}, {2387851/ > 37487500, -3.47141*10^-6}, {19202807/ 299900000, -3.56275*10^-6}, {9651403/ > 149950000, -3.656*10^-6}, {3880561/ 59980000, -3.75119*10^-6}, {4875701/ > 74975000, -3.84834*10^-6}, {19602803/ 299900000, -3.94748*10^-6}, {9851401/ > 149950000, -4.04865*10^-6}, {19802801/ 299900000, -4.15187*10^-6}, {49757/ > 749750, -4.25718*10^-6}, {20002799/ 299900000, -4.36461*10^-6}, {10051399/ > 149950000, -4.47419*10^-6}, {20202797/ 299900000, -4.58595*10^-6}, {5075699/ > 74975000, -4.69992*10^-6}, {4080559/ 59980000, -4.81613*10^-6}, {10251397/ > 149950000, -4.93463*10^-6}, {20602793/ 299900000, -5.05543*10^-6}, {2587849/ > 37487500, -5.17858*10^-6}, {20802791/ 299900000, -5.3041*10^-6}, {2090279/ > 29990000, -5.43204*10^-6}, {21002789/ 299900000, -5.56242*10^-6}, {5275697/ > 74975000, -5.69529*10^-6}, {21202787/ 299900000, -5.83067*10^-6}, {10651393/ > 149950000, -5.96859*10^-6}, {4280557/ 59980000, -6.10911*10^-6}, {671962/ > 9371875, -6.25224*10^-6}, {21602783/ 299900000, -6.39804*10^-6}, {10851391/ > 149950000, -6.54652*10^-6}, {21802781/ 299900000, -6.69774*10^-6}, {1095139/ > 14995000, -6.85172*10^-6}, {22002779/ 299900000, -7.00851*10^-6}, {11051389/ > 149950000, -7.16815*10^-6}, {22202777/ 299900000, -7.33066*10^-6}, {2787847/ > 37487500, -7.49609*10^-6}, {896111/ 11996000, -7.66448*10^-6}, {11251387/ > 149950000, -7.83587*10^-6}, {22602773/ 299900000, -8.01029*10^-6}, {5675693/ > 74975000, -8.18779*10^-6}, {22802771/ 299900000, -8.3684*10^-6}, {2290277/ > 29990000, -8.55217*10^-6}, {23002769/ 299900000, -8.73914*10^-6}, {1443923/ > 18743750, -8.92935*10^-6}, {23202767/ 299900000, -9.12283*10^-6}, {11651383/ > 149950000, -9.31964*10^-6}, {4680553/ 59980000, -9.5198*10^-6}, {5875691/ > 74975000, -9.72338*10^-6}, {23602763/ 299900000, -9.9304*10^-6}, {11851381/ > 149950000, -0.0000101409}, {23802761/ 299900000, -0.000010355}, {597569/ > 7497500, -0.0000105726}, {24002759/ 299900000, -0.0000107938}, {12051379/ > 149950000, -0.0000110187}, {24202757/ 299900000, -0.0000112474}, {6075689/ > 74975000, -0.0000114798}, {4880551/ 59980000, -0.0000117159}, {12251377/ > 149950000, -0.000011956}, {24602753/ 299900000, -0.0000121999}, {771961/ > 9371875, -0.0000124478}, {24802751/ 299900000, -0.0000126996}, {99611/ > 1199600, -0.0000129555}, {25002749/ 299900000, -0.0000132155}, {6275687/ > 74975000, -0.0000134795}, {25202747/ 299900000, -0.0000137478}, {12651373/ > 149950000, -0.0000140203}, {5080549/ 59980000, -0.0000142971}, {3187843/ > 37487500, -0.0000145782}, {25602743/ 299900000, -0.0000148637}, {12851371/ > 149950000, -0.0000151536}, {25802741/ 299900000, -0.0000154479}, {1295137/ > 14995000, -0.0000157468}, {26002739/ 299900000, -0.0000160503}, {13051369/ > 149950000, -0.0000163584}, {26202737/ 299900000, -0.0000166712}, {1643921/ > 18743750, -0.0000169887}, {5280547/ 59980000, -0.000017311}, {13251367/ > 149950000, -0.0000176382}, {26602733/ 299900000, -0.0000179702}, {6675683/ > 74975000, -0.0000183072}, {26802731/ 299900000, -0.0000186491}, {2690273/ > 29990000, -0.0000189962}, {27002729/ 299900000, -0.0000193483}, {3387841/ > 37487500, -0.0000197056}, {27202727/ 299900000, -0.0000200681}, {13651363/ > 149950000, -0.0000204359}, {1096109/ 11996000, -0.000020809}, {6875681/ > 74975000, -0.0000211876}, {27602723/ 299900000, -0.0000215715}, {13851361/ > 149950000, -0.000021961}, {27802721/ 299900000, -0.000022356}, {174392/ > 1874375, -0.0000227566}, {28002719/ 299900000, -0.000023163}, {14051359/ > 149950000, -0.000023575}, {28202717/ 299900000, -0.0000239929}, {7075679/ > 74975000, -0.0000244166}, {5680543/ 59980000, -0.0000248462}, {14251357/ > 149950000, -0.0000252818}, {28602713/ 299900000, -0.0000257234}, {3587839/ > 37487500, -0.0000261712}, {28802711/ 299900000, -0.0000266251}, {2890271/ > 29990000, -0.0000270852}, {29002709/ 299900000, -0.0000275516}, {7275677/ > 74975000, -0.0000280243}, {29202707/ 299900000, -0.0000285035}, {14651353/ > 149950000, -0.0000289891}, {5880541/ 59980000, -0.0000294813}, {1843919/ > 18743750, -0.0000299801}, {29602703/ 299900000, -0.0000304855}, {14851351/ > 149950000, -0.0000309977}, {29802701/ 299900000, -0.0000315167}, > {299027/2999000, -0.0000320425}}


Order/Dependency of Styles in a Stylesheet

How exactly is a custom stylesheet processed? Which style depends on (inherits from) which other style. Consider e.g. setting a font. I would expect that setting the font for "Section" to YY after setting the font for "All" to XX would result in the font being YY for Sections and XX for everything else, but the "All" overrides it. For "Text" and "Section" its works as expected. "All" seems to be a global override (at least for the `FontFamily`. Can someone clarify this?


May I restrict caching to disk when memory runs low?

An hour ago, I had to hard reset my laptop again because Mathematica froze the system again. When import a large file or make a mistake that produces huge arrays with complicated entries etc., I often see that the system becomes unresponsive. Holding the power button for seconds seems to be the only solution. I was forced to do so about 20 times in recent 3 months, because of a project I was working at. Today, chkdsk had to start already when Windows was starting which I think is creepy. No errors found on the disk, thank God. Is there a way to constrain this behavior so that it doesn't become hopeless? Some setting which makes Mathematica say "I give up, low memory" instead of doing the impossible and suicidal caching?


hat not big enough

I like to use Mathematica text cells for creating draft technical documents. When entering equations in a text cell, the ^ (hat accent) does not dynamically adjust its size to fit. It looks good if you enter x^, but if you wanted abc^, the ^ covers only the b. Anyone know how to make the ^ (and other accents) adjust to the size of the text?


How to create a plot of the volume between three surfaces

I need help creating a plot that I can manipulate the variables for the volume between three surfaces. I am trying to make it look like this example here: http://demonstrations.wolfram.com/ExploringCylindricalCoordinates/ but with the volume I need. It is volume that lies within the cylinder x^2+y^2=1, above the plain z=0 ,and below the cone z^2=4x^2+4y^2. I converted to cylindrical coordinates (z,r,theta). Here is what I have so far.:               Show[RevolutionPlot3D[2 r, {r, 0, 1}, {theta, 0, Pi}],       ParametricPlot3D[{Cos[u], Sin[u], v}, {u, 0, Pi}, {v, 0, 2}]]      thank you


How to get a plot generated by R returned in an output cell?

It seems we'll never have built in two axis plots and list plots in Mathematica but you can make them in R.               Needs["RLink`"]     InstallR[];     REvaluate["{      x <- 1:5      y1 <- rnorm(5)      y2 <- rnorm(5,20)      par(mar=c(5,4,4,5)+.1)      plot(x,y1,type=\"l\",col=\"red\")      par(new=TRUE)      plot(x,y2,,type=\"l\",col=\"blue\",xaxt=\"n\",yaxt=\"n\",xlab=\"\",\ ylab=\"\")      axis(4)      mtext(\"y2\",side=4,line=3)      legend(\"topleft\",col=c(\"red\",\"blue\"),lty=1,legend=c(\"y1\",\"\     y2\"))}"]      Which returns this plot in a popup window: ![enter image description here](http://i.stack.imgur.com/SGj64.png) How can I get the plot that is generated from this code to appear in an `Output` cell?


How could I add arrows to the axis of a figure?

It is easy for me to add arrows to the axes of the a figure by taking advantage of `AxesStyle -> Arrowheads[]` when the differences between the horizontal and vertical coordinates is small. For instance, by using               Plot[1/x, {x, -20, 20}, AxesStyle -> Arrowheads[{0.0, 0.03}]]      the arrows appear at both the horizontal and vertical axis. However, I don't know how to add arrows to the ones whose differences are big. For example, when the following program is run               Plot[1/x^5, {x, -20, 20}, AxesStyle -> Arrowheads[{0.0, 0.00003}]]      the arrows cannot be seen obviously? I want to know how I can make the arrows to be found evidently just as the previous one?


Faster code for specific problem

Sorry, but I need the following code much faster and I'm running out of ideas. I do appreciate any help. I post two of my fastest ideas (tab and mat), although they are not really fast. Thanks in advance.               Clear[bNum,nNum,weights,newMat,sortMat,tab];          bNum=20;     nNum=100;          weights=Table[RandomReal[{-10,10}],{b,1,bNum},{n,1,nNum}];     newMat=Table[RandomReal[{-10,10}],{b,1,bNum},{n,1,nNum}];     sortMat=Table[i,{i, -10, 10, 0.1}];          tab=Table[     Sum[weights[[k,i]]*If[newMat[[k,i]] <= sortMat[[j]],1.,0.],{i,1,nNum}],{k,1,bNum},      {j,1,Length[sortMat]}];//AbsoluteTiming          mat=Block[{k=1},     Reap[Do[     Sow[Table[Sum[weights[[k,i]]*If[newMat[[k,i]] <= sortMat[[j]],1.,0.],{i,1,nNum}],{j,1,Length[sortMat]}]];     k++,{bNum}]]][[2,1]];//AbsoluteTiming


Skip one step of the loop if there is an NIntegrate::eincr message

Is there a possibility of skipping one step of a loop if in this step there appears an error like `NIntegrate::eincr`? After skipping, the loop should go to the next step and continue evaluation.


Ticks disappear in Graphics3D with Epilog

Normally, you can enable `Graphics3D` to show tick marks by doing this:               Graphics3D[Sphere[], Axes -> True]      ![ticks](http://i.stack.imgur.com/XQkj4.png) But in _Mathematica_ version **10** , when I add an `Inset` which contains a `Grid` or `Column`, the output looks wrong:               Graphics3D[Sphere[], Axes -> True,      Epilog -> Inset[Column[{"a"}], {.05, .05}]]      ![no ticks](http://i.stack.imgur.com/NaiIC.png) The ticks only appear when I manually rotate the graphics or start editing the input line. But note that I produced the enclosed images here by doing `Export["file.png",%]` after each plot, so that this faulty display is indeed not just a notebook display problem - it leads to incorrectly exported graphics, too. This doesn't appear to happen when the inset contains a `Row` instead of `Column`. I also see this strange behavior when doing something like this:               Plot3D[1, {x, -1, 1}, {y, -1, 1},      Epilog -> Inset[Column[{"a"}], {.05, .05}]]      ![partial ticks](http://i.stack.imgur.com/wKTTd.png) Here, you can see that the tick marks are displayed only _partially_! My operating system is Mac OS X 10.8.5, and I am wondering if this is reproducible on other systems. If so, it would be nice to know how to work around this problem. The issue also goes away when the `Inset` only contains numbers and not strings. **Edit** I've reported this as a bug (CASE:1384605).


Problem with SARIMA Time Series Model

I'm in the process of becoming familiar with some on the version 10 new functionality. I have two data sets, datasetA and datasetC, of time series data that I would like to make forecasts on. Here is datasetA.               datasetA = {{0., 16.2}, {0.5, 20.}, {1., 19.}, {1.5, 28.5}, {2.,      17.8}, {2.5, 23.3}, {3., 19.9}, {3.5, 13.5}, {4., 20.1}, {4.5,      11.8}, {5., 29.8}, {5.5, 26.9}, {6., 32.3}, {6.5, 16.5}, {7.,      31.7}, {7.5, 24.2}, {8., 37.1}, {8.5, 25.9}, {9., 28.1}, {9.5,      35.6}, {10., 27.4}, {10.5, 30.4}, {11., 29.4}, {11.5, 29.3}, {12.,      29.4}, {12.5, 29.1}, {13., 31.4}, {13.5, 24.}, {14.,      30.9}, {14.5, 43.1}, {15., 28.7}, {15.5, 38.8}, {16.,      37.9}, {16.5, 34.8}, {17., 26.5}, {17.5, 44.4}, {18.,      39.2}, {18.5, 44.6}, {19., 26.9}, {19.5, 51.1}, {20., 34.}, {20.5,      42.6}, {21., 38.7}, {21.5, 45.1}, {22., 56.}, {22.5, 54.3}, {23.,      47.7}, {23.5, 48.6}, {24., 48.4}, {24.5, 47.1}, {25.,      45.4}, {25.5, 44.7}, {26., 35.7}, {26.5, 36.6}, {27.,      52.8}, {27.5, 56.6}, {28., 60.8}, {28.5, 58.4}, {29.,      52.7}, {29.5, 49.1}, {30., 44.8}};      And here is my attempt at modeling it with a SARIMA time series model, with the corresponding plot of the above data and a 30 day forecast.               tsmA = TimeSeriesModelFit[datasetA, {"SARIMA", Automatic}]     plot2 = ListLinePlot[{tsmA["TemporalData"],      TimeSeriesForecast[tsmA, {70}]}, Frame -> True,      FrameLabel -> {"Time (days)", "Output"},      PlotLabel -> "Plot 2 \nModel: tsmA with Forecast",      PlotLegends -> {"data", "forecast"}]      ![enter image description here](http://i.stack.imgur.com/jQ7Bb.jpg) So far so good as this forecast looks reasonable. Here is datasetC, my attempt at modeling it and its forecast.               datasetC = {{0., 25.2}, {0.5, 18.4}, {1., 22.1}, {1.5, 21.5}, {2.,      20.7}, {2.5, 33.}, {3., 15.3}, {3.5, 24.4}, {4., 33.7}, {4.5,      37.4}, {5., 31.8}, {5.5, 23.5}, {6., 30.2}, {6.5, 24.6}, {7.,      21.1}, {7.5, 27.7}, {8., 35.5}, {8.5, 29.3}, {9., 34.1}, {9.5,      30.1}, {10., 27.6}, {10.5, 34.4}, {11., 34.9}, {11.5, 37.9}, {12.,      40.5}, {12.5, 31.9}, {13., 37.5}, {13.5, 36.5}, {14.,      25.4}, {14.5, 28.}, {15., 41.2}, {15.5, 36.6}, {16., 33.5}, {16.5,      37.1}, {17., 22.7}, {17.5, 37.5}, {18., 48.8}, {18.5,      39.7}, {19., 47.5}, {19.5, 38.1}, {20., 30.9}, {20.5, 50.9}, {21.,      43.9}, {21.5, 39.4}, {22., 44.1}, {22.5, 45.7}, {23.,      38.6}, {23.5, 57.}, {24., 46.}, {24.5, 49.5}, {25., 38.}, {25.5,      49.}, {26., 46.1}, {26.5, 55.5}, {27., 47.7}, {27.5, 49.2}, {28.,      51.4}, {28.5, 50.2}, {29., 57.3}, {29.5, 53.}, {30., 46.2}};          tsmC = TimeSeriesModelFit[datasetC, {"SARIMA", Automatic}]     plot6 = ListLinePlot[{tsmC["TemporalData"],      TimeSeriesForecast[tsmC, {70}]}, Frame -> True,      FrameLabel -> {"Time (days)", "Output"},      PlotLabel -> "Plot 6 \nModel: tsmC with Forecast",      PlotLegends -> {"data", "forecast"}]      ![enter image description here](http://i.stack.imgur.com/UDr3w.jpg) This forecast does not look reasonable. Can someone explain why this is and how I might produce a better forecast ? Eventually, I would like to produce a 90% prediction interval on the forecasts. Thanks.


Strange integration result

In Mathematica 8, the Integrate command sometimes strangely integrates polynomials yielding unsimplified (and unexpected) fractional results. As an example, the line:               Integrate[((h-x)*(q[1]+q[2])+x*(q[3]+q[4]))^2,{x,0,h}]      The (unsimplified) result is:               h^2/3(-(q[1]+q[2])^3+(q[3]+q[4])^3)/(-q[1]+q[2]+q[3]+q[4])      while the (theoretical) result cannot be a fraction. What are the proper command lines which lead to a polynomial?


How do I place frame ticks without having corresponding numbers?

> **Possible Duplicate:**   >  Remove tick labels, but retain tick marks in RegionPlot (and related > functions) I need to display a 2D graph, say $y=x^2$ with tick-marks along the $x$ and $y$-axes but with no numbers ( _e.g._ 1, 2, 3 ...) indicating these tick-mark values. What is the most efficient way to perform this task? Thanks!


Numerical Functions Compatible with Regions Fail with MeshRegions and BoundaryMeshRegions

Given a `MeshRegion`:               region = DelaunayMesh[RandomReal[1, {50, 3}]]      ![Mathematica graphics](http://i.stack.imgur.com/HhpNN.png) We can numerically `Integrate` over it easily:               NIntegrate[x^2 y^2 z^2, {x, y, z} ∈ region]      > 0.0169908561 We can also `Integrate` over its boundary:               NIntegrate[x^2 y^2 z^2, {x, y, z} ∈ RegionBoundary@region]      > 0.151404597 if you replace `DelaunayMesh` with `ConvexHullMesh`, which yields a `BoundaryMeshRegion`, the same process works fine. This does not come as a surprise as the documentation for `NIntegrate` suggests that integrating over regions in this way is possible. Now we turn our attention to `NArgMin`. We can mimic the built-in `RegionNearest` as follows:               dist[x_?VectorQ, y_?VectorQ] /; Length[x] == Length[y] := Sqrt @ Total[(x - y)^2]             regN[region_, point_] := NArgMin[{dist[point, x], x ∈ region}, x]      We can use it as follows:               regN[Disk[], {2, 3}]      > {0.55470039, 0.832050166}               regN[Sphere[], {2, 3, 4}]      > {0.371392166, 0.557086686, 0.742780105} Note that `Disk[]` and `Sphere[]` are `Region`s. Let's try our `MeshRegion` from above:               regN[region, {2, 3, 4}]      ![Mathematica graphics](http://i.stack.imgur.com/FBG2j.png) So, it looks like while `NIntegrate` works fine with `MeshRegion` and `BoundaryMeshRegion` objects, other functions (`NArgMin`, `NArgMax`, `NMinValue`, `NMaxValue`, `NMinimize`, `NMaximize` etc.) that claim to work over regions fail for both. Is this an omission in documentation or implementation, or am I totally missing something here?


How to prevent substitution?

I have a function: $\bar{u}:=u[t,x,y,z]$ (1) How do I prevent it from expanding and substituting in instructions like those following: $\partial _t {\bar u}$ (2) Thanks in advance EDIT: Mathematica expressions as asked:               OverBar[u]:=u[t,x,y,z]          D[ OverBar[u] , t]


how to dynamically change color of setterbar

I have a `SetterBar` with 3 values. I want that when I hover the cursor on any of the `SetterBar` value,it changes its color and again go back to its original. But when I select some value out of 3 values. It should show selected values as Red and rest White. I have tries this way but when I hover cursor of any one of these values, all changes color. This I dont want.                col = Yellow;      SetterBar[x,{            inp1 =  EventHandler[InputField[a, FieldSize -> 3,Background -> Dynamic[col]],             {"MouseMoved" :> (col =col /. {Yellow -> Green, Green->Yellow})}],                        inp2 = EventHandler[InputField[a, FieldSize -> 3,Background -> Dynamic[col]],             {"MouseMoved" :> (col =col /. {Yellow -> Green, Green->Yellow})}],             inp3 = EventHandler[InputField[a, FieldSize -> 3,Background -> Dynamic[col]],             {"MouseMoved" :> (col =col /. {Yellow -> Green, Green->Yellow})}]       }, Enabled -> True]


Possible bug while plotting homographic function with stylled axes (?!)

Seems like a bug to me, don't have time to dig more now. WinXP V9.0.1.0               With[{           opt = Sequence[AxesLabel -> {"x", "y"}, PlotStyle -> {Thick}, AspectRatio -> 1,                           ImageSize -> {300, 300}, AxesStyle -> Arrowheads[0.05]]          },          Row[{Framed@Plot[Sin[x], {x, 4, 6}, opt],                Framed@Plot[(-5 + x)/(6 + x)^2, {x, 4, 6}, opt]}]         ]      ![enter image description here](http://i.stack.imgur.com/UDGq7.png) and without `AxesStyle`: ![enter image description here](http://i.stack.imgur.com/HUqGW.png) So as we can see, `Arrowheads` is making the trouble but not with every function. Can you confirm this behaviour on other enviroments? p.s. **the solution** is `ImagePadding -> spec` ofc, but there should not be the issue.


Why won't mathematica plot the 3D Contour of this function?

I want to find the 3D contour of the equation1:               C1 = 10^(-10);     C2 = 0.1*C1;     R = 50;     Tb = 0.1;     Geb = 5*10^-15;     Z0 = 50;     L[Te_] := 10^-9 + 10^-9*(Te - 0.1);     Zlcr[Te_, w_] := (1/R + 1/(I*L[Te]*w) + I*C1*w)^-1;     Zload[Te_, w_] := -I*w*C2 + Zlcr[Te, w];     \[CapitalGamma][Te_, w_] := (Zload[Te, w] - Z0)/(Zload[Te, w] + Z0);     y[Te_, w_] := (Abs[\[CapitalGamma][Te, w]])^2;     eqn1[w_, Te_, Pprobe_] := (1 -   y[Te, w]) Pprobe  ==  (Te - Tb) Geb     ContourPlot3D[      eqn1[w, Te, Pprobe], {w, 0, 5*10^9}, {Te, 0, 1}, {Pprobe, 0, 10^-14}]


Solving system of 9 differential equations with Im & Re parts

I tried to solve a system of nine differential equations. Actually, I tried to do it in two ways, and both of them give me the same error: > NDSolve::pdord: Some of the functions have zero differential order, so the > equations will be solved as a system of differential-algebraic equations. >>               Clear[t]     z1 = 0;     z2 = 0;     Ωp = 2.2758;     Ωc = 0.22758;     τ = 13.8;     T2 = 200;     ω0 = 1;     ω02 = 1;     r = 0.7071;     Δ1 = 1.7758;     Δ2 = 0;     s = 2.2758;     ℏ = 1.05457173*10^-34;     ω = 0.5;          system = {ρ11'[t] == -Ωp*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*Im[ρ13[t]],     ρ22'[t] == -Ωc*Im[ρ23[t]],     ρ33'[t] == 2*Ωp*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*Im[ρ31[t]] + Ωc*Im[ρ32[t]],     Im[ρ12'[t]] == (Δ2 - Δ1)*Re[ρ12[t]] + Ωc/2*Re[ρ13[t]] - I*Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*Re[ρ32[t]],     Im[ρ13'[t]] == (Δ1)*Re[ρ13[t]] - Ωc/2*Re[ρ12[t]] - Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*(ρ11[t] - ρ33[t]),     Im[ρ23'[t]] == (Δ2)*Re[ρ23[t]] + Ωc/2*(ρ22[t] - ρ33[t]) + Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*Re[ρ21[t]],     Re[ρ12'[t]] == (Δ1 - Δ2)*Im[ρ12[t]] - Ωc/2*Im[ρ13[t]] - Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*Im[ρ23[t]],     Re[ρ13'[t]] == -(Δ1)*Im[ρ31[t]] - Ωc/2*Im[ρ12[t]],     Re[ρ23'[t]] == -(Δ2)*Im[ρ23[t]] - Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*Im[ρ21[t]]};          initialvalues = {ρ11[0] == 1, ρ22[0] == 0, ρ33[0] ==      0, ρ12[0] == 0, ρ21[0] == 0, ρ13[0] ==      0, ρ31[0] == 0, ρ23[0] == 0, ρ32[0] == 0};     sol = NDSolve[Join[system, initialvalues], {ρ11[t], ρ22[t], ρ33[t], ρ12[t], ρ13[t], ρ23[t], ρ21[t], ρ31[t], ρ32[t]}, {t, -20, 20}];      The other way that I used to write the equation is:               Clear[t]     z1 = 0;     z2 = 0;     Ωp = 2.2758;     Ωc = 0.22758;     τ = 13.8;     T2 = 200;     ω0 = 1;     ω02 = 1;     r = 0.7071;     Δ1 = 1.7758;     Δ2 = 0;     s = 2.2758;     ℏ = 1.05457173*10^-34;     ω = 0.5;          system = {ρ11'[t] == I*Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*(ρ13[t] - ρ31[t]),     ρ22'[t] == -I*Ωc/2*(ρ23[t] - ρ32[t]),     ρ33'[t] == -I*Ωp*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*(ρ31[t] - ρ13[t]) + I*Ωc/2*(ρ32[t] - ρ23[t]),     ρ12'[t] == -I (Δ2 - Δ1)*ρ12[t] +      I*Ωc/2*ρ13[t] - I*Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*ρ32[t],      ρ13'[t] == -I (Δ1)*ρ13[t] + I*Ωc/2*ρ12[t] + I*Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*(ρ11[t] ρ33[t]),      ρ23'[t] == -I (Δ2)*ρ23[t] +      I*Ωc/2*(ρ22[t] - ρ33[t]) + I*Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*ρ21[t],      ρ12'[t] == -I (Δ2 - Δ1)*ρ12[t] +         I*Ωc/2*ρ13[t] - I*Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*ρ32[t],      ρ31'[t] == I (Δ1)*ρ31[t] - I*Ωc/2*ρ21[t] -       I*Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*(ρ11[t] - ρ33[t]),     ρ32'[t] == I (Δ2)*ρ32[t] - I*Ωc/2*(ρ22[t] - ρ33[t]) - I*Ωp/2*E^(-(r^2/ω0^2) - ((t^2*(1.177^2))/τ^2))*ρ12[t]};          initialvalues = {ρ11[0] == 1, ρ22[0] == 0, ρ33[0] ==      0, ρ12[0] == 0, ρ21[0] == 0, ρ13[0] ==      0, ρ31[0] == 0, ρ23[0] == 0, ρ32[0] == 0};     sol = NDSolve[Join[system, initialvalues], {ρ11[t], ρ22[t], ρ33[t], ρ12[t], ρ13[t], ρ23[t], ρ21[t], ρ31[t], ρ32[t]}, {t, -20, 20}];


Get part of lousy data

I want to get part of large data. some part of this data is as follows:               data = {{"(100)", -0.033716509`, -0.19824611`,          "(101)", -0.026845098`, -0.18296293`,          "(102)", -0.021913837`, -0.17231199`}, {"(103)", -0.015043555`,     -0.16745934`, "(104)", -0.0076064845`, -0.16494502`,          "(105)", -1.1449175`*^-15, -0.16417456`}, {"(106)",          0.0076064845`, -0.16494502`, "(107)", 0.015043555`, -0.16745934`,          "(108)", 0.021913837`, -0.17231199`}, {"(109)",          0.026845098`, -0.18296293`, "(110)", 0.033716509`, -0.19824611`,          "(111)", -0.054776429`, -0.23685639`}, {"(112)", -0.042058374`,     -0.20053958`, "(113)", -0.029721072`, -0.19132756`,          "(114)", -0.019094091`, -0.18620841`}, {"(115)", -0.0093881514`,     -0.18374386`, "(116)", -1.4016566`*^-15, -0.18296576`, "(117)",          0.0093881514`, -0.18374386`}, {"(118)",          0.019094091`, -0.18620841`, "(119)", 0.029721072`, -0.19132756`,          "(120)", 0.042058374`, -0.20053958`}, {"(121)",          0.054776429`, -0.23685639`, "("}, {}, {"ELE", "CENTROID",          "CARTESIAN", "STRESSES", "PRIN", "STRESSES", "PRIN", "STRAINS",          "PRINCIPAL", "STRAINS", "YM"}};      I want to get the elements starting from `"(111)"` to `{}`. I prefer not to use `Flatten` simply because I want the output to match the elements levels (but if Flatten is need that is ok). the lists between `"(111)"` to `{}` is a variable and can be more or less. what is the best pattern that can take the elements from `"(111)"` to `{}?` **Note:** This set of data is repeated multiple times in the large data list and I want them all. Many thanks.