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

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}


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

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?


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

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?


Flipping axis on a plot

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`.


Is it possible to type equations as text in Mathematica?

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?


Finding integral bounds

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?


Negative power instead of fraction

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)


Eureqa Client to connect to Mathematica under Windows

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?


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

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.


List manipulation - various

# 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.


Is there a way to plot discrete functions in mathematica?

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


Draw the plane on ParametricPlot3D with one parameter

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?


How to program a F::argx message?

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?


substitution rules for Penrose tiles

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!


LogPlot and LogLogPlot do not output their legends correctly

![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?


Correct behavior of lock file in hsqldb connection

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?


How to delete duplicate solutions of this system of equations?

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?


Compute the rank of a matrix with variable entries

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)$ ?


diff-able text-only notebooks?

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?


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

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?


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

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!


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

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?


ColorData["VisibleSpectrum"] is wrong?

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?


Expression of uncertainty in measurement.

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.


May the Fourth be with you

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.


Non linear constrained interger Optimization

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


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

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?


Linear regression with x and y errors

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?


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

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_


How can I create a 3D FilledCurve object?

`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)


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

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 ?


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

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?


Manipulate executes twice

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.


Why does StreamColorFunctionScaling refuse to turn off?

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?


How to plot filling under a curve?

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?


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

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?


WSMSetValues function

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


Getting MemoryAllocationFailure from NIntegrate

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)?


Generating a list of questions (simultaneous equations)

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...


Open a Mathematica 9 notebook in Mathematica 8

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


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

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.} *)


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

![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.


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

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".


How can I generate permutations of bit strings with repetition?

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"} >


Displaying only unique cell tags OR creating cell group tags

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?


How can I remove unnecessary warning messages?

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)


DSolve vs a system of differential equations

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:-).


Filter list based on date

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.


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

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.


EventHandler Not Detecting KeyDown

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])}           ]


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

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)


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

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?


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

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?


How to run function every x seconds?

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...


Open an html saved notebook

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?


CDF to give away with a custom StyleSheet

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?


HTMLEncode a string for webMathematica

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.


Asymptotic expansion of a list

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.


Plotting lists, exact color values

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?


Make a scatter plot from two lists

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.


Run FileSystem Remotely and Front End/Kernel Locally

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.


Efficient method for inverting a block tridiagonal matrix

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)


Can palettes dock to notebooks?

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)?


Replace operators

`/.` 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?


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

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.


Viewing the inside of cuboid intersections

![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)


Resolving initial / boundary condition conflicts ?

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!


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

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])


Problem of how to manipulate Taylor/McLaurin series

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!


How to track row swap in Gaussian elimination?

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


Tooltip for a ListPlot3D

I am getting stuck with figuring out how to use `Tooltip` for a `ListPlot3D`. Basically I have a list of values for the 3D plot (no table or function) and would like to have the `Tooltip` return the x, y and z coordinates for the point. Here is the code for the Plot that I would like to have "tooltipped":               correlationMatrix = {{1., -0.312997, -0.23282,        0.21541, -0.492404, -0.429369, -0.529716, -0.139237,        0.545136, -0.329623, 0.0439952, -0.281572,        0.311432, -0.339743, -0.313293, -0.276101}, {-0.312997, 1.,        0.124945, -0.40165, 0.346201, 0.202914,        0.422802, -0.330172, -0.255637, -0.312864, -0.669181,        0.148235, -0.26647, 0.171766, -0.529144, 0.0928761}, {-0.23282,        0.124945, 1., 0.117204, -0.284851, -0.0106801, 0.132487,        0.266604, -0.612488, 0.276884, 0.194778, -0.169994,        0.508427, -0.430038, -0.0587014, -0.646482}, {0.21541, -0.40165,        0.117204, 1., -0.139717, -0.264258, -0.391223, 0.311072, 0.222882,        0.219147, 0.702512, -0.454245, 0.342072, -0.22791, 0.473594,        0.0226572}, {-0.492404, 0.346201, -0.284851, -0.139717, 1.,        0.382168, 0.351843, -0.454952, -0.0969759, -0.234836, -0.355201,        0.169766, -0.190264, 0.337011, 0.264028, 0.509604}, {-0.429369,        0.202914, -0.0106801, -0.264258, 0.382168,        1., -0.24091, -0.279989, -0.0826109, 0.370576, -0.102702,        0.229024, -0.366183, 0.265442, 0.0947463, 0.225124}, {-0.529716,        0.422802, 0.132487, -0.391223, 0.351843, -0.24091,        1., -0.178734, -0.520441, -0.252357, -0.396323, 0.191239, -0.104731,        0.0866192, -0.0556171, -0.0804755}, {-0.139237, -0.330172,        0.266604, 0.311072, -0.454952, -0.279989, -0.178734, 1., -0.050751,        0.659989, 0.515793, 0.0467429, 0.0373106, 0.0889927, 0.257039,        0.0444238}, {0.545136, -0.255637, -0.612488,        0.222882, -0.0969759, -0.0826109, -0.520441, -0.050751,        1., -0.0912518, 0.304593, -0.29235, -0.398841, -0.093443, 0.272338,        0.225868}, {-0.329623, -0.312864, 0.276884, 0.219147, -0.234836,        0.370576, -0.252357, 0.659989, -0.0912518, 1., 0.539342,        0.113201, -0.0615683, 0.133768, 0.362695,        0.0785236}, {0.0439952, -0.669181, 0.194778,        0.702512, -0.355201, -0.102702, -0.396323, 0.515793, 0.304593,        0.539342, 1., -0.573185, 0.0920204, -0.456162,        0.678595, -0.221534}, {-0.281572, 0.148235, -0.169994, -0.454245,        0.169766, 0.229024, 0.191239, 0.0467429, -0.29235,        0.113201, -0.573185, 1., -0.20389, 0.891105, -0.119537,        0.520205}, {0.311432, -0.26647, 0.508427,        0.342072, -0.190264, -0.366183, -0.104731,        0.0373106, -0.398841, -0.0615683, 0.0920204, -0.20389,        1., -0.368594, -0.205337, -0.353868}, {-0.339743,        0.171766, -0.430038, -0.22791, 0.337011, 0.265442, 0.0866192,        0.0889927, -0.093443, 0.133768, -0.456162, 0.891105, -0.368594, 1.,        0.0188257, 0.824432}, {-0.313293, -0.529144, -0.0587014, 0.473594,        0.264028, 0.0947463, -0.0556171, 0.257039, 0.272338, 0.362695,        0.678595, -0.119537, -0.205337, 0.0188257, 1.,        0.187089}, {-0.276101, 0.0928761, -0.646482, 0.0226572, 0.509604,        0.225124, -0.0804755, 0.0444238, 0.225868, 0.0785236, -0.221534,        0.520205, -0.353868, 0.824432, 0.187089, 1.}};          ListPlot3D[correlationMatrix, AxesStyle -> Thickness[0.01],       AxesLabel -> {"X", "Y", "Corr(X,Y)"},       AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}},       ColorFunction -> "BrightBands"]


Importing additional custom data in DIMACS format

I have graphs in DIMACS format, with vertex colors specified. The vertex colors are denoted by lines `n u c`, where `u` is the vertex number and `c` an integer representing its color. Here's an example of a triangle colored with 2 colors:               p edge 3 3     e 1 2     e 2 3     e 3 1     n 1 1     n 2 1     n 3 2      Using `Import`, I can nicely import the graph, but not the vertex colors. Is there a way to read them in with `Import`, or am I forced to write my own reader that manually sets the vertex colors?


Coordinate extraction and manipulating graphs as graphics objects

Consider the image below:               GraphData[{"Wheel", 7}]      ![enter image description here](http://i.stack.imgur.com/pD3BV.jpg) Is it possible in _Mathematica_ to lay several of these `Graph` along each other and then get the coordinates of the resultant network? Something like these at the simplest case: ![enter image description here](http://i.stack.imgur.com/wvNgv.jpg) ![enter image description here](http://i.stack.imgur.com/lw15p.jpg)


Textures are not rendered in combined graphics

p1 = Plot[x^2, {x, -2, 2}, PlotStyle -> {Thick, Black}];      p2 = Graphics3D[{EdgeForm[Black], Texture[p1],       Polygon[{{-2, 0, -1}, {2, 0, -1}, {2, 4, -1}, {-2, 4, -1}},       VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}],       Opacity[1]}, Lighting -> "Neutral", Boxed -> False];     squares =       Table[Graphics3D[{Opacity[.3],       Polygon[{{-Sqrt[y], y, 0}, {Sqrt[y], y, 0}, {Sqrt[y], y,       2 Sqrt[y]}, {-Sqrt[y], y, 2 Sqrt[y]}}]}, Boxed -> False], {y, 0, 4, .25}];     all = Show[Table[squares[[j]], {j, 1, 16}]];     Show[p2]     Show[p2, all]      results in this output for me: ![](http://i.stack.imgur.com/eF6Uf.jpg) ![](http://i.stack.imgur.com/1N0TQ.jpg) However, for others (at least one of whom is a Mac user), indeed the `p2` graphic shows up in the second result. When I click on the cell bracket, and Save As... PDF, the result is ![](http://i.stack.imgur.com/UV7jF.png) And finally, if I directly copy and paste the figure (rather than export), I get this: ![enter image description here](http://i.stack.imgur.com/3BQPH.jpg) I need some independent confirmation of if this a bug in the Windows 7 version of v8.0.4 and if you have any ideas for workarounds since I need a PDF version of the last figure for insertion into other docs. Thanks.


Creating DotPlots

I've been struggling to create a DotPlot like the one shown in Cleveland's The Elements of Graphing Data. ![enter image description here](http://i.stack.imgur.com/jHhjh.jpg) Using the following dataset               data = Sort[{#,       WolframAlpha[       StringJoin["Number of native speakers ", #], {{"Result", 1},         "ComputableData"}]} & /@ {"Mandarin", "French", "English",      "Spanish", "German", "Hindi", "Malay", "Arabic", "Portuguese",      "Russian", "Korean", "Italian", "Cantonese", "Telugu",      "Urdu"}, #1[[2]] < #2[[2]] &]      What is the best approach to replicate this chart with its two axis, dot, dashed lines , etc?


Why x = x doesn't cause an infinite loop, but f[x_] := f[x] does?

If I execute:               In[1] := x = x     Out[1] = x      and then I evaluate the symbol `x`:               In[2] := x     Out[2] = x      it simply returns `x` itself. I don't understand why this doesn't result in an infinite loop. Given that `x` references itself after the assignment `x = x`, I think that evaluating `x` should result in an infinite loop (`x` is replaced by `x`, which is replaced `x`, and so on). What am I missing? Contrast this with what happens with the assignment:               f[x_] := f[x]      Evaluating `f[x]` after this assignment results in an infinite loop:               In[5]:= f[x]      > During evaluation of In[5]:= $IterationLimit::itlim: Iteration limit of 4096 > exceeded.               Out[5]= Hold[f[x]]      **Edit:** Using `x := x` instead of `x = x` does not cause an infinite loop. Using `x = Identity[x]` does not cause an infinite loop either. But using `x := Identity[x]` as suggested by Jacob Akkerboom in the comments results in an infinite loop. Why?


Solving problems with the floor function

I've got the following problem: If I want to calculate the following equation,               S[EK_] = Floor[Piecewise[{{0, 0 < EK < 8130},         {((933.70*((Floor[EK] - 8130)/10000) + 1400)*(Floor[EK] - 8130)/             10000), 8130 < EK <=            13469}, {((228.74*((Floor[EK] - 13469)/10000) +                2397)*((Floor[EK] - 13469)/10000) + 1014),           13469 < EK <= 52881},         {(0.42*Floor[EK] - 8196), 52881 < EK <= 250730},         {(0.45*Floor[EK] - 15718), 250730 < EK}}]]          Solve[S[x]/x == 0.25, x]      _Mathematica_ is calculating but cannot solve the equation. The same goes for another set of equations. Does anybody see the error in the equation or the function? Beste wishes


Conditional range in a parametric plot

I have a program that needs to be done like this:               ParametricPlot[       equation,       If[x < 1, {x, 0, t}, {x, t, 2}]]      But _Mathematica_ didn't seem to recognize the values of xmin and xmax in the range of the independent variable x, nor the variable x itself. The simplest solution, in my opinion, would be to insert `If` expressions into the range itself, something like this:               ParametricPlot[       equation,       {x, If[x < 1, 0, t], If[x >= 1, t, 2]}]      **EDIT:** This is why I needed to do this. I needed to paint the curve when $0<t\leq T$, but "delete" it when $T<t\leq2T$ ![Spirograph](http://i.stack.imgur.com/3zSEK.gif)


Charts performance

Evaluating the following lines in my computer takes near six seconds in Mathematica 10 and near 5 in Mathematica 9. I consider this very slow as only quantiles are being calculated from data to create this simple set of charts. I think that Mathematica should do much better than this. Do you agree? Thoughts?               data = Table[RandomVariate[NormalDistribution[RandomInteger[5], 1], 100000], {10}];     Timing@BoxWhiskerChart[data, ChartLabels -> {"a", "b", "c"}, PerformanceGoal -> "Speed"]


Reduce with Integer domain, but receive a rational solution

I want to find the integer values $k$ so that `D[f[x], x]` has integer solutions. I tried               f[x_] := 2 x^3 - 3 (m - 1) x^2 + k * (m + 2)*(m - 3) x + 1     g := D[f[x], x]     d = Discriminant[g, x]     Reduce[{d == 0, -10 <= k <= 10}, {k, m}, Integers]      I got               (m == -3 && k == 4) || (m == 1 && k == 0) || (m == 7 && k == 3/2)      As you can see in the last solution `k=3/2` which is definitely not an integer, as I have specified in the domain used by `Reduce`. Is this a bug? Can anyone comment on this?


Symbolic bit vectors

I'd like to see how addition and xoring bitvectors mix together. To do this, I implemented (a primitive) vec_add and vec_xor:               makevar[x_, i_] := ToExpression[StringJoin[x, ToString[i]]]          ClearAll[ADD];     S[x_, y_, c_] := c + x - 2 c x + y - 2 c y - 2 x y + 4 c x y     Ca[x_, y_, c_] := c x + c y + x y - 2 c x y     ADD[fa_, fb_, i_] := Module[         {CC, SS, obit},         CC[0] := Ca[fa[0], fb[0], 0];         CC[n_] := Ca[fa[n], fb[n], CC[n - 1]];         SS[0] := S[fa[0], fb[0], 0];         SS[n_] := S[fa[n], fb[n], CC[n - 1]];         obit := SS[i];         Return[obit];         ]     VECADD[fa_, fb_, n_] := Module[         {o},         o := Table[ADD[fa, fb, i], {i, 0, n}];         Return[o];         ]     xor[a_, b_] := a + b - 2*a*b     BITS := 8     xt := Table[{makevar["x", i]}, {i, 0, BITS}]     yt := Table[{makevar["y", i]}, {i, 0, BITS}]          fx[n_] := xt[[n + 1]]     fy[n_] := yt[[n + 1]]          t1 := VECADD[fx, fy, BITS]      fa[n], fb[n] are functions that return n-th variable from a table. The SS and CC functions are SUM/CARRY respectively. Clearly, this doesn't look like a good implementation so my question is: how to do this nicely? It would be perfect to overload operators for ADD/XOR and just write (a+b)^(b+c). EDIT: If the implementation isn't clear: the SS/CC functions implement a FULL ADDER


List manipulation after importing txt-file

I have some problems converting data which I imported from a txt-file into proper Mathematica expressions. After importing my data looks like               sample = {"{3", "\"string1\"", 45, "\"string2\"", 8.32, " {2013", 8, 1, 0, 6, " 19}", "0.}"}      Now I would like to transform it into               converted = {3, "string1", 45, "string2", 8.32`, {2013, 8, 1, 0, 6, 19}, 0.}      I imported the file using `Import[file.txt,"Data"]`


Use URLFetch in init.m

I'm not able to use `URLFetch` in my `$UserBaseDirectory/Kernel/Init.m` as it always returns `ImportString[Null, Text, CharacterEncoding -> "ISO8859-1"]`. Here is my test code, which works in a Notebook, but runs forever in the init file:               ip = $Failed;          While[ip == $Failed,          ip = Quiet@Check[URLFetch@"http://tyilo.com/ip/", $Failed]     ];     MessageDialog[ip];      The reason I would like to use `URLFetch` in my init script is that I have distributed it to a couple of friends and I would like to make it automatically update. Everything except the `URLFetch` part of the auto-update script works, so it would be nice to be able to finish this feature. If you could make it run asynchronously after Mathematica has fully started up, that would be fine too.


How stretch curly brace on multi-line text?

What's the cell option (or other technique) to use to stretch the curly brace that one typically uses in traditional math to group several displayed equations? Like this: ![Mathematica graphics](http://i.stack.imgur.com/3GI4P.png) And is there any better way of getting the vertical alignments of the equations that simply inserting a 3-column table?


Windows Explorer Natural Order

Currently there are a list of notebooks in Windows that I am processing in a folder. Ideally I would like the notebooks to be concated in the same order as how they display in Windows Explorer. I found the question Sort Strings By Natural Order, but none of the answers seem to use the same technique as Windows Explorer. After reading What is the first character in the sort order used by Windows Explorer?, it appears that Windows has an internal function that could be used to naturally sort the filenames. I plan to run this only on Windows, so it is okay if it depends on OS-specific functions, though a pure Mathematica way would be nice. I believe that Windows sorts the files based on ASCII order unless a number is encountered. Ideally I am looking for a function that sorts a list of names into the following order when run. None of the answers linked above correctly order the names below.               {"Ie4 01", "Ie4!01", "Ie4_01", "Ie4_128", "Ie5", "Ie6", "Ie401sp2",       "Ie501sp2"}                    Ie4 01     Ie4!01     Ie4_01     Ie4_128     Ie5     Ie6     Ie401sp2     Ie501sp2


Can I set 'no-go' values in a Manipulate slider?

Is it possible to easily modify a `Manipulate` such that the slider automagically skips certain values? For example, say I am plotting an equation that's perfectly well behaved for all values of `x` between `x=0` and `x=1` except for `x=0.25` where it blows up and causes _Mathematica_ to emit many error messages. I could, of course, check for `x=0.25` in the body of the `Manipulate` and then do something sensible but it would be nice if I could just say to `Manipulate` 'Avoid x=0.25.'


FullGraphics ticks problem

In the document of FullGraphics, it promise to produce the same graphic result as the input one:               "FullGraphics[g] should display the same as g, though it may have a different internal structure."      but it has problem in the ticks and axes as the follow example, as they are too thin and the ticks position aren't the same as the original one.               g = Plot[Sin[x], {x, 0, 10}]     Show[FullGraphics[g], AspectRatio -> 1/GoldenRatio]      I have two question:   1. What is the mechanism of axes, tick etc, why they are treated different from the graphics primitives in MMA? Could you explain how MMA convert the axes, ticks etc into the graphics primitives?   2. Is there any "easy" solution to make FullGraphics to reproduce the same result as the input image, or even write one's own version of FullGraphics? Thanks. Sorry I'm a novice and I can't post the figure.


Plot curves different way so that one can see them when printing black and white

I am going to plot for instance:               Plot[Evaluate[        PDF[ExponentialDistribution[#]][x] & /@ {1/2, 1/5, 1/25,            1/1000}], {x, 0, 50}, AxesOrigin -> {0, 0}]      Now, when someone prints this black and white, I would want him to be able to distinguish between the curves (a line, then a dotted line and so on). How would you suggest me to change the code, to achieve this goal?


Fastest way to test if a numerical array has complex elements

I am looking for the fastest way to test whether an _n_ -dimensional numerical (`NumericQ`) array (in the `ArrayQ` sense) is complex or not. It is considered complex if it has at least one complex element. It is an important requirement that this test must not unpack packed arrays. Currently I have `Not@ArrayQ[arr, _, FreeQ[#, _Complex] &]`, which does not unpack, but it executes the test for each element of packed arrays (can be tested using `Print`). Theoretically it's sufficient to test only one: all elements of a packed array are necessarily of the same type. In theory it's possible to detect whether an array is packed, and if it is, only test the first element, but this is very ugly, so I'd like to avoid it. It' also not easy to implement for an _n_ -dimensional array. What I am hoping for is a function which is internally special cased for packed arrays and is thus very fast.