title: Is it possible to specify a context-sensitive, "depth-agnostic" rewrite rule?

text: I'm using the term "depth-agnostic" in this post to describe structural patterns featuring a "target" sub-pattern that can occur "at any depth" relative to one or more "context" sub-patterns. As a simple example of a "depth-agnostic" pattern, consider the following rewrite rule: > RR1 > > replace with the expression `WRAP[X]` any expression `X_TGT` contained > _somewhere_ within some expression `_CTX`.1 Here the target and context sub-patterns are `X_TGT` and `_CTX`, respectively. The depth-agnostic bit comes in as the phrase " _somewhere_ within". In other words, RR1 says to find expressions that look like               … CTX[ … y0[ … y1[ … … yk[ … TGT[ … ] … ] … … ] … ] … ] …      ...(where the number of nested subexpressions `y0`, `y1`, ..., `yk` is indeterminate), and rewrite them as               … CTX[ … y0[ … y1[ … … yk[ … WRAP[TGT[ … ]] … ] … … ] … ] … ] …      Thus, if we defined               ping = foo[{1, CTX[bar[2,  3, {TGT[0], 4} ]]}];     ding = foo[{1, CTX[bar[2, {3, {TGT[0], 4}}]]}];     pong = foo[{1, baz[bar[2,  3, {TGT[0], 4} ]]}];      then, according to RR1, `ping` would be changed to               foo[{1, CTX[bar[2,  3, {WRAP[TGT[0]], 4} ]]}]      ...and `ding` would be changed to               foo[{1, CTX[bar[2, {3, {WRAP[TGT[0]], 4}}]]}]      On the other hand, `pong` would be unaffected by RR1, even though it contains an expression `_TGT`, because this expression does not occur " _somewhere_ within an expression `_CTX`". The problem is > how to implement a rewrite rule that features such a "depth-agnostic" > pattern in _Mathematica_? To see why "depth-agnosticity" is an issue, consider rewrite rule RR2 below, identical in every way to RR1, except that it specifies a single, unambiguous depth for the target relative to the context sub-pattern (IOW, it is not "depth-agnostic"): > RR2 > > replace with the expression `WRAP[X]` any expression `X_TGT` contained _at a > depth of 3 within_ some expression `_CTX`. As shown below, implementing RR2 in _Mathematica_ is straightforward (though, admittedly, a bit tedious), but unfortunately, it is nowhere as general as RR1 (e.g. RR2 affects only `ping`, not `ding`). Here's one (rather uninspired) implementation of RR2 in action:               {ping, ding, pong} /.       CTX[a1___, h1_[a2___, h2_[a3___, X_TGT, z3___], z2___], z1___] ->        CTX[a1, h1[a2, h2[a3, WRAP[X], z3], z2], z1] // TableForm          foo[{1, CTX[bar[2, 3, {WRAP[TGT[0]], 4}]]}]     foo[{1, CTX[bar[2, {3, {TGT[0], 4}}]]}]     foo[{1, baz[bar[2, 3, {TGT[0], 4}]]}]      This implementation fulfills the earlier assertions about RR2: it like RR1 with respect to `ping` (affects it) and `pong` (does not affect it), but not with respect to `ding` (RR1 affects `ding` but RR2 doesn't). * * * There are at least two important generalizations of the ideas described above. The first one is the situation in which there are multiple context sub- patterns that are themselves at indeterminate depths relative to each other. For example: > RR3 > > replace with the expression `WRAP[X]` any expression `X_TGT` and being > contained _somewhere_ within some expression `_CTX` that is itself contained > _somewhere_ within some expression `_List`. The second generalization could be expressed as allowing "negative depths", or in other words, patterns in which the context sub-pattern is contained within the target subpattern. For example: > RR4 > > replace with the expression `WRAP[X]` any expression `X_TGT` containing > _somewhere_ within it some expression `_CTX`. * * * 1In this post I will resort to Mathematica's notation for patterns. Namely, `_H` denotes a pattern matching any expression having head `H`, and `X_H` denotes a pattern matching any expression (henceforth referred to as `X`) having head `H`. I will abuse this notation slightly, writing "an expression `_H`" as shorthand for "an expression matching the pattern `_H`", and "an expression `X_H`" as shorthand for "an expression (henceforth referred to as `X`) matching the pattern `_H`.)


title: Enlarge an image and increase its resolution

text: An ongoing purely recreational project. I got my introduction to image processing with this Rotating perspective... question and had a lot of fun with it. Now I want to take it to the next step. The great solutions to the earlier question led me to the following image as quite a small JPEG: ![collage](http://i.stack.imgur.com/oPQMH.jpg) Now, I hope to create a poster of the image that I can have printed at say 4' horizontally. To do this I need a JPEG which will have at least a 4' horizontal dimension with a resolution of at least 300 dpi. The artist created the original collage from pieces of cut colored paper - each piece a completely saturated color. The entire collage only has 10 or 11 colors. I can pretty easily identify RGB values for each. Also, the shapes that look approximately rectangular should all show as actual rectangles. The artist originally used full sheets of the colored paper. If you copy the above image into _Mathematica_ and zoom in on it even a little like this: ![zoom of collage](http://i.stack.imgur.com/YzHof.png) you'll see that it doesn't have crisp straight edges and many of the colors appear modulated rather than saturated. This will only get worse the more one blows up the image. To enlarge this up to 4' wide I need a way to address all of those issues. Call the attached JPEG `i = Import["http://i.stack.imgur.com/oPQMH.jpg"];`               ImageResize[i, 5000]      gets me pretty close to the size I need.               ColorQuantize[i, 11]      ![collage2](http://i.stack.imgur.com/Vh6jO.jpg) begins to get me towards the saturation of color that I want. But these approaches don't get me all the way. Do I need to try point operations and/or transformations of some kind? Do I need to breakout grey scales for each of the RGB values? Would some kind of mask help? Something so I break the problem down into smaller pieces. Any guidance appreciated. * * * P.S., I have the original artist's full cooperation and permission in this little project. If anyone wants to make a print of the final product and display it he'd love to see it out in the world and enjoyed.


title: How to fill a whole rectangle with text?

text: I have a rectangle with specified dimensions and I'd like to fill it with text, so that the text uses all (well, as much as possible) of the available area. I tried to do it with               Framed@Pane[       TextCell[ExampleData[{"Text", "LoremIpsum"}],        TextJustification -> 0, TextAlignment -> Center, ImageMargins -> 0],        ImageSize -> 1/2 {1920, 1080}, ImageSizeAction -> "ResizeToFit",        Alignment -> {Center, Center}]      I'm not concerned about the little gaps caused by the `TextJustification` option, but `ImageSizeAction -> "ResizeToFit"` bothers me because it leaves empty spaces at the top and bottom of the rectangle. This becomes more apparent when the rectangle size gets bigger, and I want to make some very large images. Rectangle size 960x540: ![small rectangle](http://i.stack.imgur.com/9zlHy.png) Rectangle size 1920x1080: ![bigger rectangle](http://i.stack.imgur.com/MfcfU.png) I would expect that the font size would increase to fill the empty space, but this does not happen.


title: How to inherit options by scoping?

text: Consider the following example: you have a function `framed` producing a cell with a button that, when pushed, calls `framed` again. How to supply options to `framed` such that whenever the button is pushed, the "embedded" `framed` inherits these options? If, however, the `framed` is called **not** by the button, it should use the default options (as it cannot inherit it from a parent). The following example works as expected (any new cell will inherit `a -> 1111`:               Options[framed] = {a -> 1};     Options[button] = {"framedOptions" -> Options@framed};     button[x_, opts : OptionsPattern[]] :=        Button[x, Print@framed[x, OptionValue@"framedOptions"]];     framed[x_, opts : OptionsPattern[]] :=        Framed[{button[x, "framedOptions" -> Flatten@{opts}], OptionValue@a}];          Print@framed["Push", a -> 1111];      Pushing the displayed button yields a second cell with inherited options: ![Mathematica graphics](http://i.stack.imgur.com/x7N1x.png) But for certain reasons I want to avoid unnecessary options like `"framedOptions"` and use some kind of scoping as there could be multiple embeddings and recursion and I don't want to forward `"framedOptions"` all the time. No scoping would work however, as the button funcion is only evaluated at runtime.               Options[framed] = {a -> 1};     button[x_] := Button[x, Print@framed@x];     framed[x_, opts : OptionsPattern[]] := Framed[        Internal`InheritedBlock[{framed = framed},         SetOptions[framed, Flatten@{opts}];         {button@x, OptionValue@a}         ]];          Print@framed["Push", a -> 1111];      ![Mathematica graphics](http://i.stack.imgur.com/RanqH.png) Note that the problem extends to attributes or any part of a function definition. What I would really need is an `InheritedDynamicBlock` (nonexistent) that not justs inherits the function definition but also keeps it local to a _certain part of the screen_ (where the original content is displayed). Any idea?


title: How can you convert a matrix back into a list of lists?

text: It is very simple in Mathematica to convert a list of lists into a matrix: all you need to do is apply the `//MatrixForm` function to it and voila. Is it possible to do the reverse though? I have a matrix that I want to convert back into a list of lists, so as to manipulate its elements more easily. Is this possible? Is there a '`ListForm`' function that deletes all `MatrixForm`s from the element in question? As an example, here is the `FullForm` for one of my elements: `MatrixForm[List[List[63],List[4,62]]]` Is there a function which would take this as input and return simply `List[List[63],List[4,62]]`? Thank you


title: FoldWhile and FoldWhileList

text: Mathematica has had `NestWhile` and `NestWhileList` for some time. But, to date, it has not implemented a built-in `FoldWhile` or a `FoldWhileList`. So, since these constructs seem useful to me, I have tried to brew my own. Here are my current implementations. Anyone have suggestions on how either of these might be improved. I'd be particularly interested in a variant of `FoldWhile` that did not require as much memory as `FoldWhileList`.                FoldWhileList[f_, init_, list_, test_, m_, max_] :=       Block[{i = 0},          NestWhileList[(i = i + 1; f[#, Part[list, i]]) &, init, test, m, max]]      and                FoldWhile[f_, init_, list_, test_, m_, max_] :=          Last[FoldWhileList[f, init, list, test, m, max]]


title: How to solve equations over polynomial rings

text: sorry if my question is very basic but I don't know what to even search to look it up and the only "obvious" places I thought of had nothing. Some background, for whatever context it might provide. I'm working with a certain ring of functions $R=\langle P_i\rangle$, where $P_i=ax^i+y^i+z^i+(-1)^i (ax+y+z)^i\in\mathbb{C}(a)[x,y,z]$ (i.e. I normally think of $a$ as a coefficient of $x$, but here I'm actually keeping it as a variable, hoping to generalize a calculation I'll explain below). By a theorem of Hilbert's, I know that $R$ is finitely generated. More importantly, if it is free over $\mathbb{C}[P_2, P_3, P_4]$, it is Cohen-Macaulay and that's what I want to know ultimately. If I compute the Hilbert series and all coefficients are positive, then this tells me where I should pick generators from. Sorry if this is more information than is relevant. OK, well in particular, say I think the generators should be $1, P_4, P_5$, meaning that polynomials like $P_{10}$ should have a (unique) expression of the form $f_1(P_2, P_3, P_4)+f_2(P_2, P_3, P_4)P_4+f_3(P_2, P_3, P_4)P_5=P_{10}$, where the $f_i$ are polynomials. I don't care to show the uniqueness, but given all the $P_i$, is there any systematic way to have Mathematica solve for the polynomials $f_i$? The bounds on degrees give some pretty tight bounds on the degrees of the $f_i$. Any help would be much appreciated!


title: Apply IC and BCs on Second - Order Linear PDE

text: I am now trying to solve second - order linear partial differential equation in that interested eq. has been separated into variables to simplify the procedure for Mathematica. Here is my equation; ![Differential Equation](http://i.stack.imgur.com/mHre8.jpg) or separated form, ![Separated Form](http://i.stack.imgur.com/yZGBZ.jpg) Also, the last equation is coded in Mathematica as;                   L[t_, z_] := T[t] Z[z]         Eq = (D[T[t], t]/(A*T[t])) == R*(D[D[Z[z], z], z]/Z[z]) - B*(D[Z[z], z]/Z[z])         L[t, z] /. Flatten@{DSolve[Eq[[1]] == F, T, t, GeneratedParameters -> CT],          DSolve[Eq[[2]] == F, Z, z, GeneratedParameters -> CS]}      Then, the solution is given as; ![The Solution](http://i.stack.imgur.com/aKpzb.jpg) However at that point, I should plug IC and BCs into related eq. to both get rid of constants and proceed with my calculations. These are my IC and BCs, respectively; ![IC](http://i.stack.imgur.com/BtfzA.jpg) ![BC1](http://i.stack.imgur.com/fQpUT.jpg) ![BC2](http://i.stack.imgur.com/cRGa0.jpg) How can I solve this problem? Is there any way to insert these IC and BCs into the code above? or Does there exist any method, command etc. to come up with solution without integration constants? Note: Any of the values included in BCs is neither a function of z nor that of t.


title: How can I wrap text around a circle?

text: How can I wrap text around a circle? For example: the text in the sectors of this chord plot. Perhaps one could use `FilledCurve[]` and then apply a `GeometricTransformation[]`?


title: Issuing user-defined messages takes a long time (Message is slow)

text: Issuing messages takes a very long time in version 9 and version 10. Can others reproduce this? Is there a fix? **Update:** This is slow only when using the front end, but not when running the kernel from a terminal. System-messages tend to be faster, but not nearly as fast as they were in v8. (`Message[General::args, "boo"] // AbsoluteTiming`) * * * ### Version 8 Version 8 is fast. The second invocation of `Message` is _much_ faster.               In[1]:= $Version         Out[1]= "8.0 for Mac OS X x86 (64-bit) (July 22, 2012)"          In[2]:= mysym::mess = "message";          In[3]:= Message[mysym::mess] // AbsoluteTiming          During evaluation of In[3]:= mysym::mess: message          Out[3]= {0.110727, Null}          In[4]:= Message[mysym::mess] // AbsoluteTiming          During evaluation of In[4]:= mysym::mess: message          Out[4]= {0.000389, Null}      ### Version 9 Version 9 is slow               In[1]:= $Version         Out[1]= "9.0 for Mac OS X x86 (64-bit) (January 24, 2013)"          In[2]:= mysym::mess = "message";          In[3]:= Message[mysym::mess] // AbsoluteTiming          During evaluation of In[3]:= mysym::mess: message          Out[3]= {0.364160, Null}          In[4]:= Message[mysym::mess] // AbsoluteTiming          During evaluation of In[4]:= mysym::mess: message          Out[4]= {0.220693, Null}      ### Version 10 Version 10 is slow just like version 9:               In[1]:= $Version         Out[1]= "10.0 for Mac OS X x86 (64-bit) (June 29, 2014)"          In[2]:= mysym::mess = "message";          In[3]:= Message[mysym::mess] // AbsoluteTiming          During evaluation of In[3]:= mysym::mess: message          Out[3]= {0.343261, Null}          In[4]:= Message[mysym::mess] // AbsoluteTiming          During evaluation of In[4]:= mysym::mess: message          Out[4]= {0.271947, Null}


title: BoxWhiskerChart - 10-90th percentile instead of min - max

text: I am trying to draw a custom BoxWhiskerChart with alternative values determining fences. I have data that has a lot of outliers and I have to compare it to another chart that has 10-90th percentile instead of standard min/max. How would I go about it?


title: Are formal characters like \[FormalA] to be used differently than other symbols?

text: I noticed that Mathematica has a set of special 'Formal' characters such as `\\[FormalA]`, `\\[FormalB]` , etc.. In the front end, it looks like a character with a dot above and below. It is not clear from the build-in help files how these characters are to be used. Can anyone demonstrate?


title: Flipping axis on a plot

text: I want to make a 2D plot where the x-axis is flipped so the higher numbers are on the right and lower numbers are on the left. I've managed to do it by flipping the data and making new `Ticks` but this solution is manually and requires manipulating the data. I was hoping there was a better way. For the normal plot:               data = Table[{x, x^2}, {x, 20, 100}];     ListLinePlot[data]      ![Mathematica graphics](http://i.stack.imgur.com/dLsT8.png) And for the flipped data and the new plot:               data = Table[{100 - x + 20, x^2}, {x, 20, 100}];     ticks = Table[{x, 100 - x + 20}, {x, 20, 100, 10}]     ListLinePlot[data, Ticks -> {ticks, Automatic}]      ![Mathematica graphics](http://i.stack.imgur.com/YJdWT.png) I couldn't seem to find any options like `ReverseAxis`.


title: Is it possible to type equations as text in Mathematica?

text: I was wondering if I could write an equation, symbolically, but only as part of a text in Mathematica. So I don't want Mathematica to consider anything inside that equation as a variable, nor equate or perform any mathematics on it. Is that possible?


title: Finding integral bounds

text: i have this integral shown below is equal to 1, and i need to find "a" on mathematica, but I'm not sure how. integral (from 0 to a) sqrt((-50.8938 sin(8.4823 t))^2+(4-11.3097 sin(11.3097 t))^2) dt = 1 any suggestions?


title: Negative power instead of fraction

text: Solve returns a solution in the form `{{x->y/a^2 + y^2/a^7}}`. Since I want to process the input (with another program) in terms of Laurent polynomials, I would like an output like `{{x->y a^-2 + y^2 a^-7}}`. Is this kind of output format possible? Edit: I would prefer a string "x=ya^-2 + y^2a^-7" (or something that could be parsed to this easily)


title: Eureqa Client to connect to Mathematica under Windows

text: Does there exist a way to use Eureqa software with Mathematica under Windows?   That is, is there a working client to connect to a Eureqa server?


title: Why can I still hear sound when the frequency of the periodic function inside Play is higher than the range of human ear?

text: We know that usually sound that is perceptible by humans has frequencies from about 20 Hz to 20,000 Hz, but as the title said, I can still hear the sound of the outputs of the following code:               (* The following sound won't cause discomfort… I think. *)     Play[Sin[1000000 2 Pi t], {t, 0, 1}, SampleRate -> 10000000]      After asking some of my friends to hear them, I'm sure I don't have clairaudience. I think it's probably not the fault of _Mathematica_ , it might be an issue for loudspeaker, but I failed to find an answer by myself and I think it's worth posting a question for this.


title: List manipulation - various

text: # Update OK, Please forgive the messiness of this, but I am working with something like:               d = (q = 8;     f = (lop =        Transpose[{Flatten[          Reverse[Table[             Gamma[y], {y, 1, q + 1}]] /. {ComplexInfinity -> 0}],          Flatten[Table[Binomial[n, k], {n, q, q}, {k, 0, n}]],          Flatten[Table[x^n, {n, 0, q}]]}];      {#1*#2*#3} & @@@ lop);     Flatten[f];     Total[f]);     d      which gives:               {40320 + 40320 x + 20160 x^2 + 6720 x^3 + 1680 x^4 + 336 x^5 + 56 x^6 + 8 x^7 + x^8}      I am then comparing the roots with another series, eg:               Normal[Series[E^x, {x, 0, 8}]]      which, in this case are the same. However, I have lots of different series & was wondering if I could manipulate them as stated below. _(NB - I realise there is no 'ComplexInfinity' output in the above example, but have left it in to demonstrate that I have tried several replace techniques for the subsequent questions.)_ # Original question I have several questions on list manipulation & at the risk of asking the same question multiple times, I have compiled them into the following single question: (a) Changing alternate (or some other pattern) signs / operators: From this:               1 + x + (x^2)/2! +  (x^3)/3! + (x^4)/4! +  (x^5)/5! ...      I would like to do get this:               1 - x + (x^2)/2! -  (x^3)/3! + (x^4)/4! -  (x^5)/5! ...      (b) Multiplying alternate (or some other pattern) elements by a given value (eg - I): From this:               1 + x + (x^2)/2! +  (x^3)/3! + (x^4)/4! +  (x^5)/5! ...      I would like to do get this:               1 - I x + (x^2)/2! -  I(x^3)/3! + (x^4)/4! -  I(x^5)/5! ...      (c) Convert all Imaginary values in a list to real values (or vice versa), noting that there may be no pattern in the distribution here: From this:               1 + I x + (x^2)/2! +  (x^3)/3! + I(x^4)/4! +  I(x^5)/5! ...      I would like to do get this:               1 + x + (x^2)/2! +  (x^3)/3! + (x^4)/4! +  (x^5)/5! ...      or this:               I + I x + I(x^2)/2! +  I(x^3)/3! + I (x^4)/4! +  I(x^5)/5! ...      I have tried various select & replace methods, but have had no luck so far.


title: Is there a way to plot discrete functions in mathematica?

text: Suppose you have a discrete function Triangle[n/5]. How would you plot it in mathetica?


title: Draw the plane on ParametricPlot3D with one parameter

text: I need to make semitransparent coordinate plane(s) at ParametricPlot3D with one parameter. If I add the second parameter the curves becomes ugly.                GraphicsRow[{        ParametricPlot3D[{          {Sin[u], Tan[u], u/10},           0.5 {Cos[u], Sin[u], u/10}},         {u, -20, 20},  BoxRatios -> {1, 1, 1}],         ParametricPlot3D[{          {Sin[u], Tan[u], u/10},           0.5 {Cos[u], Sin[u], u/10},           {u/10, v/10, 0}},        {u, -20, 20}, {v, -20, 20}, BoxRatios -> {1, 1, 1}]}]      ![enter image description here](http://i.stack.imgur.com/pebHZ.png) ![enter image description here](http://i.stack.imgur.com/pBdCj.png) How I can fix it?


title: How to program a F::argx message?

text: How useful is it to program a user-built function in a package to produce a red warning message `F::argx` if you give the wrong number of arguments to that function? How do I do this?


title: substitution rules for Penrose tiles

text: This page on W|A shows a nice substitution rule to draw kites and darts. I'd like to implement the rule in _Mathematica_ , so I've drawn the original kite and its replacement (separately). I've also drawn the original dart and its replacement. This seems like a job for `Replace[]`, but I'm not sure how. I know there are similar animations on Demonstrations, but I'd like to create my own (with help!). In my mind, this would be cool as a `Manipulate[]` environment, where the slider controls the number of times the replacement has occurred. Maybe even a rotation slider, too, so the kites and darts tile space in a particular direction. Thanks!


title: LogPlot and LogLogPlot do not output their legends correctly

text: ![LogLogPlot does not output legends correctly](http://i.stack.imgur.com/kIhFc.png) When I give lists of functions to `LogPlot` or `LogLogPlot` with the option of `PlotLegends`, the output legends only have its first one, just like on the image below. What should I do to get all legends in the plot?


title: Correct behavior of lock file in hsqldb connection

text: I'm running in to some problems with generating a persistent HSQLDB and during some troubleshooting I came upon the following behavior.               Needs["DatabaseLink`"]     tc = OpenSQLConnection[      JDBC["hsqldb", ToFileName[Directory[], "temp"]], Username -> "sa"]     CloseSQLConnection[tc]      The above code generates three files (which will be located in `Directory[]`). Despite the fact that the connection is closed, two of the files (temp.lck and temp.log) cannot be deleted until the Mathematica kernel has been shut down. Is this 'normal' behavior?


title: How to delete duplicate solutions of this system of equations?

text: I want to find vertices (has integer coordinates) of the triangle $ABC$ with the centorid is $G(1,1)$ and orthocenter is $H(3,3)$. I tried               a = {x1, y1};     g = {1, 1};     h = {3, 3};     b = {x2, y2};     c = {x3, y3};     Solve[{x1 + x2 + x3 == 3 g[[1]],        y1 + y2 + y3 == 3 g[[2]], (h - a).(c - b) == 0, (h - b).(c - a) ==         0, -20 < x1 < 20, -20 < y1 < 20, -20 < x2 < 20, -20 < y2 < 20,        x2*y3 - x1*y3 + x1*y2 - y2*x3 + y1*x3 - y1*x2 != 0}, {x1, y1, x2,        y2, x3, y3}, Integers]      ![enter image description here](http://i.stack.imgur.com/HPZjB.gif) There are some duplicate triangles. How to delete this duplicate triangles?


title: Compute the rank of a matrix with variable entries

text: Say I have a matrix like $$ M=\left( \begin{array}{c c c} x & xz & w-2x \\ wz^3 & xy & z \\ y^2-z^3 & x+w & z+x^5 \end{array} \right) $$ is it possible to ask Mathematica the rank of $M$, depending on $(x,y,z,w)$ ?


title: diff-able text-only notebooks?

text: I would like to save my _Mathematica_ notebooks as plain-text documents, so that I can keep them under `git` version control. I thought that `File > Save as...` + `Plain Text` would do what I want, but I'm having problems with it. First, I can't figure out how to "re-import" into _Mathematica_ (in a form that can be readily evaluated) a notebook saved this way. Second, the human-readable text content is overwhelmed by serializations of graphic objects, etc. Therefore, the output produced by `git diff` on two versions of such text files is a nightmare. Third, the human-readable text portions are not all that readable. Of course, some rich formatting cannot be easily converted to text, but I would like to preserve at least some of the indentation found in the original, if possible. Is there a better approach?


title: How can I recover a graph from a graphical output in a notebook after resetting the kernel?

text: I have an old Mathematica notebook with an output for a graph structure $G$ I would like to recover. However, the routine for building up the graph is stochastic, so I can't simply rerun the code. Can I recover the vertices and edges of a graph from its output in an old notebook after the kernel has been restarted? * * * More specifically, say I run the command:               G = RandomGraph[{50, 600}]      Which produces and graphical output that clearly can't be reconstructed by eye. I then quit the kernel. Can I recover the vertex and edges of $G$ using the output graphic?


title: Combining three R, G, B matrices into a single matrix of 3-tuples?

text: Working with _Mathematica 8_ on _OSX_ here. I have three $1024 \times 1024$ matrices representing the counts from consecutive exposures onto a _CCD_ with $R$, $G$, and $B$ filters on it, and am looking to combine the three matrices to get a nice color picture. My first shot was something of the following sort:               ColorCombine[{     MatrixPlot[m13R - dark - bias, ColorFunction -> (RGBColor[#, 0, 0] &)],     MatrixPlot[m13G - dark - bias, ColorFunction -> (RGBColor[0, #, 0] &)],     MatrixPlot[m13B - dark - bias, ColorFunction -> (RGBColor[0, 0, #] &)]     }]      but it looks like `ColorCombine` messes with the resolution, and so what was originally $1024\times1024$ comes out looking rather pixelated. What I'm thinking now is to do the equivalent of `Transpose` but am unsure as to how to combine my three matrices into a $1024\times1024$ matrix with a $3$-tuple at each entry. From there I think `Image[combined, ColorSpace -> "RGB"]` will work to plot the now-colored image. For those interested, you can find the relevant data here. Any help appreciated!


title: Why does Integrate return a solution that is not defined at a particular point when it actually is well defined at that point?

text: I am trying to compute               Integrate[Sqrt[x^4 + (y - y^2)^2], {x, 0, y}]      _Mathematica_ 8 gives               (* ConditionalExpression[y^2 Abs[-1 + y]                              Hypergeometric2F1[-(1/2), 1/4, 5/4, -(y^2/(-1 + y)^2)],                              0 < y < 1 || y > 1] *)      but it is perfectly well defined for $y=1$ where the answer is exactly $1/3$. Is this a bug?


title: ColorData["VisibleSpectrum"] is wrong?

text: I am trying to visualize the visible spectrum using the built-in `ColorData["VisibleSpectrum"]` function which "colors based on light wavelength in nanometers". But I get wrong results for well-known pure colors. For example the yellow color has wavelength of 570–590 nm but `ColorData["VisibleSpectrum"][580]` returns green: ![screenshot](http://i.stack.imgur.com/sf7mZ.png) Is it a bug? How to visualize the visible spectrum in _Mathematica_ correctly?


title: Expression of uncertainty in measurement.

text: I have a problem with writing a _Mathematica_ function. I have been requested to show the results of my experiments with the measurement uncertainty (mu) like below:               measurementValue(mu)        Both numbers ought to be rounded with precision, given by the two most significant digits of mu. Example:               16(11), 123.4(1.3), 1230(10), 123.345(40)||123.345(0.040)      Getting proper format of mu is simple:               NumberForm[mu, 2]      But I don't have any idea, how to round properly measurement value. Finally I want to write a function, that returns the proper format of the value and mu as output.


title: May the Fourth be with you

text: Happy Star Wars day. I was playing around with the image manipulation functions in _Mathematica_ in an attempt to recreate the Star Wars crawl. There's an HTML/CSS implementation which is in my opinion pretty impressive and I'm wondering if it's possible to obtain the same quality out of Mathematica (ideally using features that can be exported as a CDF). For starters, I was focusing on the crawl (with the "long time ago..." and diminishing Star Wars title components to be added eventually). The text and theme song:               text = "It is a period of civil war.       Rebel spaceships, striking       from a hidden base, have won       their first victory against       the evil Galactic Empire.\n       During the battle, Rebel       spies managed to steal secret       plans to the Empire's       ultimate weapon, the DEATH       STAR, an armored space       station with enough power       to destroy an entire planet.\n       Pursued by the Empire's       sinister agents, Princess       Leia races home aboard her       starship, custodian of the       stolen plans that can save her       people and restore       freedom to the galaxy....";     theme = Import[       "http://www.moviewavs.com/0093058674/WAVS/Movies/Star_Wars/starwars.wav"]      One can get the gist if the effect fairly succinctly with a combination of `ImagePerspectiveTransformation` and `TranslationTransform` after rasterizing the text:               i0 = Rasterize[Panel[Style[text, Yellow], Background -> Black],         RasterSize -> 400, ImageSize -> 300];     Animate[      Show[With[{a = 5.25, b = 5},        ImagePerspectiveTransformation[         ImagePerspectiveTransformation[i0,           TranslationTransform[{0, crawl}]], {{1, 0.5 b, 0}, {0, a, 0}, {0,            b, 1.}}, PlotRange -> All]        ], ImageSize -> 600],      {crawl, -3, 1}, AnimationRate -> 0.075, AnimationRepetitions -> 1,       Initialization -> (EmitSound@theme)]      There are some problems with this approach, however:   1. Text quality isn't great. The quality can be improved by adjusting the Rasterize options; however I noticed a significant performance hit in doing so.   2. The transformations result in white bars above and below the crawl.   3. The theme song repeats and is not easily stoppable.   4. The notebook size bloats to 2 MB even with the low res settings   5. Use of Animate won't work when it comes to exporting as a CDF I am interested in finding solutions to these problems.


title: Non linear constrained interger Optimization

text: I need to maximize the equation below which is subjected to some nonlinear constraints                  Maximize  hsum + isum + jsum + ksum + lsum + msum + nsum + osum      constraints are:                  0 < hsum,isum,jsum,ksum,lsum,msum,nsum < 10000       -5000 < osum < 0             a*x1 + b*x2 + d*x4 - h*(x1 + x2 + x4) = hsum        a*x1 + b*x2 + d*x4 - i*(x1 + x2 + x4) = isum        a*x1 + b*x2 + e*x5 - j*(x1 + x2 + x5) = jsum        a*x1 + b*x2 + e*x5 - k*(x1 + x2 + x5) = ksum        a*x1 + c*x3 + f*x6 - l*(x1 + x3 + x6) = lsum        a*x1 + c*x3 + f*x6 - m*(x1 + x3 + x6) = msum        a*x1 + c*x3 + g*x7 - n*(x1 + x3 + x7) = nsum         a*x1 + c*x3 + g*x7 - o*(x1 + x3 + x7) = osum            > X1,X2,X3....X7 are integers               a=100          b = (a + u1) && c = (a - u2) && d = (b + u3) && e = (b - u4) &&      f = (c + u5) && g = (c - u6) && h = (d + u7) && i = (d - u8) &&      j = (e + u9) && k = (e - u10) && l = (f + u11) && M = (f - u12) &&     n = (g + u13) && o = (g - u14)                0.1 <= u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11, u12, u13, u14 <= 3      I have tried to solve this but sadly my input maximization eq. is displayed as output   But **when i remove the integer constrain for x1,x2...x7** code runs indefinitely. Also some one said mathematica is unable to solve non linear equations where variables are constrained by integers values is that so? Anyways here is my mathematica equation to check out if there is any problem with the code               Maximize[     {        hsum + isum + jsum + ksum + lsum + msum + nsum + osum,         a*x1 + b*x2 + d*x4 - h*(x1 + x2 + x4) == hsum &&         a*x1 + b*x2 + d*x4 - i*(x1 + x2 + x4) == isum &&         a*x1 + b*x2 + e*x5 - j*(x1 + x2 + x5) == jsum &&         a*x1 + b*x2 + e*x5 - k*(x1 + x2 + x5) == ksum &&         a*x1 + c*x3 + f*x6 - l*(x1 + x3 + x6) == lsum &&         a*x1 + c*x3 + f*x6 - m*(x1 + x3 + x6) == msum &&         a*x1 + c*x3 + g*x7 - n*(x1 + x3 + x7) == nsum &&         a*x1 + c*x3 + g*x7 - o*(x1 + x3 + x7) == osum &&              a == 100&&             b == (a + u1) && c == (a - u2) && d == (b + u3) && e == (b - u4) &&         f == (c + u5) && g == (c - u6) && h == (d + u7) && i == (d - u8) &&         j == (e + u9) && k == (e - u10) && l == (f + u11) && m == (f - u12) &&        n == (g + u13) && o == (g - u14)             && 0.1<=u1<=3 && 0.1<=u2<=3 && 0.1<=u3<=3 && 0.1<=u4<=3 && 0.1<=u5<=3 && 0.1<=u6<=3         && 0.1<=u7<=3 && 0.1<=u8<=3 && 0.1<=u9<=3 && 0.1<=u10<=3 && 0.1<=u11<=3         && 0.1<=u12<=3 && 0.1<=u13<=3 && 0.1<=u14<=3 &&                    0.1 <= hsum <= 10000 && 0.1 <= isum <= 10000 && 0.1 <= jsum <= 10000 &&         0.1 <= ksum <= 10000 && 0.1 <= lsum <= 10000 && 0.1 <= msum <= 10000 &&        0.1 <= nsum < 10000 && -5000 <= osum <= -0.1              &&Element[x1 | x2 | x3 | x4 | x5 | x6 | x7, Integers]     },           {a, b, c, d, e, f, g, h, i, j, k, l, m, n,      o, x1, x2, x3, x4, x5, x6, x7, hsum, isum, jsum, ksum, lsum, msum,     nsum, osum,u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11, u12, u13, u14}]      thanks for reading till here


title: Interpolating function as a model in Mathematica's procedures for fitting

text: Is it possible to use interpolating function with parameters as a model for NonLinearModel fit (and other integrated methods for fitting)? Similar question was already posted earlier - How do I find the best parameter to fit my data if the model is a interpolating function?. However, answer is not covering whole fitting procedure and it is based on "do it yourself" method, since the question was only about the value of best fit parameter. Difference is that I am asking how to use (if possible) Mathemaca's methods for fitting. NonLinearModelFit finds not only best values of parameters, but also chi2, confidence regions, correlation matrix and many more things that I use. I could calculate them on my own, but I want to use some of integrated methods. If one defines a model in the form `model[x, A, B, C]`, which gives a real number for a set of parameter values A, B, C and a value of x, then Mathematica knows how to play with it. Instead I have a model defined as `model[A, B, C]`, which gives, for any set of numeric values A, B and C, a pure function or a function of `x` on some range. Now how to explain that to Mathematica and to use NonLinearModelFit? One thing I could do is to redefine pure function `model[A, B, C]` to `model[x, A, B, C]`, but that would require calculating the whole slope `model[A, B, C]` while taking its value at only one point `x`, and then repeating this procedure for every point `x`. This takes too long if one has big set of data points (with errors) to fit. Is there a better idea?


title: Linear regression with x and y errors

text: I have a question about finding a linear regression weighted with x and y errors. I found the answer provided by 0x4A4D in Estimate error on slope of linear regression given data with associated uncertainty, but didn't know how to post it under his post, so I'am putting it here. Sorry in advance if there is anything wrong with this. If i use the following code provided by 0x4A4D:               ortlinfit[data_?MatrixQ, errs_?MatrixQ] :=       Module[{n = Length[data], c, ct, dk, dm, k, m, p, s, st, ul, vl, w, wt, xm, ym},             (* yes, I know I could have used FindFit[] for this... *)             {ct, st, k} = Flatten[MapAt[Normalize[{1, #}] &,                 NArgMin[Norm[Function[{x, y}, y - \[FormalM] x - \[FormalK]] @@@ data],                        {\[FormalM], \[FormalK]}], 1]];             (* find orthogonal regression coefficients *)             {c, s, p} = FindArgMin[{                Total[(data.{-\[FormalS], \[FormalC]} -                      \[FormalP])^2/((errs^2).{\[FormalS]^2, \[FormalC]^2})],                \[FormalC]^2 + \[FormalS]^2 == 1},               {{\[FormalC], ct}, {\[FormalS], st}, {\[FormalP], k/ct}}];             (* slope and intercept *)             {m, k} = {s, p}/c;             wt = 1/errs^2; w = (Times @@@ wt)/(wt.{1, m^2});             {xm, ym} = w.data/Total[w];             ul = data[[All, 1]] - xm; vl = data[[All, 2]] - ym;             (* uncertainties in slope and intercept *)             dm = w.(m ul - vl)^2/w.ul^2/(n - 2);             dk = dm (w.data[[All, 1]]^2/Total[w]);             {Function[\[FormalX], Evaluate[{m, k}.{\[FormalX], 1}]], Sqrt[{dm, dk}]}] /;          Dimensions[data] === Dimensions[errs]          {lin, {sm, sk}} = ortlinfit[data, errs]          Show[          Graphics[{AbsolutePointSize[4], Point[data], MapThread[Circle, {data, errs}]},                   Frame -> True],           Plot[{lin[x], lin[x] - sm x - sk, lin[x] + sm x + sk}, {x, -1, 9},               PlotStyle -> {Directive[Thick, Red],                             Directive[Dashed, Gray], Directive[Dashed, Gray]}]          ]      there is a problem with some kind of data. I get my data like this: {x, xerr, y, yerr}               info={{327, 10, 29, 2}, {153, 4, 56, 2}, {88, 3, 90, 2}}      and change it to work with 0x4A4D's code for my problem to data = {x, 1/y} and errs = {xerr, yerr/y^2} (absolute errors which I want to plot od graph) with following code Input:               data = {#[[1]], 1/#[[3]]} & /@ info     errs = {#[[2]], #[[4]]/#[[3]]^2} & /@ info      Output:               data = {{327, 1/29}, {153, 1/56}, {88, 1/90}}     errs = {{10, 2/841}, {4, 1/1568}, {3, 1/4050}}      If i use this data and errs it works perfectly (or at least so it looks at the first glance). Result is: ![enter image description here](http://i.stack.imgur.com/jt5lG.png) But for the sake of my report I have to multiply "y" and "yerr" with a 10^(-5) factor, so I get to work with following points: Input:               info[[All,3]]*=10^(-5);     info[[All,4]]*=10^(-5);          data = {#[[1]], 1/#[[3]]} & /@ info;     errs = {#[[2]], #[[4]]/#[[3]]^2} & /@ info;      Output:               data = {{327, 100000/29}, {153, 12500/7}, {88, 10000/9}};     errs = {{10, 200000/841}, {4, 3125/49}, {3, 2000/81}};      And now his algorithm doesn't work as it should anymore since the result is this: ![enter image description here](http://i.stack.imgur.com/9ZnH1.png) Does anyone possibly knows why?


title: How to draw a Circle in a graph with Log Y Scale

text: I've programmed drawing tools for graph images and am experiencing a problem with the coordinates of **an Ellipse on a graph with a Log Y axis**. It's quite easy to work out the Y Axis coordinates for other primitive objects such as Line, Rectangle & etc:               y1 = ((viewHeight - stPoint.Y + topMargin) / (viewHeight) * (maxY - minY) + minY);     y2 = ((viewHeight - endPoint.Y + topMargin) / (viewHeight) * (maxY - minY) + minY);          if (isLogYAxis)     {        y1 = Math.Exp(y1);        y2 = Math.Exp(y2);     }      Here is an example showing the Epilog generated for a Circle and a Rectangle I've drawn: ![enter image description here](http://i.stack.imgur.com/fE0ec.png)               Epilog -> {{RGBColor[1,0.2196,1], Circle[{AbsoluteTime@{1991,03,09} + ((AbsoluteTime@{1996,04,28} - AbsoluteTime@{1991,03,09}) / 2),Log@40},         {(AbsoluteTime@{1996,04,28} - AbsoluteTime@{1991,03,09}) / 2,Log@60}]},          {EdgeForm[Directive[Thick, RGBColor[0.6157,0.6,0.7922]]], Transparent, Rectangle[{AbsoluteTime@{1986,03,26},Log@60},{AbsoluteTime@{1990,12,15},Log@40}]}}      When I execute this command the Ellipse's Y axis is out of proportion, see: ![enter image description here](http://i.stack.imgur.com/rLAtz.png) I want to be able to plug in Log@40 and Log@60 for both the Rectangle and Circle and get the same results. I've made a basic example to demonstrate this.               LogPlot[x^x, {x, 1, 5},       Epilog -> {{RGBColor[0, 0, 0],          Circle[{2, Log@46.20}, {1, Log@50.9972}]}}]      Seeing the radius from the ellipse's centre to its top (2000) will be a different size from its centre to its bottom (approx 50), is it even possible to draw a Ellipse on a LogY Graph as I've described? ![enter image description here](http://i.stack.imgur.com/VoxpV.png) **Edit:** @Artes thank you for pointing me in the right direction, I've tried all sorts of things using this formula `Plot[Exp[y /. Solve[x^2 + y^2 == 1, y]], {x, -1, 1}]` without luck. In the last screenshot I've put red squares around the `Log@46.20` and `Log@50.9972` **does anybody know what formula's I would have to change these too in order to get a circle with Log Height of about 5?** _If it makes any difference I have the MinY and MaxY Log scale:_ _MinY = 3.6888794541139363_   _MaxY = 4.941642422609304_


title: How can I create a 3D FilledCurve object?

text: `FilledCurve` can create a 2D graphics object; for example:               a = {{-1, 0}, {0, 1}, {1, 0}}; b = {{0, -(2/3)}};     Graphics[FilledCurve[{{BezierCurve[2 a], Line[2 b]}, {BezierCurve[a], Line[b]}}]]       ![a FilledCurve in 2D](http://i.stack.imgur.com/aXVBq.jpg) How can I put a `Graphics3D` object like this on a plane, say $z=0$, and create something like the following 3D graphic (without mapping it on a polygon as a texture)? ![a 3D version?](http://i.stack.imgur.com/nTWnC.jpg)


title: Recurrence relation: Find a recurrence and evaluate (on WolframAlpha)

text: I am trying to get _WolframAlpha_ to solve a recurrence and evaluate a result in one query. For example: If               f[6] == 0, f[0] == 1      f[i] == (1/2)*f[i+1] + (1/2)*f[i-1]      Then `f[3]` equals to .. ? It gives me an analytical result for `f`, but does not evaluate `f[3]`. How would I get it to evaluate `f[3]` on this same query ?


title: Can I generate a "piecewise" list from a list in a fast and elegant way?

text: Suppose we have a number list `a`:               n = 1000000;     a = RandomReal[{0, 1}, {n}];      We want to generate a list `c` with the same dimension of `a` and the relationship between the elements of `a` and `c` is: > $c[[i]] == 2 a[[i]] +3$ I think there will be no doubt that the best way to get this `c` is:               c = 2 a + 3      However, what if `c` is a "piecewise" list i.e. elements in different part of `c` are generated by different formula? For example, `n/2` of the elements right in the middle of `c` are `0.` while others still follow the formula above. The most direct way I can think out is:               c1 = Table[If[n/4 + 1 <= i <= 3 n/4, 0., 2 a[[i]] + 3 ], {i, n}]; // AbsoluteTiming      > {7.7380000, Null} It's simple, but too slow. While these 2 approaches are fast:               (c2 = 2 a + 3 ;        c2[[n/4 + 1 ;; 3 n/4]] = ConstantArray[0., {n/2}];) // AbsoluteTiming     (c3 = ConstantArray[0., {n}];       c3[[1 ;; n/4]] = 2 a[[1 ;; n/4]] + 3 ;        c3[[3 n/4 + 1 ;; -1]] = 2 a[[3 n/4 + 1 ;; -1]] + 3;) // AbsoluteTiming      > {0.0760000, Null} > > {0.0580000, Null} But they are so dirty… And things will be worse when the dimension of the list becomes higher:               n=100;     b = RandomReal[{0, 1}, {n, n, n}]          d1 = Table[         If[n/4 + 1 <= i <= 3 n/4 && n/4 + 1 <= j <= 3 n/4 &&            n/4 + 1 <= k <= 3 n/4, 0., 2 b[[i, j, k]] + 3 ], {i, n}, {j,           n}, {k, n}]; // AbsoluteTiming     (d3 = ConstantArray[0., {n, n, n}];         d3[[1 ;; n/4]] = 2 b[[1 ;; n/4]] + 3;         d3[[3 n/4 + 1 ;; -1]] = 2 b[[3 n/4 + 1 ;; -1]] + 3;        d3[[n/4 + 1 ;; 3 n/4, 1 ;; n/4]] =          2 b[[n/4 + 1 ;; 3 n/4, 1 ;; n/4]] + 3;         d3[[n/4 + 1 ;; 3 n/4, 3 n/4 + 1 ;; -1]] =          2 b[[n/4 + 1 ;; 3 n/4, 3 n/4 + 1 ;; -1]] + 3;        d3[[n/4 + 1 ;; 3 n/4, n/4 + 1 ;; 3 n/4, 1 ;; n/4]] =          2 b[[n/4 + 1 ;; 3 n/4, n/4 + 1 ;; 3 n/4, 1 ;; n/4]] + 3;         d3[[n/4 + 1 ;; 3 n/4, n/4 + 1 ;; 3 n/4, 3 n/4 + 1 ;; -1]] =          2 b[[n/4 + 1 ;; 3 n/4, n/4 + 1 ;; 3 n/4, 3 n/4 + 1 ;; -1]] + 3;); // AbsoluteTiming      > {12.8440000, Null} > > {0.0930000, Null} And a nightmare when the region are irregular:               f1 = Table[If[i^2 + j^2 + k^2 <= n^2, 0., 2 b[[i, j, k]] + 3 ],                 {i, n}, {j, n}, {k, n}]; // AbsoluteTiming      > {7.4530000, Null} A fast `f3` with the method shown in `c3` and `d3` is of course possible, but I'd like to skip it now. So my question is, as the title said, is there an approach that's both elegant as `c1` and fast as `c3`? Or at least not that slow as `c1` and not that dirty as `c3`? Or, I can't have my cake and eat it too? * * * Well, to be honest, I knew that `Compile` together with `Module` can somewhat help (thanks for the help of @chyaong!):               c11 = Compile[{}, Module[{a = a, n = n},            Table[If[n/4 + 1 <= i <= 3 n/4, 0., 2 a[[i]] + 3], {i, n}]]][]; // AbsoluteTiming      > {0.3590000, Null} But I still look forward to a better solution: maybe a little greed? * * * I'd like to point out that, though I chose "$f(a)$ and $0$" to generate list in the example above for the sake of simplicity, this question is more general, the generated list may be formed by "$f(a)$ and $g(a)$", or even by "$f(a1,a2)$ and $g(a1,a2)$". Still, I appreciated and will appreciate those answers that focus on special cases since the "$f(a)$ and $0$" cases are simple but also common. I added the tag "difference-equations" because this question generated when exploring finite difference method (FDM). I believe it's a inevitable issue when programming FDM. Here are two existed post that can be optimized or answered with the outcome of this discussion: How to discretize a nonlinear PDE fast? How do I solve a PDE with a strange boundary condition?


title: Manipulate executes twice

text: I need help, guys! Here the script:               numberProcesses = 24;     numberLevels = 4;     Manipulate[      numberExperts = E;      processMatrix =        Table[RandomReal[{0, 1}, WorkingPrecision -> 2], {i, E}, {j,          numberLevels}];      aggregatedMark =        Table[Total[processMatrix[[All, k]]]/E, {k, numberLevels}];      deviation =        Table[N[Sqrt[          Sum[RootApproximant[(processMatrix[[h, g]] -                 aggregatedMark[[g]])^2], {h, E}]/E], 2], {g, numberLevels}];      variation =        Table[N[RootApproximant[deviation[[g]]/aggregatedMark[[g]]*100],          2], {g, numberLevels}];      graphTable =        Table[Show[{Histogram[processMatrix[[All, j]], {0, 1, 0.1}, "PDF"],           SmoothHistogram[processMatrix[[All, j]],            PlotStyle -> Thick]}], {j, numberLevels}];      groupMark = {};      k = {};      l = {};      tmax = 2;      t = 1;      AppendTo[k, Table[1/E, {i, E}]];      While[True,       AppendTo[groupMark,         Table[N[Sum[processMatrix[[i, j]]*k[[t, i]], {i, E}], 2], {j,           numberLevels}]];       AppendTo[l,         RootApproximant[         Sum[Sum[groupMark[[t, i]]*processMatrix[[j, i]], {j, E}], {i,            numberLevels}]]];       temp = Table[         N[1/l[[t]]*           Sum[(processMatrix[[i, j]]*groupMark[[t, j]]), {j,              numberLevels}], 2], {i, E - 1}];       AppendTo[k,         AppendTo[temp,          N[RootApproximant[1 - Sum[temp[[i]], {i, E - 1}]], 2]]];       If[t >= tmax,         If[Max[Table[            Abs[groupMark[[t, i]] - groupMark[[t - 1, i]]], {i,              numberLevels}]] <= 0.0001, Break[], t++], t++]];      viewTable = Text[Grid[Append[Append[Append[Append[Append[              MapThread[               Prepend, {Prepend[                 processMatrix, {"Второй уровень", "Третий уровень",                   "Четвёртый уровень", "Пятый уровень"}],                 Prepend[Table[i, {i, E}], ""]}],               Insert[aggregatedMark, "fi",1]],              Insert[deviation, "Sigma", 1]],             Insert[variation, "V", 1]],            Insert[graphTable, "Graph", 1]],           Insert[groupMark[[t, All]], "Mark", 1]], Frame -> All,          Background -> LightYellow]], {{E, 3, "Number"}, 2,        100, 1}, ContinuousAction -> False, TrackedSymbols -> {E}]      It does: ![The result](http://i.stack.imgur.com/4nvKy.png) And most of that works well, but when the `E` value is changed `Manipulate` executes all twice... Why is it so? I really don't understand. I tried delete the graphs from the table. After that I saw `Manipulate` didn't execute all twice. It's magic =/ Secondly, I don't know how I can get real numbers with only two digits after the point (0.xx). When I use `N[,2]` Mathematica returns sometimes 0.0xx or 0.00xx. But I wanna get 0.0x or 0.00 (of course, using the standard rule for rounding). How can I do it? And last but not least, as you can see I used such functions as `RootApproximant`. I don't want use it, but sometimes without 'em Mathematica says: `No significant digits are available to display`. What can I do? I will be happy if someone will help me optimize the script. Thank you for your attention. **EDITED** `Manipulate` executes all twice. It was solved - Stackoverflow. Thanks, @SjoerdC.deVries.


title: Why does StreamColorFunctionScaling refuse to turn off?

text: Consider this simple streamline plot:               StreamPlot[{-y/10, x/10}, {x, -1, 1}, {y, -1, 1},       StreamColorFunction -> Function[{x, y, u, v}, Hue[v]]]      ![enter image description here](http://i.stack.imgur.com/8cxA0.png) The arguments to the colour function are rescaled to lie between 0 and 1, so the colours span the whole spectrum, as expected. But now I want to turn off colour function scaling and work with the original vector field values. Those lie between -1/10 and 1/10, so I should get only hues between purple and orange:               StreamPlot[{-y/10, x/10}, {x, -1, 1}, {y, -1, 1},       StreamColorFunction -> Function[{x, y, u, v}, Hue[v]],       StreamColorFunctionScaling -> False]      ![enter image description here](http://i.stack.imgur.com/B9mXe.png) _I'm sorry, Dave. I'm afraid I can't do that._ Is this a bug? How do I work around it?


title: How to plot filling under a curve?

text: I want to mark critical areas for statistical test on the plot. How can I do this? This:               pdf = PDF[NormalDistribution[], x]     Show[Plot[pdf, {x, -5, 5}],       Plot[pdf, {x, -5, -2.001}, Filling -> Axis]]      gives: ![enter image description here](http://i.stack.imgur.com/op81t.png) I know that it is probably some super-duper Mathematica feature, but as far as I know this filling shouldn't be cut in such strange way, so I don't want to use this feature. How can I make the filling look right?


title: Is this result wrong because of calculation time? (and more questions about Assumptions)

text: I am confused with the Integrate Given by _Mathematica_. First let's see a one-dimensional case:                   Integrate[UnitStep[k - Sqrt[kx^2]], {kx, -Infinity, Infinity}, Assumptions -> k > 0]      The result is `2k`. Right answer! You can change `UnitStep` to `HeavisideTheta`, it still gives the same correct answer. However, when changing to three dimension case,`HeavisideTheta` gives the wrong answer. See the following:               Integrate[ HeavisideTheta[k - Sqrt[kx^2 + ky^2 + kz^2]],       {kx,-Infinity,  Infinity}, {ky, -Infinity, Infinity}, {kz, -Infinity, Infinity},       Assumptions -> k > 0]      _Mathematica_ gives the wrong answer `0` and with an error message I don't understand. > Refine::fas: Warning: One or more assumptions evaluated to False. If `Assumptions` is not added, it directly gives `0` without any WARNING! As if it calculated it right! How dangerous if I previously didn't know the answer! @Jens suggested using `UnitStep` instead of `HeavisideStep`. I tried: in _Mathematica_ 7 it fails (giving the wrong answer 0) but in version 8 it gives the right result:                   (4 k^3 \[Pi])/3      Still with the same message: > Refine::fas: Warning: One or more assumptions evaluated to False. ## So what does this message mean? Why do different _Mathematica_ versions give different answers? Is this because of the computing time involved? * * * Above is the main question, here is some subtle question I would like to ask; see this integral:               Assuming[k > 0, Integrate[ UnitStep[k - Sqrt[kx^2 + ky^2 + kz^2]],       {kx, -Infinity, Infinity}, {ky, -Infinity, Infinity}, {kz, -Infinity, Infinity}]]      the results:                   (4 k^3 \[Pi])/3 k>0          0  True      ## It seems _Mathematica_ 'forgets' that I have assumed that `k>0`. Why is that? What does the second line of the result mean?


title: WSMSetValues function

text: I am trying to assign values to some model parameters using WSMSetValues function, however, it seems to be working only with values greater than 10^-4. Is this normal behavior or I am doing something wrong? Of course, I could manually type in these values in Model Center and it would work fine, but I wish to do this programmatically. Here is an example:               Needs["WSMLink`"];     param = {"TT1.C2" -> 1. 10^-7, "TT1.C1" -> 1. 10^-7,      "TT1.R6" -> 10000., "TT1.R5" -> 10000., "TT1.R4" -> 10000.,      "TT1.R3" -> 5400., "TT1.R2" -> 10000., "TT1.R1" -> 10000.};     m = "filter";       WSMSetValues[m, param];       WSMModelData[m, "ParameterValues"]        and this is an output showing that C1 and C2 did not take desired values:                {TT1\[UpPointer]resistor1\[UpPointer]useHeatPort -> False,       TT1\[UpPointer]resistor1\[UpPointer]T ->       TT1\[UpPointer]resistor1\[UpPointer]T\[UnderBracket]ref,       TT1\[UpPointer]resistor1\[UpPointer]R -> TT1\[UpPointer]R1,       TT1\[UpPointer]resistor1\[UpPointer]T\[UnderBracket]ref -> 300.15,       TT1\[UpPointer]resistor1\[UpPointer]alpha -> 0,       TT1\[UpPointer]resistor2\[UpPointer]useHeatPort -> False,       TT1\[UpPointer]resistor2\[UpPointer]T ->       TT1\[UpPointer]resistor2\[UpPointer]T\[UnderBracket]ref,       TT1\[UpPointer]resistor2\[UpPointer]R -> TT1\[UpPointer]R2,       TT1\[UpPointer]resistor2\[UpPointer]T\[UnderBracket]ref -> 300.15,       TT1\[UpPointer]resistor2\[UpPointer]alpha -> 0,       TT1\[UpPointer]resistor3\[UpPointer]useHeatPort -> False,       TT1\[UpPointer]resistor3\[UpPointer]T ->       TT1\[UpPointer]resistor3\[UpPointer]T\[UnderBracket]ref,       TT1\[UpPointer]resistor3\[UpPointer]R -> TT1\[UpPointer]R3,       TT1\[UpPointer]resistor3\[UpPointer]T\[UnderBracket]ref -> 300.15,       TT1\[UpPointer]resistor3\[UpPointer]alpha -> 0,       TT1\[UpPointer]resistor4\[UpPointer]useHeatPort -> False,       TT1\[UpPointer]resistor4\[UpPointer]T ->       TT1\[UpPointer]resistor4\[UpPointer]T\[UnderBracket]ref,       TT1\[UpPointer]resistor4\[UpPointer]R -> TT1\[UpPointer]R4,       TT1\[UpPointer]resistor4\[UpPointer]T\[UnderBracket]ref -> 300.15,       TT1\[UpPointer]resistor4\[UpPointer]alpha -> 0,       TT1\[UpPointer]resistor5\[UpPointer]useHeatPort -> False,       TT1\[UpPointer]resistor5\[UpPointer]T ->       TT1\[UpPointer]resistor5\[UpPointer]T\[UnderBracket]ref,       TT1\[UpPointer]resistor5\[UpPointer]R -> TT1\[UpPointer]R5,       TT1\[UpPointer]resistor5\[UpPointer]T\[UnderBracket]ref -> 300.15,       TT1\[UpPointer]resistor5\[UpPointer]alpha -> 0,       TT1\[UpPointer]resistor6\[UpPointer]useHeatPort -> False,       TT1\[UpPointer]resistor6\[UpPointer]T ->       TT1\[UpPointer]resistor6\[UpPointer]T\[UnderBracket]ref,       TT1\[UpPointer]resistor6\[UpPointer]R -> TT1\[UpPointer]R6,       TT1\[UpPointer]resistor6\[UpPointer]T\[UnderBracket]ref -> 300.15,       TT1\[UpPointer]resistor6\[UpPointer]alpha -> 0,       TT1\[UpPointer]capacitor1\[UpPointer]C -> TT1\[UpPointer]C1,       TT1\[UpPointer]capacitor2\[UpPointer]C -> TT1\[UpPointer]C2,       TT1\[UpPointer]R1 -> 10000, TT1\[UpPointer]R2 -> 10000,       TT1\[UpPointer]R3 -> 5400, TT1\[UpPointer]R4 -> 10000,       TT1\[UpPointer]R5 -> 10000, TT1\[UpPointer]R6 -> 10000,       TT1\[UpPointer]C1 -> 0, TT1\[UpPointer]C2 -> 0}        Since I could not attach the model here, I am providing a link for the same question I asked at Wolfram student forum where i was able to attach the model: http://forums.wolfram.com/student-support/topics/487059 Thank you, Tatjana


title: Getting MemoryAllocationFailure from NIntegrate

text: When numerically calculating a double integral using `NIntegrate` over an infinite domain (with all options at their default), _Mathematica_ 7 calculates my integral with some comments about slow convergence, but _Mathematica_ 9 aborts calculating with a long message which starts with > SystemException["MemoryAllocationFailure" ... What do I have to do to make the calculation in _Mathematica_ 9 (Linux)?


title: Generating a list of questions (simultaneous equations)

text: I am trying to create a list of simultaneous equations showing steps, where I only need to change a, b and the question number, and maybe a couple of minor things about q (where q is the factored quadratic, and a & b are the integer factors). I am currently using:               a = -2; b = 1; q = 2 (a + x) (b + x);          q1 = Expand[q]; sol = x /. Solve[q1 == 0, x];     TraditionalForm[Grid[{{Grid[{{"2.       (1)      ", y, " = ",         If[Coefficient[q1, x, 2] == 1, "", Coefficient[q1, x, 2]], x,         If[Coefficient[q1, x, 1] > 0, "+", ""], Coefficient[q1, x, 1]},       {"          (2)      ", x y, " = ", , -Coefficient[q1, x, 0],         " ", " ", " ", " ", " "}}]},{Grid[{{"       ", q1, "= 0"}}]},     {Grid[{{"          ", Factor[q1], "= 0"}}]},     {Grid[{{"{x,y} pairs:  ", {sol[[1]],          Coefficient[q1, x, 2]*sol[[1]] + Coefficient[q1, x, 1]},         ",", {sol[[2]],          Coefficient[q1, x, 2]*sol[[2]] + Coefficient[q1, x, 1]}, " ",         " ", " ", " "}}]}}]]      which is a bit messy to say the least, but outputs: ![enter image description here](http://i.stack.imgur.com/df4qn.gif) not too far from the desired effect of: $2.\quad\ \ \ (1)\quad \quad y=2x-2\\ \qquad \ \ (2)\quad \quad xy=4\\ \qquad \qquad\ \quad \ \ 2x^2-2x-4=0\\ \qquad \qquad \quad \ \ 2(x-2)(x+1)=0\\ \{x,y\}\text{ pairs: }\{-1,-4\},\{2,2\}$ though I should probably have used a table in my $\LaTeX$! I am sure there is a better, more efficient way of doing this though. Things I would like to improve: better spacing, automatic numbering, randomly chosen integer (or fraction) factors, random `x` sign changes, etc. (Basically a self-generating work/answersheet.) # Update OK, I have replaced ubpdqn's top line with               q = RandomChoice[Join[Range[-5, -1],      Range[1, 5]]] (RandomChoice[Join[Range     [-10, -1],  Range[1, 10]]] + x)      RandomChoice[Join[Range[-10, -1], Range[1, 10]]]     + x);     q1 = Expand[q];     sol = x /. Solve[q1 == 0, x];     eqn = {y == Coefficient[q1, x, 2] x -      Coefficient[q1, x, 1],      x y == -Coefficient[q1, x, 0]};      which generates question using random numbers, but have tried putting this into a table with `n` number of questions & just outputs same question `n` times :/ I suppose copy & paste will have to do for now...


title: Open a Mathematica 9 notebook in Mathematica 8

text: I have the following question: Can I open a _Mathematica_ 9 notebook in _Mathematica_ 8? Are there compatibility issues?


title: Avoid creation of OwnValues when inserting transformation rules into Experimental`OptimizeExpression

text: I have a large list of transformation rules that I want to simplify. I find Experimental`OptimizeExpression works as it gets me the answers. **My question is: **I can only get this to work when I convert my list of rules into a list of assignments - which is obviously what i want to avoid doing** - by using               list1/.Rule->Set      **How can I avoid making the assignments and still use Experimental`OptimizeExpression?** # Please note: **I have a solution that gives me the outcome, I want to avoid the side effect of the assignments. Whilst alternative solutions are appreciated, the real issue I have is the side effect that assigns values to the symbols in the rule sets!** I apologise for my incompetence making this clear. For example               list1 = {a -> b + c, d -> b + c};     list2 = {b -> 1, c -> 1};     Experimental`OptimizeExpression[{list1 /. Rule -> Set, list2 /. Rule -> Set}];     %[[1, 2]]          (* Out= {{2, 2}, {1, 1}} *)      This does indeed simplify my list of transformation rules, however the assignment has some drawbacks as my rules are now evaluating, which I clearly do not want. I am creating OwnValues for each individual transformation rule, effectively disabling the transformation rules.               list1     list2     (* Out= {2 -> 2, 2 -> 2} *)     (* Out= {1 -> 1, 1 -> 1} *)      PLEASE NOTE THE DESIRED RESULT SHOULD BE               (* Out= {a -> b + c, d -> b + c} *)     (* Out= {b -> 1, c -> 1}; *)      I can clear the assignments, and then all works fine, but there must be a more elegant solution.               Clear[a, b, c, d]     list1     list2          (* Out= {a -> b + c, d -> b + c} *)     (* Out= {b -> 1, c -> 1} *)      **Now there have kindly been several alternative solutions for the above example provided and I have tried a lot myself as well, however I cannot get any of them to work with the full set of lists which is more complex** (and imported from another application so it looks a bit messy): > lists= {v[4] -> v[22], v[6] -> v[16], v[15] -> v[17], v[31] -> v[22]*v[39], > v[32] -> v[75], v[33] -> v[22], v[35] -> v[21], v[41] -> v[22] + v[26] - > v[63], v[45] -> v[23], v[51] -> v[22], v[2] -> 0.25, v[3] -> 14, v[17] -> > 100000000, v[20] -> 5, v[22] -> 2000000000000, v[23] -> 1, v[18] -> > 400000000000, v[19] -> 200000000000, v[24] -> 0.5, v[27] -> 0.7, v[29] -> > -1, v[34] -> 0.03, v[36] -> 0.05, v[37] -> 333, v[38] -> 222, v[39] -> 0.3, > v[46] -> 0.01, v[47] -> 1000, v[52] -> 0.0175, v[53] -> 0, v[54] -> 0, v[55] > -> 0, v[56] -> 0, v[57] -> 0, v[58] -> 0, v[59] -> 0, v[60] -> 1, v[61] -> > 0, v[64] -> 3, v[65] -> 0.4, v[67] -> 0.0625, v[66] -> 0.4, v[68] -> 0.25, > v[69] -> 0.25, v[71] -> 2.5, v[73] -> 0.5, v[70] -> 2.5, v[72] -> 4, v[74] > -> 0.0625, v[1] -> v[6]/v[3] + v[7] + v[14] + v[25] + (-v[6] + v[11])/v[64], > v[7] -> v[5]*v[41], v[8] -> v[18]*v[43]*v[55], v[9] -> v[19]*v[43]*v[56], > v[10] -> v[26] + (1 - v[24])*v[44] + v[24]*v[51] - v[63], v[11] -> > (v[2]*v[33])/(v[3]^(-1) + v[30]), v[12] -> ((1 - v[2])*v[51])/v[50], v[13] > -> v[33] _v[39], v[14] -> (v[13] - v[31])/v[66], v[25] -> v[8] + v[18], > v[26] -> v[9] + v[19], v[28] -> v[36], v[30] -> > v[34]/((v[4]/v[22])^(v[27]/v[29])_ > ((v[22]*v[45])/(v[20]*v[35]))^v[29]^(-1)), v[40] -> (v[18] + v[19])/v[22], > v[42] -> -(v[6]/v[3]) + (1 - v[24])*v[44] + v[24]*v[51], v[43] -> v[32] - > v[36] + ((-v[12] + v[15])*v[59])/(v[15] _v[65]), v[44] -> (v[6]/v[16])^v[2]_ > (v[15]/v[17])^(1 - v[2])*v[22], v[48] -> (v[12] - v[15])/(v[15]*v[65]), > v[49] -> -(v[6]/v[3]) - v[7] - v[25] + (1 - v[24])*v[44] + v[24] _v[51] - > (-v[6] + v[11])/v[64], v[62] -> v[21]_ (1 + v[43] _v[58]), v[63] -> (v[18] + > v[19])_ (1 - v[60]) + v[40]*((1 - v[24])*v[44] + v[24]*v[51]) _v[60], v[75] > -> ((-v[15] + v[17]/(1 - v[36]))_ (1 - v[36]))/v[17], v[5] -> (-(v[6]/v[3]) > + v[41])/v[41], v[16] -> (v[2]*v[22])/(v[3]^(-1) + v[34]), v[21] -> > (v[22]*v[23])/v[20], v[50] -> ((1 - v[2])*v[22])/v[17]} Daniel Lichtblau's suggestion was:               polys = lists /. Rule -> Subtract;     vars = Cases[lists, _Symbol, Infinity] // Union;     gb = GroebnerBasis[polys, vars];     reds = PolynomialReduce[vars, gb, vars][[All, 2]];     Thread[vars->reds]      > (* Out = {v[1] -> 0., v[2] -> 0., v[3] -> 0., v[4] -> 0., v[5] -> 0., v[6] > -> 0., v[7] -> 0., v[8] -> 0., v[9] -> 0., v[10] -> 0., v[11] -> 0., v[12] > -> 0., v[13] -> 0., v[14] -> 0., v[15] -> 0., v[16] -> 0., v[17] -> 0., > v[18] -> 0., v[19] -> 0., v[20] -> 0., v[21] -> 0., v[22] -> 0., v[23] -> > 0., v[24] -> 0., v[25] -> 0., v[26] -> 0., v[27] -> 0., v[28] -> 0., v[29] > -> 0., v[30] -> 0., v[31] -> 0., v[32] -> 0., v[33] -> 0., v[34] -> 0., > v[35] -> 0., v[36] -> 0., v[37] -> 0., v[38] -> 0., v[39] -> 0., v[40] -> > 0., v[41] -> 0., v[42] -> 0., v[43] -> 0., v[44] -> 0., v[45] -> 0., v[46] > -> 0., v[47] -> 0., v[48] -> 0., v[49] -> 0., v[50] -> 0., v[51] -> 0., > v[52] -> 0., v[53] -> 0., v[54] -> 0., v[55] -> 0., v[56] -> 0., v[57] -> > 0., v[58] -> 0., v[59] -> 0., v[60] -> 0., v[61] -> 0., v[62] -> 0., v[63] > -> 0., v[64] -> 0., v[65] -> 0., v[66] -> 0., v[67] -> 0., v[68] -> 0., > v[69] -> 0., v[70] -> 0., v[71] -> 0., v[72] -> 0., v[73] -> 0., v[74] -> > 0., v[75] -> 0.} *) I am most likely missing the point (Groebnerbasis are not something I am familiar with) but this is not the desired result. Te compare with an approach using Experimental`OptimizeExpression, this provides the expected outcome, but I assign values to symbols to make it work (undesirable):               blocks = lists;     Block[{blocks2 = blocks /. Rule -> Set},      res=Experimental`OptimizeExpression[blocks2]];     res[[1]]      > (* Out = {2000000000000, 4.92958*10^12, 100000000, 6.*10^11, 0.05, > 2000000000000, 400000000000, 1.6*10^12, 1, 2000000000000, 0.25, 14, > 100000000, 5, 2000000000000, \ 1, 400000000000, 200000000000, 0.5, 0.7, -1, > 0.03, 0.05, 333, 222, \ 0.3, 0.01, 1000, 0.0175, 0, 0, 0, 0, 0, 0, 0, 1, 0, > 3, 0.4, 0.0625, \ 0.4, 0.25, 0.25, 2.5, 0.5, 2.5, 4, 0.0625, 2.*10^12, > 1.24789*10^12, 0., 0., 1.6*10^12, 4.92958*10^12, 1.*10^8, 6.*10^11, 0., > 400000000000, 200000000000, 0.05, 0.03, 3/10, 1.64789*10^12, > -1.38778*10^-17, 2.*10^12, -3.72529*10^-16, 0., 4.*10^11, 6.*10^11, 0.05, > 0.77993, 4.92958*10^12, 400000000000, 15000.} *) **_And the illustration how the assignments make the symbols in the original rules evaluate, thereby making the transformation list useless:_**               Thread[vars->res[[1]]]      > (* Out = {2000000000000 -> 2000000000000, 4.92958*10^12 -> 4.92958*10^12, > 100000000 -> 100000000, 6.*10^11 -> 6.*10^11, 0.05 -> 0.05, 2000000000000 -> > 2000000000000, 400000000000 -> 400000000000, 1.6*10^12 -> 1.6*10^12, 1 -> 1, > 2000000000000 -> 2000000000000, 0.25 -> 0.25, 14 -> 14, 100000000 -> > 100000000, 5 -> 5, 2000000000000 -> 2000000000000, 1 -> 1, 400000000000 -> > 400000000000, 200000000000 -> 200000000000, 0.5 -> 0.5, 0.7 -> 0.7, -1 -> > -1, 0.03 -> 0.03, 0.05 -> 0.05, 333 -> 333, 222 -> 222, 0.3 -> 0.3, 0.01 -> > 0.01, 1000 -> 1000, 0.0175 -> 0.0175, 0 -> 0, 0 -> 0, 0 -> 0, 0 -> 0, 0 -> > 0, 0 -> 0, 0 -> 0, 1 -> 1, 0 -> 0, 3 -> 3, 0.4 -> 0.4, 0.0625 -> 0.0625, 0.4 > -> 0.4, 0.25 -> 0.25, 0.25 -> 0.25, 2.5 -> 2.5, 0.5 -> 0.5, 2.5 -> 2.5, 4 -> > 4, 0.0625 -> 0.0625, 2.*10^12 -> 2.*10^12, 1.24789*10^12 -> 1.24789*10^12, 0 > -> 0., 0 -> 0., 1.6*10^12 -> 1.6*10^12, 4.92958*10^12 -> 4.92958*10^12, > 1.*10^8 -> 1.*10^8, 6.*10^11 -> 6.*10^11, 0. -> 0., 400000000000 -> > 400000000000, 200000000000 -> 200000000000, 0.05 -> 0.05, 0.03 -> 0.03, 3/10 > -> 3/10, 1.64789*10^12 -> 1.64789*10^12, -1.38778*10^-17 -> -1.38778*10^-17, > 2.*10^12 -> 2.*10^12, -3.72529*10^-16 -> -3.72529*10^-16, 0. -> 0., > 400000000000 -> 4.*10^11, 6.*10^11 -> 6.*10^11, 0.05 -> 0.05, 0.77993 -> > 0.77993, 4.92958*10^12 -> 4.92958*10^12, 400000000000 -> 400000000000, > 15000. -> 15000.} *) Without having to resort to assigning via /.Rule->Set I would have gotten the correct answer: > (* Out = {v[1] -> 2000000000000, v[2] -> 4.92958*10^12, v[3] -> 100000000, > v[4] -> 6.*10^11, v[5] -> 0.05, v[6] -> 2000000000000, v[7] -> 400000000000, > v[8] -> 1.6*10^12, v[9] -> 1, v[10] -> 2000000000000, v[11] -> 0.25, v[12] > -> 14, v[13] -> 100000000, v[14] -> 5, v[15] -> 2000000000000, v[16] -> 1, > v[17] -> 400000000000, v[18] -> 200000000000, v[19] -> 0.5, v[20] -> 0.7, > v[21] -> -1, v[22] -> 0.03, v[23] -> 0.05, v[24] -> 333, v[25] -> 222, v[26] > -> 0.3, v[27] -> 0.01, v[28] -> 1000, v[29] -> 0.0175, v[30] -> 0, v[31] -> > 0, v[32] -> 0, v[33] -> 0, v[34] -> 0, v[35] -> 0, v[36] -> 0, v[37] -> 1, > v[38] -> 0, v[39] -> 3, v[40] -> 0.4, v[41] -> 0.0625, v[42] -> 0.4, v[43] > -> 0.25, v[44] -> 0.25, v[45] -> 2.5, v[46] -> 0.5, v[47] -> 2.5, v[48] -> > 4, v[49] -> 0.0625, v[50] -> 2.*10^12, v[51] -> 1.24789*10^12, v[52] -> 0., > v[53] -> 0., v[54] -> 1.6*10^12, v[55] -> 4.92958*10^12, v[56] -> 1.*10^8, > v[57] -> 6.*10^11, v[58] -> 0., v[59] -> 400000000000, v[60] -> > 200000000000, v[61] -> 0.05, v[62] -> 0.03, v[63] -> 3/10, v[64] -> > 1.64789*10^12, v[65] -> -1.38778*10^-17, v[66] -> 2.*10^12, v[67] -> > -3.72529*10^-16, v[68] -> 0., v[69] -> 4.*10^11, v[70] -> 6.*10^11, v[71] -> > 0.05, v[72] -> 0.77993, v[73] -> 4.92958*10^12, v[74] -> 400000000000, v[75] > -> 15000.} *)


title: How can I format DisplayFormula Cell into TraditionalForm when export as HTML

text: ![enter image description here](http://i.stack.imgur.com/BNjHj.png) This example is in `DisplayFormula` cell.               cellExpression=Cell[BoxData[RowBox[{RowBox[{SuperscriptBox["f","\[Prime]",MultilineFunction->None],RowBox[{"(","x",")"}]}],"=",RowBox[{RowBox[{"sin","",FractionBox["1","x"]}],"-",RowBox[{FractionBox["1","x"],"cos",FractionBox["1","x"],RowBox[{"(",RowBox[{"x","!=","0"}],")"}]}]}]}]],"DisplayFormulaNumbered"];CellPrint@cellExpression      How can I format them to the appearance like the following in batch. I set `FontSize->Times`, and `Italic` for $\color{Green}{f'(x)}$, $x$ seperately, but not so easy for too many `InlineFormula`/`DisplayFormula/...` cells by hand. ![Mathematica graphics](http://i.stack.imgur.com/puE3y.png) $$\begin{align*}\color{blue}{f'(x)}=\sin \frac{1}{\color{red}{x}}-\frac{1}{\color{red}{x}}\cos\frac{1}{\color{red}{x}}(\color{red}{x}\neq 0)\tag{1}\end{align*}$$ When I export notebook as html, the formulas are rasterized to image which not in `TraditionalForm` which shown above as that I setted by hand. sample typesetting, inline formulas are images, I'm thinking that how to make them more beautiful and more traditional formal. Most of them are typed into Mathematica by hand As you'll see that some single `f`s are Times Italic, they are good shown, but in `DisplayFormula` they are not. ### Edit: Mike Honeychurch's example ![enter image description here](http://i.stack.imgur.com/1tQXR.png) My Setting(related?): ![enter image description here](http://i.stack.imgur.com/Pik0D.png) ### ------------Note: I've tried Mike's method, however failed, how about yours. I'm on _Windows_ and _Mathemtaica_ 9.


title: How does one go from a string to the contents of a variable with the same name?

text: What command should I use if I want to convert a string to the contents of a variable with the same name as the contents of that string withing a function. ToExpression[] doesn't seem to do it.               func[var_String]:=Module[{var1,var2},var1="some words";var2="other words";ToExpression[var]]          func["var1"]     var1      I want the outcome in this example to be "some words".


title: How can I generate permutations of bit strings with repetition?

text: How can I write a function which has two parameters and it should generate combination of arbitrary range bits, for example: `function[n, k]`, with `n` being range, `k` being number of `1` digits. If I define `n = 4` and `k = 2`, the function should return the following set (in any order):               function[4, 2]      > >     {"1100", "1010", "1001", "0110", "0011", "0101"} >


title: Displaying only unique cell tags OR creating cell group tags

text: I want to make an extensive use of tags and it would add some clarity if CellGroups could display a tag if all of the cells it has have it. Once the cell group is tagged, the individual cells wouldn't need to display their common cell tag. Why do I need it? I'm trying to make a selective notebook embedding function that inserts cells from a notebook x with cell tag y. Is it doable or should I consider using some other mechanism?


title: How can I remove unnecessary warning messages?

text: I updated `Mathematica`,`CdfPlayer` to new Version (9). I made a simple Application in Mathematica 9 and deployed into `CDF`.I get unnecessary messages whenever i open that `CDF` file. How can I overcome that? Error Message : ![enter image description here](http://i.stack.imgur.com/RuTL7.png)


title: DSolve vs a system of differential equations

text: I'm trying to solve a simple system of differential equations.               dp = (D[#1, #2] + #2 #1) &;     dn = (D[#1, #2] - #2 #1) &;     DSolve[{dp[f1[x], x] == a f2[x], dn[f2[x], x] == b f1[x]}, {f1, f2},     x]      using DSolve. Unfortunately, Mathematica is not able to handle this task. Is there a way to force Mathematica to print a result? Of course, it's a simple problem one could do by hand but that's not the point:-).


title: Filter list based on date

text: What I would like to do is remove entries from a list of instrument data when it is in maintenance. The maintenance data I have is a series of dates which look like this;               {{{2009, 6, 29, 10, 41, 0.}, {2009, 6, 30, 15, 26, 0.}}, {{2009, 6,         30, 16, 52, 0.}, {2009, 7, 1, 6, 0, 0.}}, {{2009, 7, 1, 6, 0,         0.}, {2009, 7, 1, 6, 2, 0.}}}      So between 29/6/2009 10:41 and 30/6/2008 15:26 the instrument was in maintenance. The instrument data looks like this;               {{{2010, 1, 1, 6, 15, 0.}, 0.04375}, {{2010, 1, 1, 6, 30, 0.},        0.04375}, {{2010, 1, 1, 6, 45, 0.},        0.04375}, {{2010, 1, 1, 7, 0, 0.},        0.04375}, {{2010, 1, 1, 7, 15, 0.}, 0.04375}}      With the first column being the date/time and the second the value. What I would like is a quick (the instrument data is 100,000 records) way to remove rows from the instrument data when their date falls inside a maintenance period.


title: Is it possible to improve Mathematica's auto-completion feature?

text: In this answer Brett Champion describes how one can intercept and modify the suggestions used for auto-completion. **Question:** Is it possible to modify the suggestion for the automatic auto- completion in _Mathematica_ version 9? ## Background I think it's possible to improve the auto-completion significantly by using _camel humps completion_. If you want to see it in action, I made a small screen-cast to demonstrate it for _Mathematica_ **version 8** (please switch to 1080p and fullscreen): ![enter image description here](http://i.stack.imgur.com/M7IDx.jpg)   * ~~For all users from good old Germany or~~ for users who prefer classical music: here is a ~~GEMA friendly,~~ musically educating version.   * Users from Germany can enjoy this screen-cast in comforting silence! The basic idea is to   * allow `ListLiPlo`, `ListLPlot` or even `LLP` to be expanded to `ListLinePlot`. Since all _Mathematica_ built-in functions are consistently named, this works pretty well   * to sort the list of suggestions by importance. In the screencast, I used the appearance of built-in functions in all packages of the `AddOns` directory as measure. The more often a function was used, the more likely it is to be on top of the list if it matches. To give an example: When you expand `Pl` in version 8, you get a list consisting of `Placed`, `Placeholder`, `PlaceholderRepeated`, `Plain`, `Play`, ... Those are all functions I barely use. I the auto-expansion I wrote, `Plot`, `PlotRange` and `Plus` are on the top of the list and after them all the others follow. In version 9 this was fixed and the completion box seems to have a better ordering.


title: EventHandler Not Detecting KeyDown

text: I am trying to use EventHandler to detect KeyDown within a LocatorPane. Anytime I press a key inside the LocatorPane the proper action is not executed (doesn't matter which key I choose) but rather the the symbol of the key pressed appears in the next input line below the LocatorPane (i.e. it jumps out of the LocatorPane). I must be missing something simple because this works fine with {{"MouseClicked",2} :> (AppendTo[someList, 1]; Print[someList])} but not as shown below with {{"KeyDown", a} :> (AppendTo[someList, 1]; Print[someList])}. Btw, in case it's not obvious I am using the right mouse button for the click because the LocatorPane responds to the left button. Any suggestions on getting this to work properly with KeyDown? - GR               (* code below does not respond to "KeyDown" events but will respond properly to          "MouseClicked" *)               pts = {};          someList = {};          EventHandler[                     LocatorPane[Dynamic[pts], Graphics[Circle[], ImageSize -> 500],        LocatorAutoCreate -> True,        Appearance -> {Graphics[{Red, Disk[]}, ImageSize -> 10],          Graphics[{Blue, Disk[]}, ImageSize -> 10]}],           {{"KeyDown", "a"} :> (AppendTo[someList, 1]; Print[someList])}           ]


title: CUDAQ[] returns False in version 9 while True in version 8

text: CUDA works in version 8 but not in version 9. Is there a way to fix the problem in version 9? I've installed the latest CUDA from the official website https://developer.nvidia.com/cuda-downloads ![enter image description here](http://i.stack.imgur.com/nEDHQ.png) ![enter image description here](http://i.stack.imgur.com/e5caM.png)


title: Why does this pattern for combining two lists require triple underscores (___) to work?

text: I understand that `__` is a list of one or more elements, and that `___` is 0 or more elements, but when I try this rule with 2 underscores I don't get the results I expect.               cartesianProduct[lis1_, lis2_] :=       ReplaceList[{lis1, lis2}, {{___, x_, ___}, {___, y_, ___}} :> {x, y}]          cartesianProduct[{a, b, c}, {x, y, z}]          (* {{a, x}, {a, y}, {a, z}, {b, x}, {b, y}, {b, z}, {c, x}, {c, y}, {c, z}} *)      I guess I do not understand the difference between `_`, `__`, and `___`. Which is the pattern for instructing _Mathematica_ to do what I want?


title: What is happening in Map[Function[x, x^2], a + b + c] from the Pure Function tutorial

text: The Pure Function tutorial gives an example: `Map[Function[x, x^2], a + b + c]`. I would expect the output to be `(a + b + c)^2`, but instead it returns `a^2 + b^2 + c^2`. `Map[Function[x,x^2],a+b+c]//FullForm` even gives `Plus[Power[a,2],Power[b,2],Power[c,2]]` which provides no clarity. What's going on here?


title: How to run function every x seconds?

text: I want to make a `Graphics` with a `Disk` whose position should update every 4 seconds. This is what I've got so far:               RunScheduledTask[(cdts = RandomReal[{-5, 5}, 2]), 4]          {Framed[Graphics[{Yellow, Disk[Dynamic@cdts, 1]}, PlotRange -> 6,         ImageSize -> Large]], Dynamic@cdts}      I chose not to use `Refresh` because that evaluates way more than once every 4 seconds (I'd say every half second or so), even though I've set `UpdateInterval-> 4`, like so:               {Framed[Graphics[{Yellow,          Disk[Dynamic@Refresh[cdts, UpdateInterval -> 4], 1]},         PlotRange -> 6, ImageSize -> Large]], Dynamic@cdts}      From a previous question I asked, I think this is because Mathematica takes the `UpdateInterval` as a minimum, and so updates much more often when it can. From what I've read in the documentation, `RunScheduledTask` should do exactly what I'm looking for, but it seems to update just as quickly as `Refresh`, about twice a second. What am I doing wrong here?? I've been looking for quite a while now for a straightforward method to periodically run functions but none of them seem to work as advertised...


title: Open an html saved notebook

text: I have found an `html` page clearly created using the `Save as HTML` option of `Mathematica`. Is there a way to reverse this operation? That is open the `html` file with `Mathematica` and render it as a `nb` file again?


title: CDF to give away with a custom StyleSheet

text: Related to this. I would like to be able to give away CDF documents created with a custom StyleSheet. The important peculiarity is that this document is assumed to be viewed on a machine with no such StyleSheet. The second one is that in the cases I have in mind delivering a separate file with the StyleSheet to be installed on that machine is absolutely out of question. The StyleSheet should be, therefore, somehow embedded into the document, if this is possible. This is the difference with respect to the answer I mentioned in the beginning. There Vitaly Kaurov created a custom StyleSheet, using it produced a CDF file and opened it on the same machine. On the other hand modifications may be subtle. That is, the StyleSheet in question is built by a slight modification of one of the existing StyleSheets, such as increased line spacing, increased font size and, may be, few others. My question: do you see such a possibility?


title: HTMLEncode a string for webMathematica

text: Is there a native _Mathematica_ way to convert a string like `"<select></select>"` into `"<select></select>"` and similarly for other reserved characters in html (or another encoding that would work in a webpage)?. I'm working in _webMathematica_ , but I can't find a good way to print the literal string `"<select></select>"` into a page - it either gets converted into an node, or it gets wrapped in a `<pre>` tag.


title: Asymptotic expansion of a list

text: I am trying to calculate a asymptotic series expansion of a list.               Series[{0,-((R^2 ν (2+(-1+ν (2+ν)) Cos[2 θ]))/((-1+ν) (1+ν^2) r^2)) +          (R^4 ν (-7+5 ν (2+ν)+16 Cos[2 θ]+(-1+3 ν (2+ν)) Cos[4 θ]))/(4 (-1+ν) (1+ν^2) r^4) +          O[1/r]^6,-((R^2 ν (3+ν) Cos[θ] Sin[θ])/((1+ν^2) r^3))+O[1/r]^4,0}, {r,Infinity,3}]      I don't understand why the `1/r^4` term shows up in the output. Even more, I can copy & paste this input               Series[-((R^2 ν (2+(-1+ν (2+ν)) Cos[2 θ]))/((-1+ν) (1+ν^2) r^2)) +          (R^4 ν (-7+5 ν (2+ν)+16 Cos[2 θ]+(-1+3 ν (2+ν)) Cos[4 θ]))/(4 (-1+ν) (1+ν^2) r^4) +          O[1/r]^6,{r,Infinity,3}]      but evaluating the following line gives an error message about the argument               Series[a/r^2+b/r^4+O[1/r]^6,{r,Infinity,3}]      Any input is highly appreciated.


title: Plotting lists, exact color values

text: I read some descriptions of similar problems but I cannot make them work in my example, I don't know why. I have list of 3 dim values to plot: `x`, `y` and a control variable `z`. I want to plot `x` against `y`, and condition on `z` should determine the colour. The list is:               data = {{1/5, -17.9919, 12}, {1/5, 17.9925, 12}, {1/5, -17.9878, 12}, {1/5, 17.9884, 12},             {2/5, 25.7781, 12}, {2/5, -25.7775, 12}, {2/5, 25.7722, 12}, {2/5, -25.7716, 12},             {3/5, 31.7075, 14}, {3/5, -31.7069, 14}, {3/5, 31.7002, 15}, {3/5, -31.6996, 15},              {4/5, 36.6911, 14}, {4/5, -36.6905, 14}, {4/5, 36.6827, 14}, {4/5, -36.6821, 14},             {1, 41.0745, 14}, {1, -41.0739, 14}, {1, 41.0651, 14}, {1, -41.0645, 14}}      Out of all similar problems I found               nC = 0;     ListPlot[data[[All, {1, 2}]],        PlotStyle -> Directive[PointSize[Large]], Joined -> True,        ColorFunction -> Function[{x, y}, If[data[[++nC, 3]]==12,Red,Black]]] /.       Line[a__] :> Point[a]      But it seems no to recognise any colours so all the points are similar. Can you suggest a solution?


title: Make a scatter plot from two lists

text: I have two lists of values               xx = {0.1, 0.3, 0.35, 0.57, 0.88, 1.0}     yy = {1.2, 3.5, 4.5, 7.8, 9.0, 12.2}      I want to make a scatter plot (list plot) with xx as x axis and yy as y axis. The help document on ListPlot tells me I have to use               ListPlot[{{x1, y1}, {x2, y2}, ...}]      How do I create something like               ListPlot[{{0.1, 1.2}, {0.3, 3.5}, ...}]      from xx and yy? Thank you.


title: Run FileSystem Remotely and Front End/Kernel Locally

text: Is there a way to run both the front end(& kernel) locally while the having Mathematica's filesystem(inode's at minimum) reference another os's filesystem? For example currently I run Mathematica in Ubuntu, but I constantly have issues with Mathematica freezing. Could I run Mathematica inside Windows while running ubuntu in a virtual machine(or remotely) so I could still effectively interface with the linux OS(read and write calls at minimum). Although this is less the ideal, I am hopeful there might be some simple configs to modify. Ideally I am looking for a way to run a Mathematica Notebook both on a virtual machine OS(linux in the case) and the host OS(Windows in this case) but have the code interact as if it was running on the hosted OS. Considering there are a lot of different types of software that allows you to create virtual machines, let's assume for this question(unless a better idea is stated) that I am using either port forwarding or a bridge adapter and shared folders in Virtualbox as a way of communication.


title: Efficient method for inverting a block tridiagonal matrix

text: Is there a better method to invert a large block tridiagonal Hermitian block matrix, other than treating it as a ordinary matrix? For example:               Do[Evaluate@ToExpression["a" <> ToString[i] <> ToString[j]] =        ConstantArray[0, {3, 3}], {i, 1, 4}, {j, 1, 4}]          a11 = DiagonalMatrix@RandomInteger[{1, 10}, 3];     a22 = DiagonalMatrix@RandomInteger[{1, 10}, 3];     a33 = DiagonalMatrix@RandomInteger[{1, 10}, 3];     a44 = DiagonalMatrix@RandomInteger[{1, 10}, 3];          a12 = a21 = Partition[RandomInteger[{1, 10}, 9], 3];     a23 = a32 = Partition[RandomInteger[{1, 10}, 9], 3];     a34 = a43 = Partition[RandomInteger[{1, 10}, 9], 3];          s = ArrayFlatten[Evaluate@Table[           ToExpression["a" <> ToString[i] <> ToString[j]], {i, 1, 4}, {j, 1,4}]]      The elements live in tridiagonal blocks as well as along the diagonal line. ![enter image description here](http://i.stack.imgur.com/JzA6L.gif)


title: Can palettes dock to notebooks?

text: Over on Meta: A wishlist for Mathematica I got an interesting comment on the following suggestion and thought it merited a stand alone question: > re: NOTEBOOK INTERFACE USABILITY & ORGANIZATION > > Dock palettes -- When I use palettes, I'd love the ability to just stick > them on to the side of a notebook window so I don't have to keep searching > for them. Comment: > This may be able to be done using docked cells. @rcollyer See: DockedCells in the documentation. I recognize that Wolfram builds palettes as notebooks and I can imagine that one could create a custom palette whose cells one could dock at the top of another notebook (this would work great if one could split a notebook into panes and scroll through them separately so one always had access to the palette). Just not certain I see a clear way to do this with a supplied palette. So, does anyone know how to dock a palette to a notebook (or any reasonably functional equivalent)?


title: Replace operators

text: `/.` can be used to replace variables but how can one replace operators. For example in `a * b`, `*` can be replaced by `+` or `x` or `/` etc. Is there some function to achieve this?


title: Changing the contents of a TextCell according to the user input of another TextCell

text: Is it possible to change TextCells in the following code in that way, that the TextCell "profile starts at x =" changes to "profile starts at y =" and at the same time the TextCell "measurement starts at y =" changes to "measurements starts at x =" when the input of the user is "y" in the TextCell "direction of the profile (x / y)"? Moreover I don't know why "TextAlignment -> Right" has no effect... Here is the code:               code = ""; ffn = ""; lfn = ""; add = 0; direction = "x"; rs = ""; \     length = ""; startmeasurement = ""; distance = "";     DialogInput[       Grid[{{Grid[{{TextCell["Code (004p):", FontSize -> 16,               TextAlignment -> Right],              InputField[Dynamic[code], String,               FieldSize -> {10, 1}]}}]}, {Grid[{{TextCell[              "first filenumber:", FontSize -> 16, TextAlignment -> Right],              InputField[Dynamic[ffn], Number, FieldSize -> {10, 1}],                  TextCell["last filenumber:", FontSize -> 16,               TextAlignment -> Right],              InputField[Dynamic[lfn], Number, FieldSize -> {10, 1}],                  TextCell["addition to filenumber", FontSize -> 16,               TextAlignment -> Right],              InputField[Dynamic[add], Number, FieldSize -> {10, 1}]},                 {TextCell["direction of the profile (x / y):", FontSize -> 16,               TextAlignment -> Right],              InputField[Dynamic[direction], String, FieldSize -> {2, 1}],                  TextCell["profile starts at x =", FontSize -> 16,               TextAlignment -> Right],              InputField[Dynamic[rs], Number, FieldSize -> {10, 1}],                  TextCell["length of the profile [m]:", FontSize -> 16,               TextAlignment -> Right],              InputField[Dynamic[length], Number, FieldSize -> {10, 1}]},                 {TextCell["measurement starts at y =", FontSize -> 16,               TextAlignment -> Right],              InputField[Dynamic[startmeasurement], Number,               FieldSize -> {10, 1}],                  TextCell["Distance between profiles (+0.5 / -0.5):",               FontSize -> 16, TextAlignment -> Right],              InputField[Dynamic[distance], Number, FieldSize -> {10, 1}]}},            Frame -> All],                    DefaultButton[DialogReturn[og]]}}],        NotebookEventActions -> {"ReturnKeyDown" :>           FrontEndExecute[NotebookWrite[InputNotebook[], "\n"]]}];      Thanks a lot for your help.


title: Viewing the inside of cuboid intersections

text: ![Four Cuboids](http://i.stack.imgur.com/mFupy.jpg)    I have a number of cuboids intersecting as illustrated. I would like to see their intersection, almost the view from inside. Setting the `ViewPoint` to `{0,0,0}` does not reveal much of the structure. Is there some way to visualize this with clever `Graphics[]` options, or must I compute the convex polyhedron that is the intersection of the cuboids (which is really what I want to see)? **Solved by Jens:**   ![Cuboids4](http://i.stack.imgur.com/9w2O7.jpg)


title: Resolving initial / boundary condition conflicts ?

text: This is likely very simple, but I often run into trouble with inconsistent boundary conditions for PDEs; While I know Mathematica sometimes produces "false" errors for spatial derivative conditions, this query is far more simple than that and mainly a syntax / specification query - For example, here's a simple reaction / diffusion equation ;               ro = 235*10^-6; qm = 10^-4; mic = 1*10^-6; De = 5.5*10^-11; eo = 100;  rn = 40*10^-6;          eqnDe = D[Ef1[r, t], t] -      De*(D[Ef1[r, t], r, r] + (2/r)*(D[Ef1[r, t], r])) + 5*Ef1[r, t];               (*Solving attempt*)     x = NDSolve[{eqnDe == 0, Ef1[r, 0] == 0,      Derivative[1, 0][Ef1][rn, t] == 0, Ef1[ro, t] == eo},       Ef1, {r, rn, ro }, {t, 0, 14400}];      This gives a warning that the initial conditions and boundary conditions are inconsistent - I think I can see where this comes from; I tell it that initially, all of $r$ domain is zero while on the boundary I say that at $r_{o}$, it's a constant of $e_{o}$ - my question is how to I tell mathematica that the boundary at $r_{o}$ is a surface, and that it is maintained at a constant $e_{o}$ while initially, at $t = 0$, the $Ef1[r,0] = 0 $ on the domain $r_{n} \leq r \leq r_{o}$ ? This is probably really simple but I would like to know how to fix this conflict and clean up my future code - thanks in advance!


title: Can I use symbolic tensors for simple linear algebra and calculus?

text: As an example, I'd like to calculate this symbolic derivative: > $\frac{\partial}{\partial b}(x-A.b)^{\mathsf{T}}.(x-A.b)$ where $x$ and $b$ are vectors and $A$ is a matrix. What I tried is this:               Clear[x, a, b, n, m]         $Assumptions = {x ∈ Vectors[n, Reals], a ∈ Matrices[{n, m}], b ∈ Vectors[m, Reals]}          expr = TensorReduce[(x - a.b).(x - a.b)]      The value returned by `TensorReduce` looks ok, in the sense that `TensorRank` and `TensorDimensions` return `0` and `{}` as expected for a scalar, and when I use replacement rules to replace `x`, `a`, `b` with proper-sized arrays, I get the expected result. However, when I write:               D[expr, b]      I get the expression: `-2 x.a.1 + a.1.a.b + a.b.a.1`. Looking at this expression, I can sort of guess what the derivative should look like, but I can't use it in code like that. For example, I can't use `TensorDimensions` to get the derivative's dimension, and I can't use replacement rules to insert arrays in place of the symbolic tensors. **ADD** : I've also tried using `TensorProduct`/`TensorContract` instead of `Dot`:               xmab = TensorReduce[x - TensorContract[TensorProduct[a, b], {{2, 3}}]];         expr = TensorReduce[        TensorContract[TensorProduct[xmab, xmab], {{1, 2}}]];       This gives a sensible looking `expr`, but I think `D` doesn't work with `TensorProduct`/`TensorContract`:               D[expr, {b, 1}]      > -2 > (TensorContract^(1,{{0,0},{0,0}}))[a[TensorProduct]b[TensorProduct]x,{{1,4},{2,3}}] > (TensorProduct^(0,1,0))[a,b,x]+(TensorContract^(1,{{0,0},{0,0},{0,0}}))[a[TensorProduct]a[TensorProduct]b[TensorProduct]b,{{1,3},{2,6},{4,5}}] > ((TensorProduct^(0,0,0,1))[a,a,b,b]+(TensorProduct^(0,0,1,0))[a,a,b,b])


title: Problem of how to manipulate Taylor/McLaurin series

text: I'm new to Mathematica so I don't know very well the program itself. I would like to manipulate as he does this person in youtube: http://www.youtube.com/watch?v=fCJHvQaGNiQ But I put all the information but nothing happens, I don't know if there are some changes from Mathematica 6 vs. the Mathematica 9. Thanks a lot!


title: How to track row swap in Gaussian elimination?

text: How do I track which rows were swapped in the Gaussian elimination using RowReduce? I am doing metabolic control analysis on a mathematical of the energy metabolism I have in Mathematica. I need to do several matrix operations including a Gaussian elimination. For my control analysis I need to know which rows were swapped and where they are after the elimination. Is there a way to let Mathematica also give me the final position of the original rows after the elimination? Thank you very much, Anne-Claire